Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for XML parsing (don't merge without inspection) #224

Open
wants to merge 38 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1f258ed
Minor patches to get things compiling locally.
m8pple May 16, 2021
c023d1b
remove unnecessary change
m8pple May 16, 2021
770d3c6
Merge remote-tracking branch 'origin/1.0.0-alpha' into development-dt…
m8pple May 16, 2021
6c4034c
Adding ccache
m8pple May 16, 2021
d1e684a
Remote extra '=' that stops compilation of handler.
m8pple May 17, 2021
90ecbf7
Fix grammar to match original v4 grammer.
m8pple May 17, 2021
4c758cb
Make appname attribute otional.
m8pple May 17, 2021
524341c
Add error message if appname cannot be recovered.
m8pple May 17, 2021
0fdcebc
Script for checking that an xml file parses and compiles.
m8pple May 17, 2021
16554ce
Remove errant space that stops compilation (#207)
m8pple May 17, 2021
b7df4b7
Automated testing of parsing/compilation for a bunch of xml files.
m8pple May 17, 2021
b9a1a57
Merge remote-tracking branch 'remotes/origin/1.0.0-alpha' into develo…
m8pple May 26, 2021
74e2747
Fixes to parser to get existing v4 XML parsing.
m8pple May 27, 2021
6e2198f
Trying to get automated compilation tests working.
m8pple May 27, 2021
df8099d
Hacky fixed for #225 - should not go into production.
m8pple May 28, 2021
6be6a06
Clean patch for adding automated parse/compile tests
m8pple Jun 12, 2021
d972852
Merge branch '1.0.0-alpha' into development-dt10-changes
m8pple Jun 12, 2021
e992e8b
Merge branch 'dt10_v4_xml_tests' into development-dt10-changes
m8pple Jun 12, 2021
aa10ad1
Emits standard type alias for properties and state. See #231.
m8pple Jun 12, 2021
fd0196a
Add space between & and 1 to avoid #230.
m8pple Jun 12, 2021
c8d3067
Working around bug #230, plus some minor test-case fixes.
m8pple Jun 14, 2021
7ce6aef
Add HaveIdleWork to avoid excessive CPU cost for spinning.
m8pple Jun 14, 2021
ac3abc5
Merge remote-tracking branch 'origin/1.0.0-alpha' into development-dt…
m8pple Jun 15, 2021
0d3add6
Merge branch '1.0.0-alpha' into dt10_v4_xml_tests
m8pple Jun 23, 2021
e3dab87
Stop mothership starting for parse and compile tests.
m8pple Jun 23, 2021
17694db
Merge branch '1.0.0-alpha' into development-dt10-changes
m8pple Jun 23, 2021
f542f8e
Merge branch 'dt10_v4_xml_tests' into development-dt10-changes
m8pple Jun 23, 2021
5cd6d5f
Rebase of hacky fixed for #225 - should not go into production.
m8pple May 28, 2021
0ffd04a
Merge branch 'dt10-patch-for-braces-225' into development-dt10-changes
m8pple Jun 23, 2021
acb66a5
Fixes to XML to avoid C library calls.
m8pple Jun 23, 2021
31d3ae5
Fixes to XML to avoid C library calls.
m8pple Jun 23, 2021
13ff78a
Merge branch 'dt10_v4_xml_tests' into development-dt10-changes
m8pple Jun 23, 2021
5421d51
Invert the sense of handler-log. See #257
m8pple Jun 23, 2021
412c8ec
Single device with print in init
m8pple Jun 23, 2021
25be744
Single device with print in init
m8pple Jun 23, 2021
73f6e4a
Extra run-time tests, plus reliable run-time test-bench.
m8pple Jun 23, 2021
e3ab860
Extra run-time tests, plus reliable run-time test-bench.
m8pple Jun 23, 2021
35b15e5
Merge branch 'dt10_v4_xml_tests' into development-dt10-changes
m8pple Jun 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ run-all-tests.sh
*.exe
*.out
*.app
*.tmp
8 changes: 8 additions & 0 deletions Build/gcc/Makefile.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ CCACHE = $(shell command -v ccache)
CC = $(CCACHE) $(MPICH_DIR)/bin/mpicc
CXX = $(CCACHE) $(MPICH_DIR)/bin/mpicxx

# If ccache is installed then use it. Even if ccache is set up for
# g++ and gcc, it won't be for the custom install of mpi
CCACHE_PATH := $(strip $(shell which ccachee 2> /dev/null))
ifneq ($(CCACHE_PATH),)
CC := $(CCACHE_PATH) $(CC)
CXX := $(CCACHE_PATH) $(CXX)
endif

# GCC, not used for building the Orchestrator, but necessary for the
# Mothership. Immediate-set, because it's used by the shell.
GCC_LIB_DIR := $(ORCHESTRATOR_DEPENDENCIES_DIR)/gcc-7.3.0/lib64:/usr/lib64
Expand Down
3 changes: 3 additions & 0 deletions Config/OrchestratorMessages.ocfg
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@
929(U) : "DS_integ::DS_integ: App name %s has disappeared"
930(U) : "DS_XML::PBuild: incoming .tag field non-null"
931(U) : "DS_XML::_EdgeI_t: pathDecode returns error code %s"
932(U) : "File %s: Graphs element does not have `appname` attribute, and there is no GraphInstance/@id to use instead."
933(U) : "File %s line %s: OutputPin has indexed=true, which is not supported by orchestrator"
996(U) : "CmLoad::Cm_App: DS_XML returns %s errors"
995(U) : "GraphI_t::GetDevice: graph instance corrupt - device %s has zero address"
997(U) : "File %s line %s: .........."
998(U) : "File %s line %s: Unknown XML element %s should have caught by the validator"
Expand Down
106 changes: 68 additions & 38 deletions Config/V4Grammar3.ocfg
Original file line number Diff line number Diff line change
@@ -1,84 +1,114 @@
<?xml version="1.0"?>
<!-- V4 Grammar definition file, 2020-09-29. -->
<Graphs Graphs="[1],[1]xmlns,[0..1]formatMinorVersion,[1]appname">
<GraphType GraphType="[1],[1]id">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>
<MetaData MetaData="[]"/>
<SharedCode SharedCode="[0..1]"><CDATA CDATA="[1]"/></SharedCode>
<Graphs Graphs="[1],[1]xmlns,[0..1]formatMinorVersion,[0..1]appname">
<GraphType GraphType="[1],[1]id,[0..1]xmlns">

<MetaData MetaData="[],[1](key,value)"/>
<Metadata Metadata="[],[1](key,value)"/>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>

<SharedCode SharedCode="[0..1]"><CDATA CDATA="[0..1]"/></SharedCode>
<MessageTypes MessageTypes="[0..1]">
<MessageType MessageType="[],[1]id"><CDATA CDATA="[1]"/></MessageType>

<MessageType MessageType="[],[1]id">
<Message Message="[0..1]">
<CDATA CDATA="[0..1]"/>
</Message>
</MessageType>
</MessageTypes>
<DeviceTypes DeviceTypes="[1]">
<DeviceType DeviceType="[],[1]id">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[1]"/></State>
<SharedCode SharedCode="[0..1]"><CDATA CDATA="[1]"/></SharedCode>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[0..1]"/></State>
<SharedCode SharedCode="[0..1]"><CDATA CDATA="[0..1]"/></SharedCode>
<SupervisorOutPin SupervisorOutPin="[0..1],[1]messageTypeId">
<OnSend OnSend="[1]"><CDATA CDATA="[1]"/></OnSend>

<OnSend OnSend="[1]"><CDATA CDATA="[0..1]"/></OnSend>
</SupervisorOutPin>

<SupervisorInPin SupervisorInPin="[0..1],[1]messageTypeId">
<OnReceive OnReceive="[1]"><CDATA CDATA="[1]"/></OnReceive>

<OnReceive OnReceive="[1]"><CDATA CDATA="[0..1]"/></OnReceive>
</SupervisorInPin>
<InputPin InputPin="[],[1](name,messageTypeId)">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[1]"/></State>
<OnReceive OnReceive="[1]"><CDATA CDATA="[1]"/></OnReceive>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[0..1]"/></State>
<OnReceive OnReceive="[1]"><CDATA CDATA="[0..1]"/></OnReceive>
</InputPin>
<OutputPin OutputPin="[],[1](name,messageTypeId)">
<OnSend OnSend="[1]"><CDATA CDATA="[1]"/></OnSend>
<OutputPin OutputPin="[],[1](name,messageTypeId),[0..1](indexed)">

<OnSend OnSend="[1]"><CDATA CDATA="[0..1]"/></OnSend>
</OutputPin>
<ReadyToSend ReadyToSend="[0..1]"><CDATA CDATA="[1]"/></ReadyToSend>
<OnInit OnInit="[0..1]"><CDATA CDATA="[1]"/></OnInit>
<OnHardwareIdle OnHardwareIdle="[0..1]"><CDATA CDATA="[1]"/></OnHardwareIdle>
<OnDeviceIdle OnDeviceIdle="[0..1]"><CDATA CDATA="[1]"/></OnDeviceIdle>

<ReadyToSend ReadyToSend="[0..1]"><CDATA CDATA="[0..1]"/></ReadyToSend>
<OnInit OnInit="[0..1]"><CDATA CDATA="[0..1]"/></OnInit>
<OnHardwareIdle OnHardwareIdle="[0..1]"><CDATA CDATA="[0..1]"/></OnHardwareIdle>
<OnDeviceIdle OnDeviceIdle="[0..1]"><CDATA CDATA="[0..1]"/></OnDeviceIdle>
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</DeviceType>
<ExternalType ExternalType="[],[1]id">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>
<InputPin InputPin="[],[1](name,messageTypeId)"/>
<OutputPin OutputPin="[],[1](name,messageTypeId)"/>
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</ExternalType>
<SupervisorType SupervisorType="[0..1],[1]id,[0..1](SupervisorInPin,SupervisorOutPin)">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[1]"/></State>
<Code Code="[0..1]"><CDATA CDATA="[1]"/></Code>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[0..1]"/></State>
<Code Code="[0..1]"><CDATA CDATA="[0..1]"/></Code>
<SupervisorOutPin SupervisorOutPin="[0..1],[1]id,[1]messageTypeId">
<OnSend OnSend="[1]"><CDATA CDATA="[1]"/></OnSend>

<OnSend OnSend="[1]"><CDATA CDATA="[0..1]"/></OnSend>
</SupervisorOutPin>
<SupervisorInPin SupervisorInPin="[0..1],[1]id,[1]messageTypeId">
<OnReceive OnReceive="[1]"><CDATA CDATA="[1]"/></OnReceive>

<OnReceive OnReceive="[1]"><CDATA CDATA="[0..1]"/></OnReceive>
</SupervisorInPin>
<InputPin InputPin="[],[1](name,messageTypeId)">
<Properties Properties="[0..1]"><CDATA CDATA="[1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[1]"/></State>
<OnReceive OnReceive="[1]"><CDATA CDATA="[1]"/></OnReceive>

<Properties Properties="[0..1]"><CDATA CDATA="[0..1]"/></Properties>
<State State="[0..1]"><CDATA CDATA="[0..1]"/></State>
<OnReceive OnReceive="[1]"><CDATA CDATA="[0..1]"/></OnReceive>
</InputPin>
<OutputPin OutputPin="[],[1](name,messageTypeId)">
<OnSend OnSend="[1]"><CDATA CDATA="[1]"/></OnSend>

<OnSend OnSend="[1]"><CDATA CDATA="[0..1]"/></OnSend>
</OutputPin>
<OnInit OnInit="[0..1]"><CDATA CDATA="[1]"/></OnInit>
<OnSupervisorIdle OnSupervisorIdle="[0..1]"><CDATA CDATA="[1]"/></OnSupervisorIdle>
<OnRTCL OnRTCL="[..1]"><CDATA CDATA="[1]"/></OnRTCL>
<OnStop OnStop="[..1]"><CDATA CDATA="[1]"/></OnStop>
<OnCTL OnCTL="[..1]"><CDATA CDATA="[1]"/></OnCTL>

<OnInit OnInit="[0..1]"><CDATA CDATA="[0..1]"/></OnInit>
<OnSupervisorIdle OnSupervisorIdle="[0..1]"><CDATA CDATA="[0..1]"/></OnSupervisorIdle>
<OnRTCL OnRTCL="[..1]"><CDATA CDATA="[0..1]"/></OnRTCL>
<OnStop OnStop="[..1]"><CDATA CDATA="[0..1]"/></OnStop>
<OnCTL OnCTL="[..1]"><CDATA CDATA="[0..1]"/></OnCTL>
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</SupervisorType>
</DeviceTypes>
</GraphType>
<GraphInstance GraphInstance="[],[1](id,graphTypeId),[0..1](P)">
<MetaData MetaData="[]"/>
<GraphInstance GraphInstance="[],[1](id,graphTypeId),[0..1](P),[0..1]xmlns">
<MetaData MetaData="[],[1](key,value)"/>
<Metadata Metadata="[],[1](key,value)"/>
<DeviceInstances DeviceInstances="[0..1]">
<DevI DevI="[],[1](id,type),[0..1](P,S)">
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</DevI>
<ExtI ExtI="[],[1](id,type),[0..1]P">
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</ExtI>
</DeviceInstances>
<EdgeInstances EdgeInstances="[0..1]">
<EdgeI EdgeI="[],[1]path(path),[0..1](P,S)">
<EdgeI EdgeI="[],[1]path(path),[0..1](P,S),[0..1](sendIndex)">
<MetaData MetaData="[]"/>
<Metadata Metadata="[]"/>
</EdgeI>
</EdgeInstances>
</GraphInstance>
Expand Down
20 changes: 19 additions & 1 deletion Source/Common/CommonBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,26 @@ void CommonBase::MPISpinner()

int MSGBUFSIZ = 1024; // Individual incoming message buffer
char * MSGBUF = new char[MSGBUFSIZ]; // Pull it off the heap

const int MAX_PROBE_IDLE_BACKOFF_US=100000; // Maximum is 100,000us, i.e. 10hz
int probe_idle_backoff_us=0;
for (;;) {
// See if there are any MPI packets coming down the pipe
MPI_Status status; // Note the multi-threaded MPI probe
int flag;
MPI_Iprobe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&flag,&status);
if (flag==0) { // Nothing there....
OnIdle(); // Guess
if(HaveIdleWork()){
OnIdle(); // Guess
}else{
probe_idle_backoff_us=std::min<int>(MAX_PROBE_IDLE_BACKOFF_US, std::max<int>(10, (probe_idle_backoff_us*5)/4));
OSFixes::sleep( probe_idle_backoff_us / 1000 );
}
continue; // And try again
}

probe_idle_backoff_us=0;

int count;
MPI_Get_count(&status,MPI_CHAR,&count);
if (count > MSGBUFSIZ) { // Ensure we have the space for it
Expand Down Expand Up @@ -142,6 +153,13 @@ void CommonBase::OnIdle()

//------------------------------------------------------------------------------

bool CommonBase::HaveIdleWork()
{
return true; // For compatibility with existing users of OnIdle
}

//------------------------------------------------------------------------------

unsigned CommonBase::OnPmap(PMsg_p * Z)
{
pPmap->Register(Z);
Expand Down
1 change: 1 addition & 0 deletions Source/Common/CommonBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ virtual unsigned Decode(PMsg_p *) = 0;
void Dump(unsigned = 0,FILE * = stdout);
unsigned OnExit(PMsg_p *);
virtual void OnIdle();
virtual bool HaveIdleWork(); // Return false if there is something we want to do in OnIdle
unsigned OnPmap(PMsg_p *);
unsigned OnSystPingAck(PMsg_p *);
unsigned OnSystPingReq(PMsg_p *);
Expand Down
19 changes: 16 additions & 3 deletions Source/LogServer/LogServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,27 @@ while (recd!=0) { // Walk the records in the section

//------------------------------------------------------------------------------

// DT10 : This was previously a static within LogServer::OnIdle. A static
// global here seems as problematic as there, so moved it out. It looked
// like a hack anyway.
static bool OnIdle_flag0 = false; // All the processes registered?

bool LogServer::HaveIdleWork()
{
if(logfp==0) return false;
if((OnIdle_flag0==false)&&(pPmap->vPmap.size()>=unsigned(Usize))){
return true;
}
return false;
}

void LogServer::OnIdle()
{
if (logfp==0) return; // May not yet have an output channel
static bool flag0 = false; // All the processes registered?
if ((flag0==false)&&(pPmap->vPmap.size()>=unsigned(Usize))) {
if ((OnIdle_flag0==false)&&(pPmap->vPmap.size()>=unsigned(Usize))) {
if (pPmap->vPmap.size()>unsigned(Usize))Post(113);
pPmap->Show(logfp);
flag0 = true; // Make sure we just do this once
OnIdle_flag0 = true; // Make sure we just do this once
}
CommonBase::OnIdle(); // Any base actions?
}
Expand Down
1 change: 1 addition & 0 deletions Source/LogServer/LogServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ string Assemble(int,vector<string> &);
void Dump(unsigned = 0,FILE * = stdout);
void InitFile();
void LoadMessages(string);
bool HaveIdleWork();
void OnIdle();
unsigned OnLoad(PMsg_p *);
unsigned OnLogP(PMsg_p *);
Expand Down
11 changes: 9 additions & 2 deletions Source/OrchBase/Composer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ void Composer::formDevTStrings(ComposerGraphI_t* builderGraphI, DevT_t* devT)

formHandlerPreamble(dTypStrs);
formDevTHandlers(dTypStrs);
formDevTPropsDStateD(dTypStrs);
formDevTPropsDStateD(builderGraphI->graphI, dTypStrs);
formDevTInputPinHandlers(dTypStrs);
formDevTOutputPinHandlers(dTypStrs);

Expand Down Expand Up @@ -2196,11 +2196,13 @@ void Composer::formDevTHandlers(devTypStrings_t* dTypStrs)
/******************************************************************************
* Form Device Type Properties and State declarations
*****************************************************************************/
void Composer::formDevTPropsDStateD(devTypStrings_t* dTypStrs)
void Composer::formDevTPropsDStateD(GraphI_t *graph, devTypStrings_t* dTypStrs)
{
DevT_t* devT = dTypStrs->devT; // grab a local copy of the devtype
std::string devTName = devT->Name(); // grab a local copy of the name

std::string graphTName=graph->pT->Name();

std::stringstream vars_h("");

// Write Properties declaration
Expand All @@ -2209,6 +2211,8 @@ void Composer::formDevTPropsDStateD(devTypStrings_t* dTypStrs)
vars_h << "typedef struct " << devTName << "_properties_t \n{\n";
vars_h << devT->pPropsD->C_src();
vars_h << "\n} devtyp_" << devTName << "_props_t;\n\n";

vars_h << "typedef devtyp_" << devTName << "_props_t "<<graphTName<<"_"<<devTName<<"_properties_t;\n\n";
}

// Write State declaration
Expand All @@ -2217,6 +2221,8 @@ void Composer::formDevTPropsDStateD(devTypStrings_t* dTypStrs)
vars_h << "typedef struct " << devTName << "_state_t \n{\n";
vars_h << devT->pStateD->C_src();
vars_h << "\n} devtyp_" << devTName << "_state_t;\n\n";

vars_h << "typedef devtyp_" << devTName << "_state_t "<<graphTName<<"_"<<devTName<<"_state_t;\n\n";
}

// Append to the strings
Expand Down Expand Up @@ -2400,6 +2406,7 @@ void Composer::formDevTOutputPinHandlers(devTypStrings_t* dTypStrs)
if ((*pinO)->pMsg->pPropsD)
{
handlers_cpp << " pkt_" << (*pinO)->pMsg->Name();

handlers_cpp << "_pyld_t* message";
handlers_cpp << " OS_ATTRIBUTE_UNUSED= ";
handlers_cpp << "static_cast<pkt_";
Expand Down
2 changes: 1 addition & 1 deletion Source/OrchBase/Composer.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void formDevTStrings(ComposerGraphI_t*, DevT_t*);
void populatePinTIdxMap(DevT_t*);
void formHandlerPreamble(devTypStrings_t*);
void formDevTHandlers(devTypStrings_t*);
void formDevTPropsDStateD(devTypStrings_t*);
void formDevTPropsDStateD(GraphI_t *graph, devTypStrings_t*);
void formDevTInputPinHandlers(devTypStrings_t* dTypStrs);
void formDevTOutputPinHandlers(devTypStrings_t* dTypStrs);

Expand Down
7 changes: 7 additions & 0 deletions Source/OrchBase/Handlers/CmCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ fflush(fp);

//------------------------------------------------------------------------------

bool CmCall::IsEmpty()
{
return Equeue.empty();
}

//------------------------------------------------------------------------------

Cli CmCall::Front()
// Provides a valid Cm object: if there was one in the Q, it gets popped off
// the front; otherwise an empty one is returned.
Expand Down
1 change: 1 addition & 0 deletions Source/OrchBase/Handlers/CmCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void CaEcho(Cli::Cl_t);
void CaFile(Cli::Cl_t);
void Dump(unsigned = 0,FILE * = stdout);
Cli Front();
bool IsEmpty();
void Show(FILE * = stdout);
unsigned operator()(Cli *);

Expand Down
Loading