diff --git a/.gitignore b/.gitignore index 5a5c1a63..efec9745 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ run-all-tests.sh *.exe *.out *.app +*.tmp diff --git a/Build/gcc/Makefile.dependencies b/Build/gcc/Makefile.dependencies index a24817aa..fd59f6bd 100644 --- a/Build/gcc/Makefile.dependencies +++ b/Build/gcc/Makefile.dependencies @@ -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 diff --git a/Config/OrchestratorMessages.ocfg b/Config/OrchestratorMessages.ocfg index ae6381ad..d89514d4 100644 --- a/Config/OrchestratorMessages.ocfg +++ b/Config/OrchestratorMessages.ocfg @@ -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" diff --git a/Config/V4Grammar3.ocfg b/Config/V4Grammar3.ocfg index e1c55413..33f9dbee 100644 --- a/Config/V4Grammar3.ocfg +++ b/Config/V4Grammar3.ocfg @@ -1,84 +1,114 @@ - - - - - + + + + + + + + + - + + + + + + - - - + + + + - + + + - + + - - - + + + + - - + + + - - - - + + + + + + - + + + - - - + + + + - + + - + + - - - + + + + - + + - - - - - + + + + + + + - - + + + + + - + + diff --git a/Source/Common/CommonBase.cpp b/Source/Common/CommonBase.cpp index 2e7e8ec5..194f2325 100644 --- a/Source/Common/CommonBase.cpp +++ b/Source/Common/CommonBase.cpp @@ -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(MAX_PROBE_IDLE_BACKOFF_US, std::max(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 @@ -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); diff --git a/Source/Common/CommonBase.h b/Source/Common/CommonBase.h index 8a26a4fa..30b83ebb 100644 --- a/Source/Common/CommonBase.h +++ b/Source/Common/CommonBase.h @@ -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 *); diff --git a/Source/LogServer/LogServer.cpp b/Source/LogServer/LogServer.cpp index fedfeec8..3d75b89e 100644 --- a/Source/LogServer/LogServer.cpp +++ b/Source/LogServer/LogServer.cpp @@ -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? } diff --git a/Source/LogServer/LogServer.h b/Source/LogServer/LogServer.h index 1412daee..193976e3 100644 --- a/Source/LogServer/LogServer.h +++ b/Source/LogServer/LogServer.h @@ -22,6 +22,7 @@ string Assemble(int,vector &); void Dump(unsigned = 0,FILE * = stdout); void InitFile(); void LoadMessages(string); +bool HaveIdleWork(); void OnIdle(); unsigned OnLoad(PMsg_p *); unsigned OnLogP(PMsg_p *); diff --git a/Source/OrchBase/Composer.cpp b/Source/OrchBase/Composer.cpp index 5de81b32..943f5a9b 100644 --- a/Source/OrchBase/Composer.cpp +++ b/Source/OrchBase/Composer.cpp @@ -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); @@ -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 @@ -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 "<pStateD->C_src(); vars_h << "\n} devtyp_" << devTName << "_state_t;\n\n"; + + vars_h << "typedef devtyp_" << devTName << "_state_t "<pMsg->pPropsD) { handlers_cpp << " pkt_" << (*pinO)->pMsg->Name(); + handlers_cpp << "_pyld_t* message"; handlers_cpp << " OS_ATTRIBUTE_UNUSED= "; handlers_cpp << "static_cast + //============================================================================== DS_XML::DS_XML(OrchBase * _par) @@ -40,6 +42,7 @@ DS_map["InputPin"] = cInputPin; DS_map["MessageType"] = cMessageType; DS_map["MessageTypes"] = cMessageTypes; DS_map["MetaData"] = cMetaData; +DS_map["Metadata"] = cMetaData; DS_map["OnCTL"] = cOnCTL; DS_map["OnDeviceIdle"] = cOnDeviceIdle; DS_map["DevI"] = cDevI; @@ -77,7 +80,19 @@ DS_XML::~DS_XML() void DS_XML::_Apps_t(xnode * pn) // XML::Graphs { -aname = pn->FindAttr("appname"); // Get (and store) the application name +string aname = pn->FindAttr("appname");// Get the app name +if(aname.empty()){ + xnode *c=pn->FindChild("GraphInstance"); + if(c){ + string id=c->FindAttr("id"); + if(id!=""){ + aname=id; + } + } + if(aname.empty()){ + par->Post(932, pn->par->ename ); // Filename is root element name (?). + } +} Apps_t * pAP = new Apps_t(par,aname); // Uniquely knits itself into skyhook pAP->Def(pn->lin); // Defined on line... pAP->filename = pn->par->ename; // Filename is root element name @@ -116,6 +131,51 @@ Cstr = "// Line " + int2str(pn->lin) + "\n" + Cstr; return new CFrag(Cstr); } +static const char *match_curly_braces(const char *begin, const char *end) +{ + assert(*begin == '{'); + ++begin; + while(beginFindAttr("id"); MsgT_t * pM = new MsgT_t(pGT,mname); pM->Def(pn->lin); -pM->pPropsD = _CFrag(pn); +xnode *cc=pn->FindChild("Message"); +pM->pPropsD = _CFrag(cc); +fprintf(stderr, "Msg: %s = '%s'\n", mname.c_str(), pM->pPropsD->C_src().c_str()); return pM; } @@ -410,6 +483,14 @@ WALKVECTOR(xnode *,pn->vnode,i) { PinT_t * DS_XML::_PinT_t(DevT_t * pD,xnode * pn) // XML::PinType { +// Hack to reject indexed pins while they are not supported +string indexed = pn->FindAttr("indexed"); +if(!indexed.empty()){ + if(indexed!="false" && indexed!="0"){ + par->Post(933,__FILE__,int2str(__LINE__)); + } +} + string pname = pn->FindAttr("name"); unsigned line = pn->lin; // Go get file location PinT_t * pP; diff --git a/Source/RTCL/RTCL.cpp b/Source/RTCL/RTCL.cpp index 51fe4192..dac98b0f 100644 --- a/Source/RTCL/RTCL.cpp +++ b/Source/RTCL/RTCL.cpp @@ -106,6 +106,12 @@ fprintf(fp,"%sRTCL dump ------------------------------------------------\n",os); fflush(stdout); } +bool RTCL::HaveIdleWork() +{ + // We don't have OnIdle, so must never have work. + return false; +} + //------------------------------------------------------------------------------ unsigned RTCL::OnExit(PMsg_p * Z) diff --git a/Source/RTCL/RTCL.h b/Source/RTCL/RTCL.h index d3d2d9ed..f46ac27c 100644 --- a/Source/RTCL/RTCL.h +++ b/Source/RTCL/RTCL.h @@ -23,6 +23,8 @@ void Dump(unsigned = 0,FILE * = stdout); unsigned OnExit(PMsg_p *); unsigned OnRTCL(PMsg_p *); +bool HaveIdleWork(); + public: struct comms_t { RTCL * pthis; diff --git a/Source/Root/Root.cpp b/Source/Root/Root.cpp index 93589686..b106ff59 100644 --- a/Source/Root/Root.cpp +++ b/Source/Root/Root.cpp @@ -296,6 +296,14 @@ fflush(fp); //------------------------------------------------------------------------------ +bool Root::HaveIdleWork() +{ + if(pCmCall->IsEmpty()){ + return false; + } + return true; +} + void Root::OnIdle() { Cli Cm = pCmCall->Front(); // Anything in the batch queue? diff --git a/Source/Root/Root.h b/Source/Root/Root.h index 8947a2cd..b682de9c 100644 --- a/Source/Root/Root.h +++ b/Source/Root/Root.h @@ -42,6 +42,7 @@ unsigned CmRetu(Cli *); bool Config(); #include "Decode.cpp" void Dump(unsigned = 0,FILE * = stdout); +bool HaveIdleWork(); void OnIdle(); unsigned OnInje(PMsg_p *); unsigned OnKeyb(PMsg_p *); diff --git a/Source/Softswitch/inc/softswitch.h b/Source/Softswitch/inc/softswitch.h index ffa66da1..f9e53f7b 100644 --- a/Source/Softswitch/inc/softswitch.h +++ b/Source/Softswitch/inc/softswitch.h @@ -39,7 +39,7 @@ template inline void __handler_log(uint32_t src, int level, { #ifdef TRIVIAL_LOG_HANDLER // Call a truly trivial log handler. - if(level >= P_LOG_LEVEL) softswitch_trivial_log_handler(src, pkt); + if(level <= P_LOG_LEVEL) softswitch_trivial_log_handler(src, pkt); return; #else // No log handler, do nothing diff --git a/Tests/ReferenceXML/compile_app.exp b/Tests/ReferenceXML/compile_app.exp new file mode 100755 index 00000000..0594bbd7 --- /dev/null +++ b/Tests/ReferenceXML/compile_app.exp @@ -0,0 +1,50 @@ +#!/usr/bin/env expect + +# https://stackoverflow.com/a/23287132 +variable SCRIPT_PATH [file normalize [info script]] +set HERE [file dirname $SCRIPT_PATH] + +set script [lindex $argv 0] +send_user "Relative xml path = $script\n" + +set script [file normalize $script] +send_user "Absolute xml path = $script\n" + +spawn "$HERE/../../orchestrate.sh" -n + +expect { + default { send_user "Orchestrator didn't make it to prompt.\n" ; exit 1; } + "POETS>" +} + +send "load /app = \"$script\"\n" + +expect { + default { send_user "Timeout or unexpected outcome while loading app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + "failed validation with" { send_user "The XML file could not be validated.\n"; exit 1; } + -re ".*Application file .* loaded in .* ms." +} + +send "tlink /app = *\n" +send "place /tfill = *\n" + +expect { + default { send_user "Timeout or unexpected outcome while linking/placing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "Graph instance .+ placed successfully." +} + + +set timeout 60 +send "compose /app = *\n\n" + +expect { + default { send_user "Timeout or unexpected outcome while composing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "Graph instance .+ composed successfully." +} + +send_user "Graph appears to have loaded and compiled!" + +exit 0; diff --git a/Tests/ReferenceXML/parse_app.exp b/Tests/ReferenceXML/parse_app.exp new file mode 100755 index 00000000..d5d60b96 --- /dev/null +++ b/Tests/ReferenceXML/parse_app.exp @@ -0,0 +1,52 @@ +#!/usr/bin/env expect + +# https://stackoverflow.com/a/23287132 +variable SCRIPT_PATH [file normalize [info script]] +set HERE [file dirname $SCRIPT_PATH] + +set script [lindex $argv 0] +send_user "Relative xml path = $script\n" + +set script [file normalize $script] +send_user "Absolute xml path = $script\n" + +spawn "$HERE/../../orchestrate.sh" -n + +proc end_program {msg} { + send "exit\n"; + close; + wait; + sleep 0.2 + send_user $msg; + exit 1; +} + + + +expect { + default { send_user "Orchestrator didn't make it to prompt.\n" ; exit 1; } + "POETS>" +} + +send "load /app = \"$script\"\n" + +expect { + default { end_program "Timeout or unexpected outcome while loading app.\n" ; } + "unintelligible" { end_program "Command was invalid." ; } + "failed validation with" { end_program "The XML file could not be validated.\n"; } + "which is not supported by orchestrator" { end_program "The XML file is not supported by the orchestrator.\n"; } + -re ".*Application file .* loaded in .* ms." +} + +send "tlink /app = *\n" +send "place /tfill = *\n" + +expect { + default { send_user "Timeout or unexpected outcome while linking/placing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "Graph instance .+ placed successfully." +} + +send_user "Graph appears to have loaded and linked!" + +exit 0; diff --git a/Tests/ReferenceXML/run_app_standard_outputs.exp b/Tests/ReferenceXML/run_app_standard_outputs.exp new file mode 100755 index 00000000..ca4ae26b --- /dev/null +++ b/Tests/ReferenceXML/run_app_standard_outputs.exp @@ -0,0 +1,65 @@ +#!/usr/bin/env expect + +# https://stackoverflow.com/a/23287132 +variable SCRIPT_PATH [file normalize [info script]] +set HERE [file dirname $SCRIPT_PATH] + +set script [lindex $argv 0] +send_user "Relative xml path = $script\n" + +set script [file normalize $script] +send_user "Absolute xml path = $script\n" + +# Capture stderr too +spawn sh -c "$HERE/../../orchestrate.sh 2>&1" + +expect { + default { send_user "Orchestrator didn't make it to prompt.\n" ; exit 1; } + "Can't connect to " { send_user "RETRY:HostLink is locked or no hardware.\n"; exit 1; } + "POETS>" +} + +send "load /app = \"$script\"\n" + +expect { + default { send_user "Timeout or unexpected outcome while loading app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + "failed validation with" { send_user "The XML file could not be validated.\n"; exit 1; } + -re ".*Application file .* loaded in .* ms." + +} + +send "tlink /app = *\n" +send "place /tfill = *\n" + +expect { + default { send_user "Timeout or unexpected outcome while linking/placing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "Graph instance .+ placed successfully." +} + + +set timeout 60 +send "compose /app = *\n\n" + +expect { + default { send_user "Timeout or unexpected outcome while composing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "Graph instance .+ composed successfully." +} + +send_user "Graph appears to have loaded and compiled!" + +set timeout 60 +send "deploy /app = *\n\n" +send "initialise /app = *\n\n" +send "run /app = *\n\n" + +expect { + default { send_user "Timeout or unexpected outcome while composing app.\n" ; exit 1; } + "unintelligible" { send_user "Command was invalid." ; exit 1; } + -re "_HANDLER_EXIT_FAIL_9be65737_" { send_user "Received explicit failure from devices."; exit 1; } + -re "_HANDLER_EXIT_SUCCESS_9be65737_" { send_user "Received success from devices."; exit 0; } +} + +exit 0; diff --git a/Tests/ReferenceXML/test_compile.sh b/Tests/ReferenceXML/test_compile.sh new file mode 100755 index 00000000..80d9d1cd --- /dev/null +++ b/Tests/ReferenceXML/test_compile.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +echo "TAP version 13" + +HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +ORCHROOT="$(realpath $HERE/../..)" + +VERBOSE=0 +ABORT_ON_ERROR=0 + +while [[ $# -gt 0 ]] ; do + case $1 in + --verbose) + VERBOSE=1 + shift + ;; + --abort-on-error) + ABORT_ON_ERROR=1 + shift + ;; + *) # unknown option + >&2 "Didnt understand option $1" + exit 1 + ;; + esac +done + +TN=0 + +function TODO_compile { + F="$1" + RR=$(realpath --relative-to="$ORCHROOT" "$F") + echo "not ok $TN - # TODO Compile $RR, $2" + TN=$((TN+1)) +} + +############################################ +## Compilation + +PLOG_FILTER='s/^.*will be written to '\''([^'\'']+[.]plog)'\''.+$/\1/p' + +function TODO_compile { + F="$1" + RR=$(realpath --relative-to="$ORCHROOT" "$F") + echo "not ok $TN - # TODO Compile $RR, $2" + TN=$((TN+1)) +} + +function test_compile_success { + F="$1" + if [[ $VERBOSE -eq 1 ]] ; then + OUTPUT=$($HERE/compile_app.exp $F ) + RES=$? + + if [[ $RES -ne 0 ]] ; then + PLOG_LINE=$(echo $OUTPUT | tr -dc '[[:print:]]' | sed -r -n "${PLOG_FILTER}" ) + echo "" + echo "#Validation of $F Failed." + echo "$OUTPUT" | while read l ; do + echo "# > $l" + done + echo "# plog is in ${PLOG_LINE}" + echo "" + while read l ; do + echo "# > $l" + done < $ORCHROOT/bin/${PLOG_LINE} + fi + else + $HERE/compile_app.exp $F > /dev/null + RES=$? + fi + RR=$(realpath --relative-to="$ORCHROOT" "$F") + + if [[ $RES -eq 0 ]] ; then + echo "ok $TN - Compile $RR" + else + echo "not ok $TN - Compile $RR" + if [[ $ABORT_ON_ERROR -eq 1 ]] ; then + exit 1 + fi + fi + + TN=$((TN+1)) +} + +function test_compile_failure { + F="$1" + $HERE/compile_app.exp $F > /dev/null + RES=$? + + RR=$(realpath --relative-to="$ORCHROOT" "$F") + + if [[ $RES -ne 0 ]] ; then + echo "ok $TN - Should fail to compile $RR" + else + echo "not ok $TN - Should fail to compile $RR" + fi + + TN=$((TN+1)) +} + +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/apps/*.xml ; do + if [[ "$i" == */apsp_vec_barrier_150_10.xml ]] ; then + TODO_compile $i "Bug #232 needs to be fixed." + elif [[ "$i" == */betweeness_centrality_16_16_20_20_v4.xml ]] ; then + TODO_compile $i "orchestrator needs indexed sends." + elif [[ "$i" == */example_device_idle.xml ]] ; then + TODO_compile $i "orchestrator needs requestIdle." + else + test_compile_success $i + fi +done +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/tests/valid/*/*.xml ; do + if [[ "$i" == */L4-run-time/external-*.xml ]] ; then + TODO_compile $i "No support for externals." + else + test_compile_success $i + fi +done + +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/*.xml ; do + test_compile_failure $i +done diff --git a/Tests/ReferenceXML/test_parse.sh b/Tests/ReferenceXML/test_parse.sh new file mode 100755 index 00000000..422c4478 --- /dev/null +++ b/Tests/ReferenceXML/test_parse.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +echo "TAP version 13" + +HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +ORCHROOT="$(realpath $HERE/../..)" + +VERBOSE=0 +ABORT_ON_ERROR=0 + +while [[ $# -gt 0 ]] ; do + case $1 in + --verbose) + VERBOSE=1 + shift + ;; + --abort-on-error) + ABORT_ON_ERROR=1 + shift + ;; + *) # unknown option + >&2 "Didnt understand option $1" + exit 1 + ;; + esac +done + +TN=0 + +############################################ +## Pure syntax + +LOAD_PLOG_FILTER='s/^.*for the command '\''load \/app = [^'\'']+'\'' will be written to '\''([^'\'']+)'\''.+$/\1/p' + + +function TODO_parse { + F="$1" + RR=$(realpath --relative-to="$ORCHROOT" "$F") + echo "not ok $TN - # TODO Parse $RR, $2" + TN=$((TN+1)) +} + +function test_parse_success { + F="$1" + if [[ $VERBOSE -eq 1 ]] ; then + OUTPUT=$($HERE/parse_app.exp $F ) + RES=$? + + if [[ $RES -ne 0 ]] ; then + PLOG_LINE=$(echo $OUTPUT | tr -dc '[[:print:]]' | sed -r -n "${LOAD_PLOG_FILTER}" ) + echo "" + echo "#Validation of $F Failed." + echo "# plog is in ${PLOG_LINE}" + echo "" + while read l ; do + echo "# > $l" + done < $ORCHROOT/bin/${PLOG_LINE} + fi + else + $HERE/parse_app.exp $F > /dev/null + RES=$? + fi + + + RR=$(realpath --relative-to="$ORCHROOT" "$F") + + if [[ $RES -eq 0 ]] ; then + echo "ok $TN - Parse $RR" + else + echo "not ok $TN - Parse $RR" + if [[ ${ABORT_ON_ERROR} -eq 1 ]] ; then + exit 1; + fi + fi + + TN=$((TN+1)) +} + +function test_parse_failure { + F="$1" + $HERE/parse_app.exp $F > /dev/null + RES=$? + + RR=$(realpath --relative-to="$ORCHROOT" "$F") + + if [[ $RES -ne 0 ]] ; then + echo "ok $TN - Should fail to parse $RR" + else + echo "not ok $TN - Should fail to parse $RR" + fi + + TN=$((TN+1)) +} + +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/apps/*.xml ; do + if [[ "$i" == *betweeness_centrality_16_16_20_20_v4.xml ]] ; then + TODO_parse $i "orchestrator needs indexed sends." + else + test_parse_success $i + fi +done +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/tests/valid/*/*.xml ; do + test_parse_success $i +done + +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/*.xml ; do + test_parse_failure $i +done + +for i in $ORCHROOT/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/*.xml ; do + test_parse_failure $i +done diff --git a/Tests/ReferenceXML/test_run.sh b/Tests/ReferenceXML/test_run.sh new file mode 100755 index 00000000..87a0e71b --- /dev/null +++ b/Tests/ReferenceXML/test_run.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +echo "TAP version 13" + +HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +ORCHROOT="$(realpath $HERE/../..)" + +VERBOSE=0 +ABORT_ON_ERROR=0 + +while [[ $# -gt 0 ]] ; do + case $1 in + --verbose) + VERBOSE=1 + shift + ;; + --abort-on-error) + ABORT_ON_ERROR=1 + shift + ;; + *) # unknown option + >&2 "Didnt understand option $1" + exit 1 + ;; + esac +done + +TN=0 + +function TODO_run { + F="$1" + RR=$(realpath --relative-to="$ORCHROOT" "$F") + echo "not ok $TN - # TODO Run $RR, $2" + TN=$((TN+1)) +} + +############################################ +## Compilation + +PLOG_FILTER='s/^.*will be written to '\''([^'\'']+[.]plog)'\''.+$/\1/p' + +function test_run_success { + local TRIES + local RES + local OUTPUT + local TIMEOUT + TRIES=0 + TIMEOUT=1 + + while [[ $TRIES -lt 5 ]] ; do + + F="$1" + OUTPUT=$($HERE/run_app_standard_outputs.exp $F ) + RES=$? + + if [[ $RES -ne 0 ]] ; then + if [[ "$OUTPUT" == *"Can't connect to "* ]] ; then + echo "# HostLink locked. Sleeping $TIMEOUT seconds" + sleep ${TIMEOUT} + TIMEOUT=$((TIMEOUT+2)) + TRIES=$((TRIES+1)) + continue + else + break + fi + else + break + fi + done + + + RR=$(realpath --relative-to="$ORCHROOT" "$F") + + if [[ $RES -eq 0 ]] ; then + echo "ok $TN - Run $RR" + else + PLOG_LINE=$(echo $OUTPUT | tr -dc '[[:print:]]' | sed -r -n "${PLOG_FILTER}" ) + + if [[ $VERBOSE -ne 0 ]] ; then + echo "" + echo "#Execution of $F Failed." + echo "$OUTPUT" | while read l ; do + echo "# > $l" + done + #echo "# plog is in ${PLOG_LINE}" + #echo "" + # while read l ; do + # echo "# > $l" + #done < $ORCHROOT/bin/${PLOG_LINE} + fi + + echo "not ok $TN - Run $RR" + if [[ $ABORT_ON_ERROR -eq 1 ]] ; then + exit 1 + fi + fi + + TN=$((TN+1)) +} + +test_run_success "${HERE}/v4/PEP20/tests/valid/L4-run-time/single-device-print-hello-in-init.xml" + +test_run_success "${HERE}/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-recv.xml" +test_run_success "${HERE}/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-send.xml" +test_run_success "${HERE}/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once-no-edge--succeed-send.xml" + +test_run_success "${HERE}/v4/PEP20/apps/amg_poisson_8_8_v4.xml" +test_run_success "${HERE}/v4/PEP20/apps/gals_heat_8x8_v4.xml" +test_run_success "${HERE}/v4/PEP20/apps/relaxation_heat_16x16_v4.xml" +test_run_success "${HERE}/v4/PEP20/apps/storm_16_4_8_v4.xml" \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/apps/amg_poisson_8_8_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/amg_poisson_8_8_v4.xml new file mode 100644 index 00000000..a756cc53 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/amg_poisson_8_8_v4.xml @@ -0,0 +1,1867 @@ + + + + + + #include + + #ifdef POETS_LEGACY_HAS_HANDLER_EXIT + #define _do_handler_exit(code) handler_exit(code) + #else + #define _do_handler_exit(code) ((void)0) + #endif + + #define fake_handler_exit(code) \ + { \ + if((code)==0){ \ + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); \ + }else{ \ + handler_log(0, "_HANDLER_EXIT_FAIL_9be65737_"); \ + } \ + _do_handler_exit(code); \ + } + + // Temporary hack + #define verbose_handler_log(...) (void)0 + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fineSeen < deviceProperties->fineTotal); + deviceState->fineSeen++; + deviceState->fineAcc += edgeProperties->R*message->b; + deviceState->fineMaxResidual = std::max(deviceState->fineMaxResidual, message->max_r); + verbose_handler_log(3, "maxMaxResidual=%g", deviceState->fineMaxResidual); + ]]> + + + fineSeen == deviceProperties->fineTotal); + + message->x = deviceState->fineAcc * deviceProperties->inv_Adiag; + message->max_r = deviceState->fineMaxResidual; + verbose_handler_log(3, "msg.maxMaxResidual=%g", deviceState->fineMaxResidual); + + deviceState->fineSeen=0; + deviceState->fineAcc=0; + deviceState->fineMaxResidual=0; + ]]> + + fineSeen == deviceProperties->fineTotal ? RTS_FLAG_fine_down : 0; + //verbose_handler_log(2, "root RTS : 0x%x", *readyToSend); + ]]> + + + + + + + + State_PreSmooth + + State_PreSmooth, // Doing the first smoothing step + // [preSmoothSeen==peerCount] : send/peer_out -> State_Pre + + State_PreResidual, // Exchange for residual + // [preResidSeen==peerCount] : send/peer_out -> State_Pre + + State_Coarse, // Waiting till we get a message back from coarse + // [coarseSeen==coarseCount] : send/peer_out -> State_PostSmooth + + State_PostSmooth // Doing final smoothing before returning + // [postSmoothSeen==peerCount] : send/coarse_down -> State_Idle + }; + + ]]> + + + + state==State_Idle); + assert(deviceState->fineSeen < deviceProperties->fineCount); + + deviceState->fineSeen++; // Might enable send on peer_out + deviceState->fineAcc+=edgeProperties->R * message->b; + deviceState->fineMaxResidual=std::max(deviceState->fineMaxResidual, message->max_r); + + verbose_handler_log(4, "fineSeen=%d, fineAcc=%f", deviceState->fineSeen, deviceState->fineAcc); + ]]> + + + + + tag){ + case State_PreSmooth: + assert(deviceState->preSmoothSeen < deviceProperties->peerCount); + deviceState->preSmoothSeen++; + deviceState->preSmoothAcc+=message->x * edgeProperties->A; + break; + case State_PreResidual: + assert(deviceState->preResidualSeen < deviceProperties->peerCount); + deviceState->preResidualSeen++; + deviceState->preResidualAcc+=message->x * edgeProperties->A; + break; + case State_PostSmooth: + assert(deviceState->postSmoothSeen < deviceProperties->peerCount); + deviceState->postSmoothSeen++; + deviceState->postSmoothAcc+=message->x * edgeProperties->A; + break; + default: + assert(0); + break; + } + ]]> + + + + + state == State_Coarse); + assert(deviceState->coarseSeen < deviceProperties->coarseCount); + + // We should receive exactly the same max_r from _all_ coarse nodes, as it all comes from one root. + assert(deviceState->max_r == -1 || deviceState->max_r==message->max_r); + + deviceState->coarseSeen++; // This may enable sending on fine_down + deviceState->coarseAcc += edgeProperties->P * message->x; + deviceState->max_r = message->max_r; + + verbose_handler_log(4, "coarseSeen=%d", deviceState->coarseSeen); + ]]> + + + state==State_Idle){ + assert(deviceState->fineSeen == deviceProperties->fineCount); + + deviceState->x=0; + deviceState->b=deviceState->fineAcc; + deviceState->fineSeen=0; + deviceState->fineAcc=0; + + message->x=deviceState->x; + message->tag=State_PreSmooth; + + deviceState->state=State_PreSmooth; + verbose_handler_log(2, "Idle->Pre"); + }else if(deviceState->state==State_PreSmooth){ + assert(deviceState->preSmoothSeen==deviceProperties->peerCount); + + float dx =(deviceState->b - deviceState->preSmoothAcc) * deviceProperties->AdInvOmega + - deviceProperties->omega * deviceState->x; + + deviceState->x += dx; // We are only smoothing here, residual will be done on send/coarse_down or send/coarse_up + deviceState->preSmoothSeen=0; + deviceState->preSmoothAcc=0; + + message->x=deviceState->x; + message->tag=State_PreResidual; + + deviceState->state=State_PreResidual; + verbose_handler_log(2, "PreSmooth->PreResidual"); + }else if(deviceState->state==State_Coarse){ + assert(deviceState->coarseSeen == deviceProperties->coarseCount); + + deviceState->x += deviceState->coarseAcc; + deviceState->coarseSeen=0; + deviceState->coarseAcc=0; + + message->x=deviceState->x; + message->tag=State_PostSmooth; + + verbose_handler_log(4, "Coarse->PostSmooth"); + deviceState->state=State_PostSmooth; + }else{ + assert(0); + } + ]]> + + + state==State_PreResidual); + assert(deviceState->preResidualSeen==deviceProperties->peerCount); + + float r = deviceState->b - deviceState->preResidualAcc - deviceProperties->Ad * deviceState->x; + + message->b = r; // local residual to solve + message->max_r = deviceState->fineMaxResidual; // This is propagating the worst from any point on the grid + + deviceState->fineMaxResidual=0; + deviceState->preResidualSeen=0; + deviceState->preResidualAcc=0; + + deviceState->max_r = -1; + deviceState->state=State_Coarse; + + verbose_handler_log(4, "PreResidual->Coarse"); + ]]> + + + state==State_PostSmooth); + assert(deviceState->postSmoothSeen==deviceProperties->peerCount); + + float dx =(deviceState->b - deviceState->postSmoothAcc) * deviceProperties->AdInvOmega + - deviceProperties->omega * deviceState->x; + + deviceState->x += dx; + deviceState->postSmoothSeen=0; + deviceState->postSmoothAcc=0; + deviceState->state=State_Idle; + verbose_handler_log(4, "Post->Idle"); + + message->x = deviceState->x; + message->max_r = deviceState->max_r; + ]]> + + state){ + case State_Idle: + if(deviceState->fineSeen==deviceProperties->fineCount){ + *readyToSend |= RTS_FLAG_peer_out; + } + break; + case State_PreSmooth: + if(deviceState->preSmoothSeen==deviceProperties->peerCount){ + *readyToSend |= RTS_FLAG_peer_out; // exchange for the residual + } + break; + case State_PreResidual: + if(deviceState->preResidualSeen==deviceProperties->peerCount){ + *readyToSend |= RTS_FLAG_coarse_up; // send to the coarse refinement + } + break; + case State_Coarse: + if(deviceState->coarseSeen==deviceProperties->coarseCount){ + *readyToSend |= RTS_FLAG_peer_out; // exchange for final smooth + } + break; + case State_PostSmooth: + if(deviceState->postSmoothSeen==deviceProperties->peerCount){ + *readyToSend |= RTS_FLAG_fine_down; // Seen it back down tree + } + break; + default: + assert(0); + break; + } + ]]> + + + + + + + + residualTolerance] : send/peer_out -> State_PreSmooth + + State_PreSmooth, // Doing the first smoothing step + // [preSmoothSeen==peerCount] : send/peer_out -> State_Pre + + State_PreResidual, // Exchange for residual + // [preResidualSeen==peerCount] : send/peer_out -> State_Pre + + State_Coarse, // Waiting till we get a message back from coarse + // [coarseSeen==coarseCount ^ r <= residualTolerance] : send/fine_down -> State_Idle + // [coarseSeen==coarseCount ^ r > residualTolerance] : send/peer_out -> State_PreSmooth + + }; + + ]]> + + + + state==State_Idle); + assert(deviceState->r ==0 ); // Must have finished the previous problem... + + deviceState->b = message->b; + deviceState->x = message->x; + deviceState->r = FLT_MAX; // This will trigger RTS for peer_out + ]]> + + + + + tag){ + case State_PreSmooth: + assert(deviceState->preSmoothSeen < deviceProperties->peerCount); + deviceState->preSmoothSeen++; + deviceState->preSmoothAcc+=message->x * edgeProperties->A; + break; + case State_PreResidual: + assert(deviceState->preResidualSeen < deviceProperties->peerCount); + deviceState->preResidualSeen++; + deviceState->preResidualAcc+=message->x * edgeProperties->A; + break; + default: + assert(0); + break; + } + ]]> + + + + + state == State_Coarse); + assert(deviceState->coarseSeen < deviceProperties->coarseCount); + + // We should receive exactly the same max_r from _all_ coarse nodes, as it all comes from one root. + assert(deviceState->r == FLT_MAX || deviceState->r==message->max_r); + + deviceState->coarseSeen++; // This may enable sending on either peer_out, or solution + deviceState->coarseAcc += edgeProperties->P * message->x; + deviceState->r = message->max_r; + ]]> + + + state==State_Idle){ + assert(deviceState->r >= graphProperties->residualTol); + + message->x=deviceState->x; + message->tag=State_PreSmooth; + + deviceState->state=State_PreSmooth; + verbose_handler_log(4, "Idle->Pre"); + }else if(deviceState->state==State_PreSmooth){ + assert(deviceState->preSmoothSeen==deviceProperties->peerCount); + + float dx =(deviceState->b - deviceState->preSmoothAcc) * deviceProperties->AdInvOmega + - deviceProperties->omega * deviceState->x; + + deviceState->x += dx; // We are only smoothing here, residual will be done on send/coarse_down or send/coarse_up + deviceState->preSmoothSeen=0; + deviceState->preSmoothAcc=0; + + message->x=deviceState->x; + message->tag=State_PreResidual; + + deviceState->state=State_PreResidual; + verbose_handler_log(4, "PreSmooth->PreResidual"); + }else if(deviceState->state==State_Coarse){ + assert(deviceState->coarseSeen == deviceProperties->coarseCount); + assert(deviceState->r > graphProperties->residualTol); // Otherwise we would be sending the solution down + + deviceState->x += deviceState->coarseAcc; + deviceState->coarseSeen=0; + deviceState->coarseAcc=0; + + message->x=deviceState->x; + message->tag=State_PreSmooth; + + verbose_handler_log(4, "Coarse->PreSmooth"); + deviceState->state=State_PreSmooth; + }else{ + assert(0); + } + ]]> + + + state==State_PreResidual); + assert(deviceState->preResidualSeen ==deviceProperties->peerCount); + + float r = deviceState->b - deviceState->preResidualAcc - deviceProperties->Ad * deviceState->x; + + message->b = r; + message->max_r = std::abs(r) ; + + deviceState->preResidualSeen=0; + deviceState->preResidualAcc=0; + deviceState->r = FLT_MAX; + deviceState->state=State_Coarse; + ]]> + + + state==State_Coarse); + assert(deviceState->coarseSeen==deviceProperties->coarseCount); + assert(deviceState->r <= graphProperties->residualTol); // We must have found a solution + + // Note that we _don't_ add the coarseCorrection, as we might make the residual worse + // So we return the x for which we have calculated the worst residual + message->x = deviceState->x; + message->r = deviceState->r; + + deviceState->coarseSeen=0; + deviceState->coarseAcc=0; + deviceState->r=0; + deviceState->state=State_Idle; + ]]> + + state){ + case State_Idle: + if(deviceState->r > graphProperties->residualTol){ + *readyToSend |= RTS_FLAG_peer_out; + } + break; + case State_PreSmooth: + if(deviceState->preSmoothSeen==deviceProperties->peerCount){ + *readyToSend |= RTS_FLAG_peer_out; + } + break; + case State_PreResidual: + if(deviceState->preResidualSeen==deviceProperties->peerCount){ + *readyToSend |= RTS_FLAG_coarse_up; + } + break; + case State_Coarse: + if(deviceState->coarseSeen==deviceProperties->coarseCount){ + if(deviceState->r <= graphProperties->residualTol){ + *readyToSend |= RTS_FLAG_solution; + }else{ + *readyToSend |= RTS_FLAG_peer_out; + } + } + break; + default: + assert(0); + break; + } + verbose_handler_log(3, "state=%d, coarseSeen=%d, coarseCount=%d", deviceState->state, deviceState->coarseSeen, deviceProperties->coarseCount); + ]]> + + + + + + + + + + + + i& 1)==1); + assert(deviceState->i<16); + + auto rx=deviceProperties->x[deviceState->i/2]; + + auto x = message->x; + auto r = message->r; + auto i = message->i; + + assert( (r>=0) && (rresidualTol) ); + + verbose_handler_log(3, " iter=%d, x=%g (dx=%g), r=%g, i=%d\n\n\n", deviceState->i/2, x, std::abs(x-rx), r, i); + + deviceState->i++; + ]]> + + + i==16); + // No payload + deviceState->i++; + ]]> + + + i& 1)==0); + assert(deviceState->i<16); + + message->x = 5; + message->b = deviceProperties->b[deviceState->i]; + deviceState->i++; + ]]> + + i < 16) && (0==(deviceState->i& 1)) ){ + *readyToSend=RTS_FLAG_problem; + }else if(deviceState->i == 16){ + *readyToSend=RTS_FLAG_finished; + } + //verbose_handler_log(2, "test RTS : 0x%x", *readyToSend); + ]]> + + + + + + + + + + + + seen++; + if(deviceState->seen==deviceProperties->nodes){ + fake_handler_exit(0); + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/apsp_100_10_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/apsp_100_10_v4.xml new file mode 100644 index 00000000..757d7170 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/apsp_100_10_v4.xml @@ -0,0 +1,1853 @@ + + + + + + + #ifdef POETS_LEGACY_HAS_HANDLER_EXIT + #define _do_handler_exit(code) handler_exit(code) + #else + #define _do_handler_exit(code) ((void)0) + #endif + + #define fake_handler_exit(code) \ + { \ + if((code)==0){ \ + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); \ + }else{ \ + handler_log(0, "_HANDLER_EXIT_FAIL_9be65737_"); \ + } \ + _do_handler_exit(code); \ + } + +]]> + + + + + + + + + + + + + + + + + + + + requestValid, deviceState->round, message->round, message->isNewRound); + assert(!deviceState->requestValid); + assert(deviceState->responseSeen==0); + deviceState->requestValid=1; + deviceState->requestRound=message->round; + deviceState->requestIsNewRound=message->isNewRound; + if(message->isNewRound){ + deviceState->round=message->round; + }else{ + assert(deviceState->round==message->round); + } + ]]> + + + + + responseSeen, deviceProperties->degree); + assert(!deviceState->requestValid); + assert(deviceState->responseSeendegree); + assert(message->round==deviceState->round); + deviceState->responseSeen++; + deviceState->responseSentCount += message->sent; + deviceState->responseReceivedCount += message->received; + deviceState->responseSumDistance += message->sumDist; + deviceState->responseMaxDistance = std::max(deviceState->responseMaxDistance, message->maxDist); + ]]> + + + requestValid && deviceState->responseSeen==0); + deviceState->requestValid=0; + message->round=deviceState->requestRound; + message->isNewRound=deviceState->requestIsNewRound; + ]]> + + + requestValid && deviceState->responseSeen==deviceProperties->degree); + deviceState->responseSeen=0; + message->sent = deviceState->responseSentCount; + message->received = deviceState->responseReceivedCount; + message->sumDist = deviceState->responseSumDistance; + message->maxDist = deviceState->responseMaxDistance; + message->round = deviceState->round; + deviceState->responseSentCount=0; + deviceState->responseReceivedCount=0; + deviceState->responseSumDistance=0; + deviceState->responseMaxDistance=0; + ]]> + + requestValid){ + assert(deviceState->responseSeen==0); + *readyToSend = RTS_FLAG_request_out; + }else if(deviceState->responseSeen==deviceProperties->degree){ + *readyToSend = RTS_FLAG_response_out; + }else{ + *readyToSend = 0; + } + ]]> + + + + + + + + + + + + controlPending); + deviceState->controlPending=1; + if(deviceState->round != message->round){ + deviceState->sentCount=0; + deviceState->receivedCount=0; + deviceState->round=message->round; + deviceState->dist=0xFFFFFFFFul; + if(deviceProperties->index == deviceState->round){ + deviceState->dist=0; + deviceState->distDirty=1; + } + handler_log(2, "New round=%u", message->round); + } + ]]> + + + + + distance, message->round); + if(message->round!=deviceState->round){ + deviceState->round=message->round; + deviceState->dist=0xFFFFFFFFul; + deviceState->sentCount=0; + deviceState->receivedCount=0; + handler_log(2, "New round=%u", message->round); + } + auto newDist=message->distance + edgeProperties->w; + if(newDist < deviceState->dist){ + deviceState->dist = newDist; + deviceState->distDirty = true; + handler_log(2, "New dist=%u, ew=%u", deviceState->dist, edgeProperties->w); + } + deviceState->receivedCount++; + ]]> + + + controlPending && !deviceState->distDirty); + deviceState->controlPending=0; + message->sent = deviceState->sentCount; + message->received = deviceState->receivedCount; + message->sumDist = deviceState->dist; + message->maxDist = deviceState->dist; + message->round = deviceState->round; + ]]> + + + distDirty); + + message->round = deviceState->round; + message->distance = deviceState->dist; + + deviceState->distDirty = 0; + deviceState->sentCount += deviceProperties->degree; + ]]> + + distDirty){ + *readyToSend = RTS_FLAG_dout; + }else if(deviceState->controlPending){ + *readyToSend = RTS_FLAG_response_out; + }else{ + *readyToSend = 0; + } + ]]> + round=0xFFFFFFFFul; + ]]> + + + + + + + + + + + controlPending); + + handler_log(2, "Round %u : sendCount=%u, recvCount=%u, messageRound=%u", deviceState->round, message->sent, message->received, message->round); + + assert(deviceState->round==message->round); + + deviceState->controlPending=1; + + if(deviceState->roundBegin){ + // Always need to go round twice + deviceState->roundBegin=false; + }else{ + if(message->sent==message->received && message->sent==deviceState->prevSentCount && message->received==deviceState->prevReceivedCount){ + deviceState->sumMaxDist += message->maxDist; + deviceState->sumSumDist += message->sumDist; + + deviceState->round++; + deviceState->roundBegin=1; + + if(deviceState->round==deviceProperties->node_count){ + handler_log(1, "refSumSumDist=%d, gotSumSumDist=%d", deviceProperties->refSumSumDist, deviceState->sumSumDist); + handler_log(1, "refSumMaxDist=%d, gotSumMaxDist=%d", deviceProperties->refSumMaxDist, deviceState->sumMaxDist); + deviceState->controlPending=0; + auto ok=deviceState->sumSumDist==deviceProperties->refSumSumDist || deviceProperties->refSumSumDist==0; + ok = ok && (deviceState->sumMaxDist==deviceProperties->refSumMaxDist || deviceProperties->refSumMaxDist==0); + + fake_handler_exit(ok?0:1); + } + } + } + deviceState->prevSentCount=message->sent; + deviceState->prevReceivedCount=message->received; + ]]> + + + controlPending); + deviceState->controlPending=0; + message->round=deviceState->round; + message->isNewRound = deviceState->roundBegin; + ]]> + + controlPending){ + *readyToSend = RTS_FLAG_request_out; + }else{ + *readyToSend = 0; + } + ]]> + round=0; + deviceState->roundBegin=1; + deviceState->controlPending=1; + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml b/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml new file mode 100644 index 00000000..e742d7dc --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml @@ -0,0 +1,2059 @@ + + + + + + #include + #include + #include + + const unsigned K_MSG=sizeof(std::declval().distances) / sizeof(std::declval().distances[0]); + const unsigned K_STATE=sizeof(std::declval().distances) / sizeof(std::declval().distances[0]); + static_assert(K_MSG==K_STATE, "Size of message and state arrays has drifted."); + const unsigned K=K_MSG; + + const unsigned num_debug_1st_round_distances = sizeof(std::declval().debug_1st_round_distances) / sizeof(std::declval().debug_1st_round_distances[0]); + const unsigned num_debug_2nd_round_distances = sizeof(std::declval().debug_2nd_round_distances) / sizeof(std::declval().debug_2nd_round_distances[0]); + + + #ifdef POETS_LEGACY_HAS_HANDLER_EXIT + #define _do_handler_exit(code) handler_exit(code) + #else + #define _do_handler_exit(code) ((void)0) + #endif + + #define fake_handler_exit(code) \ + { \ + if((code)==0){ \ + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); \ + }else{ \ + handler_log(0, "_HANDLER_EXIT_FAIL_9be65737_"); \ + } \ + _do_handler_exit(code); \ + } + +]]> + + + + + + + + + + + + + + void begin_round(const GP * graphProperties, const DP *deviceProperties, DS *deviceState) + { + // Start the next round + memset(deviceState->distances, 0xFF, sizeof(deviceState->distances)); + + // Check if we are a source for the next round + int32_t id_delta=deviceProperties->id - deviceState->round_base; + if(0 <= id_delta && id_delta < K){ + deviceState->distances_dirty=true; + deviceState->distances[id_delta]=0; // Distance 0 from ourself + } + // Sometimes we need to be precise about exactly how many vertices are in this batch, + // but most of the time it is _slightly_ more efficient to use K (instruction count + memory accesses + reg pressure). + // There is only one round where curr_k < K, versus floor(n/K) where curr_k==K. Ignored for now. + deviceState->curr_k=std::min(K, graphProperties->total_vertices-deviceState->round_base); + assert(deviceState->curr_k <= K); + + deviceState->round_base += K; + } + ]]> + + + + w; + for(unsigned i=0; i < deviceState->curr_k; i++){ + auto peerDist=message->distances[i]; + if(peerDist!=UINT_MAX){ + auto newDist= peerDist + weight; + if(newDist < deviceState->distances[i]){ + handler_log(3, " new distance for %u <- %u : %u (prev %u), came from %u", deviceProperties->id, deviceState->round_base-K+i, newDist, deviceState->distances[i], message->source); + deviceState->distances[i] = newDist; + deviceState->distances_dirty=1; + } + } + } + handler_log(2, "stats_dirty=%u, distances_dirty=%u", deviceState->stats_dirty, deviceState->distances_dirty); + ]]> + + + curr_k; i++){ + handler_log(3, " distance for %u <- %u : %u", deviceProperties->id, deviceState->round_base-K+i, deviceState->distances[i]); + } + + memcpy(message->distances, deviceState->distances, sizeof(deviceState->distances)); + deviceState->distances_dirty=false; + message->source=deviceProperties->id; + handler_log(2, "stats_dirty=%u, distances_dirty=%u", deviceState->stats_dirty, deviceState->distances_dirty); + ]]> + + + stats_k; i++){ + sum_sum_distance += deviceState->stats_distances[i]; + } + message->sum_sum_distance=sum_sum_distance; + message->vertex_count=1; + memcpy(message->max_distances, deviceState->stats_distances, sizeof(deviceState->stats_distances)); + deviceState->stats_dirty=false; + + handler_log(2, "stats_dirty=%u, distances_dirty=%u, sum_sum_distance=%u", deviceState->stats_dirty, deviceState->distances_dirty, (uint32_t)sum_sum_distance); + ]]> + + distances_dirty){ // Share distances in preference to stats + *readyToSend = RTS_FLAG_share_out; + }else if(deviceState->stats_dirty){ + *readyToSend = RTS_FLAG_stats_out; + } + ]]> + + curr_k; i++){ + unsigned src=i+deviceState->round_base-K; + if( (src < num_debug_1st_round_distances) && (deviceState->round_base==K) ){ + handler_log(4, " distance %u <- %u = %u expected %u", deviceProperties->id, src, deviceState->distances[i], deviceProperties->debug_1st_round_distances[i]); + }else if( (src < num_debug_2nd_round_distances) && (deviceState->round_base==2*K) ){ + handler_log(4, " distance %u <- %u = %u expected %u", deviceProperties->id, src, deviceState->distances[i], deviceProperties->debug_2nd_round_distances[i]); + }else{ + handler_log(4, " distance %u <- %u = %u", deviceProperties->id, src, deviceState->distances[i]); + } + } + #endif + deviceState->stats_k=deviceState->curr_k; + // Capture stats for the previous round + memcpy(deviceState->stats_distances, deviceState->distances, sizeof(deviceState->distances)); + deviceState->stats_dirty=1; + + // This is safe to call after the last round. No-one will initiate any sharing. + begin_round(graphProperties, deviceProperties, deviceState); + ]]> + + + + + + + + + + max_distances[i] = std::max(deviceState->max_distances[i], message->max_distances[i]); + } + deviceState->vertex_count+=message->vertex_count; + deviceState->sum_sum_distance+=message->sum_sum_distance; + ]]> + + + + + vertex_count == deviceProperties->vertex_cone_size){ + *readyToSend = RTS_FLAG_reduce_out; + } + ]]> + + vertex_count==0); // We should have moved stats before the barrier + ]]> + + + + + + + + + + sum_sum_distances += message->sum_sum_distance; + assert(deviceState->round_base < graphProperties->total_vertices); + unsigned curr_k = std::min(K, graphProperties->total_vertices - deviceState->round_base); + assert(curr_k <= K); + for(unsigned i=0; imax_distances[i] = std::max(deviceState->max_distances[i], message->max_distances[i]); + } + deviceState->vertex_count += message->vertex_count; + handler_log(2, "vertex_count = %u", deviceState->vertex_count); + ]]> + + round_base < graphProperties->total_vertices); + *readyToSend=0; + ]]> + gen_k==K); + assert(deviceState->round_base < graphProperties->total_vertices); + ]]> + vertex_count==0){ + // Do nothing - very first round, with no stats + assert(deviceState->round_base==0); + }else{ + + assert(deviceState->vertex_count == graphProperties->total_vertices); + assert(deviceState->round_base < graphProperties->total_vertices); + + unsigned curr_k = std::min(K, graphProperties->total_vertices - deviceState->round_base); + assert(curr_k <= K); + for(unsigned i=0; isum_max_distances += deviceState->max_distances[i]; + } + memset(deviceState->max_distances, 0, sizeof(deviceState->max_distances)); + + handler_log(0, "round_base=%u, sum_sum_distance_hi=%08x:%08x, sum_max_length_hi=%08x:%08x", deviceState->round_base, uint32_t(deviceState->sum_sum_distances>>32), uint32_t(deviceState->sum_sum_distances), uint32_t(deviceState->sum_max_distances>>32), uint32_t(deviceState->sum_max_distances)); + + deviceState->round_base += K; + deviceState->vertex_count=0; + + if(deviceState->round_base >= graphProperties->total_vertices){ + if(deviceProperties->refSumMaxDist!=0){ + if(deviceProperties->refSumMaxDist != deviceState->sum_max_distances){ + handler_log(0, " ref sum max = %u, got = %u", (uint32_t)deviceProperties->refSumMaxDist, (uint32_t)deviceState->sum_max_distances); + fake_handler_exit(1); + } + if(deviceProperties->refSumSumDist != deviceState->sum_sum_distances){ + handler_log(0, " ref sum sum = %u, got = %u", (uint32_t)deviceProperties->refSumSumDist, (uint32_t)deviceState->sum_sum_distances); + fake_handler_exit(1); + } + } + fake_handler_exit(0); + } + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/betweeness_centrality_16_16_20_20_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/betweeness_centrality_16_16_20_20_v4.xml new file mode 100644 index 00000000..c5e2d042 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/betweeness_centrality_16_16_20_20_v4.xml @@ -0,0 +1,611 @@ + + + + + + >=16; } + if(!(x& 0xFF)){ res+=8; x>>=8; } + if(!(x& 0xF)){ res+=4; x>>=4; } + if(!(x& 0x3)){ res+=2; x>>=2; } + if(!(x& 0x1)){ res+=1; x>>=1; } + assert( ox&(1u<>(i%32))&1) ); + } + for(unsigned i=max; i<1024; i++){ + assert(c2[i]==0); + } + for(unsigned i=0; i<32; i++){ + assert( !(l0& (1u<0); + assert(l1[sel/32] & (1u<<(sel%32))); + assert(l0 & (1u<<(sel/32))); + + uint32_t nc= --c2[sel]; + if(nc){ + return; + } + uint32_t m1= (l1[sel/32] &= ~(1u<<(sel%32))); + if(m1){ + return; + } + l0 &= ~(1u<<(sel/32)); + } + + unsigned remove_all_ready_1k( + uint32_t &l0, // Single 32-bit mask + uint32_t l1[32], // Array of 32 bit-masks + uint32_t c2[1024], // Array of 1024 counters + unsigned sel + ){ + assert(c2[sel]>0); + assert(l1[sel/32] & (1u<<(sel%32))); + assert(l0 & (1u<<(sel/32))); + + unsigned pc=c2[sel]; + c2[sel]=0; + + uint32_t m1= (l1[sel/32] &= ~(1u<<(sel%32))); + if(!m1){ + l0 &= ~(1u<<(sel/32)); + } + + return pc; + } + + unsigned find_and_remove_ready_1k( + uint32_t &l0, + uint32_t l1[32], + uint32_t c2[1024] + ){ + assert(l0); + unsigned s0=pick_bit(l0); + uint32_t m1=l1[s0]; + assert(m1); + unsigned sel=(s0<<5)|pick_bit(m1); + assert(c2[sel]>0); + + auto nc = --c2[sel]; + if(!nc){ + m1 &= ~(1u<<(sel%32)); + l1[sel/32]=m1; + if(!m1){ + l0 &= ~(1u<<(sel/32)); + } + } + + return sel; + } + + void add_ready_1k( + uint32_t &l0, + uint32_t l1[32], + uint32_t c2[1024], + unsigned sel, + unsigned count=1 + ){ + assert(sel<1024); + assert(count>0); + + uint32_t pc=c2[sel]; + c2[sel]+=count; + if(pc){ + return; + } + uint32_t m1 = (l1[sel/32] |= (1u<<(sel%32))); + // Might as well do it unconditionally, probably saves both time and instruction space + l0 |= (1u<<(sel/32)); + } + + #ifdef POETS_LEGACY_HAS_HANDLER_EXIT + #define _do_handler_exit(code) handler_exit(code) + #else + #define _do_handler_exit(code) ((void)0) + #endif + + #define fake_handler_exit(code) \ + { \ + if((code)==0){ \ + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); \ + }else{ \ + handler_log(0, "_HANDLER_EXIT_FAIL_9be65737_"); \ + } \ + _do_handler_exit(code); \ + } +]]> + + + + + + + + + + + + + + + + + timestep <= graphProperties->max_steps); + assert_ready_1k_invariants(deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + + assert(message->count > 0); + deviceState->total_visits += message->count; + + add_ready_1k( + deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, + message->timestep, message->count + ); + if(message->timestep < graphProperties->max_steps){ + deviceState->non_final_count += message->count; + } + + handler_log(3, "Received %u at time %u, nonFinalCount=%u", message->count, message->timestep, deviceState->non_final_count); + + assert_ready_1k_invariants(deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + ]]> + + + walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + + // Always succeeds (unless program is corrupt) + unsigned sel=find_and_remove_ready_1k( + deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep + ); + // If we had sel == graphProperties->max_steps we shouldn't be in this handler + assert(sel < graphProperties->max_steps); + + message->count=1; + message->timestep=sel+1; + do{ + deviceState->seed=deviceState->seed*1664525+1013904223ul; + *sendIndex = (deviceState->seed) >> (deviceState->degree_shift); + }while(*sendIndex >= deviceProperties->degree); + + --deviceState->non_final_count; + + handler_log(3, "Sending %u to time %u, dest=%u, nonFinalCount=%u", message->count, message->timestep, *sendIndex, deviceState->non_final_count); + + assert_ready_1k_invariants(deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + ]]> + + + walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + + unsigned count=remove_all_ready_1k( + deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, + graphProperties->max_steps + ); + assert(count>0); // If there was nothing at max_steps then shouldn't be in this handler + + message->count=count; + message->node_id=deviceProperties->node_id; + message->total_visits=deviceState->total_visits; + + assert_ready_1k_invariants(deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + ]]> + + walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + + *readyToSend = 0; + if(deviceState->walks_mask_l0){ + if(deviceState->non_final_count){ + *readyToSend=RTS_FLAG_walk_continue; + }else{ + *readyToSend=RTS_FLAG_walk_finish; + } + } + ]]> + max_steps < 1024); + + uint32_t bits=1; + uint32_t mask=1; + while(deviceProperties->degree >= mask){ + bits++; + mask=(mask<<1)|1; + } + deviceState->degree_shift=32-bits; + + deviceState->seed=deviceProperties->seed; + + add_ready_1k( + deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, + 0, graphProperties->initial_walks + ); + deviceState->non_final_count+=graphProperties->initial_walks; + + assert_ready_1k_invariants(deviceState->walks_mask_l0, deviceState->walks_mask_l1, deviceState->walks_by_timestep, graphProperties->max_steps+1); + + ]]> + + + + + + + + + + + + collected+=message->count; + deviceState->max_visited=std::max(deviceState->max_visited, message->total_visits); + handler_log(2, "collected=%u, exepect4d=%u", deviceState->collected, deviceState->expected); + + if(deviceState->collected==deviceState->expected){ + handler_log(1, "max_visited=%u", deviceState->max_visited); + fake_handler_exit(0); + } + ]]> + + + expected=graphProperties->initial_walks * deviceProperties->graph_size; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/example_device_idle.xml b/Tests/ReferenceXML/v4/PEP20/apps/example_device_idle.xml new file mode 100644 index 00000000..bec015ae --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/example_device_idle.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + received++; + ]]> + + + sent++; + ]]> + + steps < 10){ + if(deviceState->sent < 10){ + *readyToSend = RTS_FLAG_o1; + } + if(deviceState->computed < 10){ + *requestIdle = true; + } + } + ]]> + + computed, deviceState->sent=10, deviceState->received); + assert(deviceState->computed==10); + assert(deviceState->sent==10); + assert(deviceState->received==10); + deviceState->computed=0; + deviceState->sent=0; + deviceState->received=0; + deviceState->steps++; + if(deviceState->steps==10){ + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); + } + ]]> + computed++; + ]]> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/apps/gals_heat_8x8_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/gals_heat_8x8_v4.xml new file mode 100644 index 00000000..f6709984 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/gals_heat_8x8_v4.xml @@ -0,0 +1,544 @@ + + + + + + + float silly_sin(float x) + { + const float INV_PI_2_MUL_2y16 = 65536 / (2*3.1415926535897932384626433832795); + x = int(x*INV_PI_2_MUL_2y16) / INV_PI_2_MUL_2y16; + return -2.422846250584589825100105800534085795531019374901e-2f + x * (1.0941122488765009056625163448729888074380238696528f + x * (1.6401318768850874493169280698974960214515214625058e-2f + x * (-0.28608843604061000778216710077897260840447261538158f + x * (6.7988688674337874080228799258345331772362960447436e-2f + x * (-4.3385477306031066279973785642212528367555127953896e-3f))))); + } + ]]> + + + + + + + + + + + + + + + + + t, message->v, deviceState->t, deviceState->cs, deviceState->ns); + + if(message->t==deviceState->t){ + deviceState->cs++; + assert(deviceState->cs <= deviceProperties->neighbours); + }else{ + deviceState->ns++; + assert(deviceState->ns <= deviceProperties->neighbours); + assert( + (deviceState->t + 1 == message->t) // Either it is one step ahead + || + (deviceState->t == graphProperties->maxTime+1) // Or we are idle and don't care + ); + } + ]]> + + + t < graphProperties->maxTime); + assert(deviceState->cs==deviceProperties->neighbours); + + deviceState->v=deviceProperties->bias + deviceProperties->amplitude + * silly_sin(deviceProperties->phase + deviceProperties->frequency * deviceState->t); + + deviceState->t = deviceState->t + 1; + deviceState->cs = deviceState->ns; + deviceState->ns = 0; + + message->t = deviceState->t; + message->v = deviceState->v; + ]]> + + + t==graphProperties->maxTime); + deviceState->t++; // We advance beyond the end of time and go idle + // And send an empty pulse to exit node + ]]> + + t < graphProperties->maxTime){ + if(deviceState->cs==deviceProperties->neighbours){ + *readyToSend = RTS_FLAG_out; + } + }else if(deviceState->t == graphProperties->maxTime){ + *readyToSend=RTS_FLAG_finished; + } + ]]> + t=0; + deviceState->cs=deviceProperties->neighbours; + deviceState->ns=0; + + deviceState->v=deviceProperties->bias + deviceProperties->amplitude + * silly_sin(deviceProperties->phase + deviceProperties->frequency * deviceState->t); + ]]> + + + + + + + + + + + + t, message->v, deviceState->t, deviceState->cs, deviceState->ca, deviceState->ns, deviceState->na); + if(message->t==deviceState->t){ + deviceState->ca += edgeProperties->w * message->v; + deviceState->cs++; + }else{ + deviceState->na += edgeProperties->w * message->v; + deviceState->ns++; + + assert( + (deviceState->t + 1 == message->t) // Either it is one step ahead + || + (deviceState->t == graphProperties->maxTime+1) // Or we are idle and don't care + ); + } + ]]> + + + t++; // We advance beyond the end of time and go idle + // And send an empty pulse to exit node + ]]> + + + t, deviceState->cs, deviceState->ca, deviceState->ns, deviceState->na); + + assert(deviceState->cs == deviceProperties->nhood); + + deviceState->t += 1; + deviceState->v=deviceState->ca; + + // TODO : move this out of the send handler into compute + if( (deviceState->t & graphProperties->exportDeltaMask)==0 ){ + //handler_export_key_value(0, 0x800000ul+(uint32_t)(int32_t)(deviceState->v*65536)); + } + + deviceState->ca = deviceProperties->wSelf * deviceState->v + deviceState->na; + deviceState->cs = deviceState->ns; + + deviceState->na=0; + deviceState->ns=0; + + message->t=deviceState->t; + message->v=deviceState->ca; + + // It is possible that all our neighbours are ahead and have broadcast, so + // we could immediately be ready to go. + ]]> + + t < graphProperties->maxTime){ + if(deviceState->cs==deviceProperties->nhood){ + *readyToSend = RTS_FLAG_out; + } + }else if(deviceState->t == graphProperties->maxTime){ + *readyToSend = RTS_FLAG_finished; + } + ]]> + v=0; + deviceState->t=0; + deviceState->ca = deviceProperties->iv; + deviceState->cs = deviceProperties->nhood; + + deviceState->ns=0; + deviceState->na=0; + + handler_log(3, "value = %f", deviceState->v); + ]]> + + + + + + + + + + + + done++; + if(deviceState->done == deviceProperties->fanin){ + fake_handler_exit(0); + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/ising_spin_fix_16_2_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/ising_spin_fix_16_2_v4.xml new file mode 100644 index 00000000..56486e63 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/ising_spin_fix_16_2_v4.xml @@ -0,0 +1,1847 @@ + + + + + =y){ + x-=y; + } + return x; + } + + uint32_t calc_tag(uint32_t x, uint32_t y) + { + return mod(x,3) + mod(y,3)*3; + } + + uint32_t urng(uint32_t *state) + { + (*state) = (*state) *1664525+1013904223; + return (*state); + } + + uint32_t rng_init(uint32_t x, uint32_t y) + { + y=(x<<16)^y; + for(unsigned i=0;i<10;i++){ + y^=(y<<13); y^=(y>>17); (y^=(y<<5)); + } + return y; + } + + // This produces a time which is approximately distributed + // with a sort of exponential-ish distribution + // The maximum value is 2^21-1 + // Expected value is: + // 0.5 * 0x4000 + 0.25 * 0x8000 + 0.125 * 0x10000 + ... + // = sum( 2^(-i-1) * 16384 * 2^i, i=0..5) + 2^-6 * 16384 * 2^6 + // = sum( 16384 * 0.5, i=0..5 ) + 16384 + // = 8192 * 6 + 16384 + // = 2^16 + // + // res= 2.^min(6,floor(-log2(rand(1,n)))) .* (rand(1,n)*32768); + uint32_t erng(uint32_t *state) + { + uint32_t v=urng(state); + uint32_t hi=v>>26; // Top 6 bits + uint32_t lo=(v<<6)>>17; // Following 15 bits. Bottom 11 bits are discarded + + uint32_t shift=6; + if(hi&1){ shift=0; } + else if(hi&2){ shift=1; } + else if(hi&4){ shift=2; } + else if(hi&8){ shift=3; } + else if(hi&16){ shift=4; } + else if(hi&32){ shift=5; } + + uint32_t val=lo<>31) ? +1 : -1; + *time = (erng(seed) << 4) | tag ; + } + + void chooseNextEvent(const uint32_t *probabilities, uint32_t tag, uint32_t *rng, int32_t *spins, uint32_t *times) + { + int sumStates=0; + for(unsigned i=1; i<5; i++){ // Only sum neighbours + sumStates+=spins[i]; + } + + unsigned index=(sumStates+4)/2 + 5*(spins[0]+1)/2; + uint32_t prob=probabilities[index]; + + if( urng(rng) < prob){ + spins[0] *= -1; // Flip + } + times[0] = (((times[0]>>4) + erng(rng)) << 4) | tag; + } + + // + + void get_neighbour_coords(uint32_t x, uint32_t y, uint32_t w, uint32_t h, int dir, uint32_t &nx, uint32_t &ny) + { + nx=x; + ny=y; + if(dir==1){ ny = y==0 ? h-1 : y-1; } + if(dir==2){ nx = x==w-1 ? 0 : x+1; } + if(dir==3){ ny = y==h-1 ? 0 : y+1; } + if(dir==4){ nx = x==0 ? w-1 : x-1; } + } + + +]]> + + + + + + + + + + + + + + + + + + + + isEarliest, + deviceState->times[0], deviceState->times[1], deviceState->times[2], deviceState->times[3], deviceState->times[4]); + ]]> + + + + + time >= deviceState->times[edgeProperties->direction]){ + deviceState->spins[edgeProperties->direction]=message->spin; + deviceState->times[edgeProperties->direction]=message->time; + + get_neighbour_coords(deviceProperties->x, deviceProperties->y, graphProperties->width, graphProperties->height, edgeProperties->direction, nx, ny); + + handler_log(4, "from %d=(%u,%d), new_time = %u, new_spin %d", edgeProperties->direction, nx, ny, message->time, message->spin); + } + + deviceState->isEarliest=1; + + for(unsigned i=1; i<5; i++){ + get_neighbour_coords(deviceProperties->x, deviceProperties->y, graphProperties->width, graphProperties->height, i, nx, ny); + if(deviceState->times[i] < deviceState->times[0]){ + handler_log(4, " time[%d (%u,%u)] = %u < time[0] = %u", i, nx, ny, deviceState->times[i], deviceState->times[0]); + deviceState->isEarliest = 0; + } + } + handler_log(4, "isEarliest = %x, time=%u", deviceState->isEarliest, deviceState->times[0]); + + ]]> + + + times[0]; + int prevSpin=deviceState->spins[0]; + handler_log(3, "256, tag=%u", deviceState->tag); + chooseNextEvent(graphProperties->probabilities, deviceState->tag, &deviceState->rng, deviceState->spins, deviceState->times); + handler_log(3, "258, tag=%u", deviceState->tag); + message->spin = deviceState->spins[0]; + message->time = deviceState->times[0]; + + if(prevSpin != deviceState->spins[0]){ + deviceState->lastFlipTime = prevTime; + } + deviceState->spin=deviceState->spins[0]; + + handler_log(3, "tag=%u, prev_t = %u, next_t = %u, curr_spin = %d", deviceState->tag, prevTime, deviceState->times[0], deviceState->spins[0]); + + deviceState->isEarliest=1; + for(unsigned i=1; i<5; i++){ + get_neighbour_coords(deviceProperties->x, deviceProperties->y, graphProperties->width, graphProperties->height, i, nx, ny); + if(deviceState->times[0] > deviceState->times[i]){ + handler_log(4, " time[%d (%u,%u)] = %u < time[0] = %u", i, nx, ny, deviceState->times[i], deviceState->times[0]); + deviceState->isEarliest = 0; + } + } + handler_log(3, "isEarliest = %x, time=%u, send-finished=%x", deviceState->isEarliest, deviceState->times[0], deviceState->times[0] >= graphProperties->endTime ); + ]]> + + + times[0] = 0xFFFFFFFFul; + handler_log(4, "Finshed"); + ]]> + + times[0] == 0xFFFFFFFFul){ + *readyToSend = 0; + }else if(deviceState->times[0] >= graphProperties->endTime){ + *readyToSend = RTS_FLAG_finished; + }else if(deviceState->isEarliest){ + *readyToSend = RTS_FLAG_out; + }else{ + *readyToSend = 0; + } + ]]> + x, y=deviceProperties->y; + uint32_t W=graphProperties->width, H=graphProperties->height; + + handler_log(3, " x=%u, y=%u", x, y); + + cell_init(x, mod(y+H-1, H), deviceState->spins+1, deviceState->times+1, &seed); + cell_init( mod(x+1,W), y, deviceState->spins+2, deviceState->times+2, &seed); + cell_init(x, mod(y+1,H), deviceState->spins+3, deviceState->times+3, &seed); + cell_init(mod(x+W-1,W), y, deviceState->spins+4, deviceState->times+4, &seed); + + // Final one is this node + cell_init(x, y, deviceState->spins+0, deviceState->times+0, &seed); + deviceState->rng=seed; // Store the rng state back + deviceState->tag=calc_tag(x,y); + handler_log(3, "tag=%u", deviceState->tag); + + deviceState->spin=deviceState->spins[0]; + deviceState->lastFlipTime=0; // Bit redundant + + // We now have perfect knowledge of our neighbourhood, and + // when they are planning to fire. + + handler_log(3, "next_t = %u, next_spin = %d", deviceState->times[0], deviceState->spins[0]); + + deviceState->isEarliest=1; + for(unsigned i=1; i<5; i++){ + handler_log(3, " times[%d] = %u", i, deviceState->times[i]); + if(deviceState->times[0] >= deviceState->times[i]){ + deviceState->isEarliest=0; // We are not the earliest cell in neighbourhood + } + } + handler_log(3, "tag=%u", deviceState->tag); + + ]]> + + + + + + + + + + + seen++; + handler_log(2, "seenFinished = %u, wantFinished = %u", deviceState->seen, deviceProperties->fanin); + if(deviceState->seen == deviceProperties->fanin){ + fake_handler_exit(0); + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/relaxation_heat_16x16_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/relaxation_heat_16x16_v4.xml new file mode 100644 index 00000000..048cf3d0 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/relaxation_heat_16x16_v4.xml @@ -0,0 +1,2826 @@ + + + + + + b) ? a-b : b-a; + } + + float abs_diff(float a, float b) + { + return (a>b) ? a-b : b-a; + } + + ]]> + + + + + + + + + + + + + + + + + + + + + boundary ){ + deviceState->nhood[message->colour] = message->temperature; + + float sum=0; + for(unsigned i=0; i<4; i++){ + sum += deviceState->nhood[i]; + } + + // Trying this in floating-point to avoid rounding problems + float div=deviceProperties->neighbours; + float relaxed=sum/div; + if(relaxed<-127){ + relaxed=-127; + }else if(relaxed>127){ + relaxed=127; + } + deviceState->nextHeat = relaxed; + + } + if(deviceState->nextVersion < message->version){ + deviceState->nextVersion=message->version; + deviceState->received=0; + deviceState->sent=0; + } + if(deviceState->nextVersion == message->version){ + deviceState->received++; + } + + deviceState->dirty=true; + ]]> + + + + + x == message->x && deviceProperties->y == message->y){ + handler_log(2, "modification of (%u,%u) -> boundary=%u, initial=%d", message->x, message->y, message->boundary, message->heat); + + deviceState->nextVersion+=1; + deviceState->sent=0; + deviceState->received=0; + + deviceState->boundary=message->boundary; + deviceState->nextHeat=message->heat; + + deviceState->dirty=true; + } + ]]> + + + currHeat,deviceState->nextHeat) > graphProperties->threshold || deviceState->currVersion != deviceState->nextVersion ); + + if( abs_diff(deviceState->currHeat,deviceState->nextHeat) > graphProperties->threshold ){ + deviceState->currHeat=deviceState->nextHeat; + deviceState->nextVersion+=1; + deviceState->sent=0; + deviceState->received=0; + } + + assert(deviceState->sent==0); + + deviceState->currVersion=deviceState->nextVersion; + deviceState->sent=deviceProperties->neighbours; + + message->version=deviceState->currVersion; + message->colour=deviceProperties->colour; + message->temperature=deviceState->currHeat; + + deviceState->totalSent += deviceProperties->neighbours; + + deviceState->dirty=true; + ]]> + + + dirty); + assert(abs_diff(deviceState->currHeat,deviceState->nextHeat) <= graphProperties->threshold); + assert(deviceState->currVersion == deviceState->currVersion); + + deviceState->clock++; + + message->version=deviceState->currVersion; + message->sent=deviceState->sent; + message->received=deviceState->received; + message->count=1; + message->linkClock=deviceState->clock; + message->totalSent=deviceState->totalSent; + message->index=deviceProperties->termination_index; + + deviceState->dirty=false; + ]]> + + currHeat,deviceState->nextHeat) > graphProperties->threshold || deviceState->currVersion < deviceState->nextVersion ){ + *readyToSend=RTS_FLAG_share_out; + }else if(deviceState->dirty){ + *readyToSend=RTS_FLAG_termination_out; + } + ]]> + boundary=deviceProperties->initial_boundary; + + deviceState->nextHeat=deviceProperties->initial_heat; + + deviceState->currVersion=0; + + deviceState->nextVersion=1; + deviceState->sent=0; + deviceState->received=0; + + deviceState->dirty=true; + ]]> + + + + + + + + + + + index; + assert(indexdegree); + + if(deviceState->version < message->version){ + deviceState->version=message->version; + for(unsigned i=0; idegree; i++){ + deviceState->sent[i]=0; + deviceState->received[i]=0; + deviceState->count[i]=0; + } + } + if(deviceState->version == message->version){ + if(deviceState->linkClock[index] < message->linkClock){ + + deviceState->count[index]=message->count; + deviceState->received[index]=message->received; + deviceState->sent[index]=message->sent; + + deviceState->dirty=true; + } + } + + if(deviceState->linkClock[index] < message->linkClock){ + deviceState->totalSent[index]=message->totalSent; + deviceState->linkClock[index]=message->linkClock; + } + + ]]> + + + dirty); + + // TODO: this could be optimised to only send down when the total count + // matches the sum of all cells recursively above this on the tree. + + deviceState->clock++; + + message->version=deviceState->version; + message->count=0; + message->sent=0; + message->received=0; + message->index=deviceProperties->termination_index; + message->linkClock=deviceState->clock; + + for(unsigned i=0; idegree; i++){ + message->count+=deviceState->count[i]; + message->sent+=deviceState->sent[i]; + message->received+=deviceState->received[i]; + message->totalSent+=deviceState->totalSent[i]; + } + + deviceState->dirty=false; + ]]> + + dirty ? RTS_FLAG_termination_out : 0; + ]]> + degree <= sizeof(deviceState->count)/sizeof(deviceState->count[0]) ); + + ]]> + + + + + + + + + + + valid); + + deviceState->x=message->x; + deviceState->y=message->y; + deviceState->heat=message->heat; + deviceState->boundary=message->boundary; + + deviceState->valid=1; + ]]> + + + x=deviceState->x; + message->y=deviceState->y; + message->boundary=deviceState->boundary; + message->heat=deviceState->heat; + + deviceState->valid=0; + ]]> + + + x=deviceState->x; + message->y=deviceState->y; + message->boundary=deviceState->boundary; + message->heat=deviceState->heat; + + deviceState->valid=0; + ]]> + + valid ){ + uint32_t val = deviceProperties->split_axis==0 ? deviceState->x : deviceState->y; + if(val < deviceProperties->split_val){ + *readyToSend = RTS_FLAG_modification_out_left; + }else{ + *readyToSend = RTS_FLAG_modification_out_right; + } + } + ]]> + + + + + + + + + + + + index==0); // Root doesn't do any merging + + handler_log(2, "version=%u, count=%u (of %u), sent=%u, received=%u, totalSentHi=%u, totalSentLo=%u", + message->version, message->count, deviceProperties->totalCells, message->sent, message->received, + uint32_t(message->totalSent>>32), uint32_t(message->totalSent&0xFFFFFFFFul) + ); + + if(message->count==deviceProperties->totalCells && message->sent==message->received){ + deviceState->steps++; + + handler_log(1, "steps = %u, max_steps = %u, totalSentHi=%u, totalSentLo=%u", + deviceState->steps, deviceProperties->max_steps, + uint32_t(message->totalSent>>32), uint32_t(message->totalSent&0xFFFFFFFFul) + ); + if(deviceState->steps >= deviceProperties->max_steps){ + // TODO: Replace with proper exit mechanism + fake_handler_exit(0); + }else{ + deviceState->rts=RTS_FLAG_modification_out; + } + } + ]]> + + + x=rand_range(deviceState->state, deviceProperties->width); + message->y=rand_range(deviceState->state, deviceProperties->height); + //message->heat=(rand(deviceState->state)>>25) - (int)(rand(deviceState->state)>>25); + + message->heat=(rand(deviceState->state)>>31) ? 127 : -127; + + message->boundary=1; + + deviceState->rts=0; + ]]> + + rts; + ]]> + state=75543210; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/apps/storm_16_4_8_v4.xml b/Tests/ReferenceXML/v4/PEP20/apps/storm_16_4_8_v4.xml new file mode 100644 index 00000000..ee1dd714 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/apps/storm_16_4_8_v4.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + credit += message->credit; + //handler_log(4, "Received %u credit, local credit is %u", message->credit, deviceState->credit); + if(deviceProperties->isRoot && deviceState->credit==deviceState->totalCredit){ + fake_handler_exit(0); + } + ]]> + + + isRoot){ + assert(deviceState->credit==0); + uint32_t perDevice=1; + while( perDevice * deviceProperties->degree < 0x10000000ul ){ + perDevice *= 2; + } + message->credit=perDevice; + deviceState->credit=1; + deviceState->totalCredit=1+perDevice * deviceProperties->degree; + }else{ + assert(deviceState->credit >= deviceProperties->degree ); + uint32_t perDevice=1; + while( (perDevice * 2) * deviceProperties->degree <= deviceState->credit){ + perDevice *= 2; + } + message->credit=perDevice; + deviceState->credit -= perDevice*deviceProperties->degree; + } + //handler_log(4, "Sending %u credit wide, local credit is %u", message->credit, deviceState->credit); + ]]> + + + isRoot); + assert(deviceState->credit > 0); + message->credit=(deviceState->credit+1)/2; + deviceState->credit -= message->credit; + //handler_log(4, "Sending %u credit narrow, local credit is %u", message->credit, deviceState->credit); + + ]]> + + isRoot){ + if(deviceState->credit==0){ + *readyToSend = RTS_FLAG_wide; + } + }else{ + if(deviceState->credit >= deviceProperties->degree){ + uint32_t b=1664525*deviceState->credit+1013904223; + if( (b>>30)==0 ){ + *readyToSend = RTS_FLAG_wide; + }else{ + *readyToSend = RTS_FLAG_narrow; + } + }else if(deviceState->credit > 0 ){ + *readyToSend = RTS_FLAG_narrow; + } + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/readme.md b/Tests/ReferenceXML/v4/PEP20/readme.md new file mode 100644 index 00000000..04922ae5 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/readme.md @@ -0,0 +1,6 @@ +These files are lifted directly from PIP20, which is here: + +> [PIP20](https://github.com/POETSII/poets_improvement_proposals/tree/2a355282f3aa3912bdacf4ec50bf25199bdf310d/proposed/PIP-0020/xml) + +These are just the example v4 xml files provided by IC after the +v4 discussions. See the description in the PIP for what they are. \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-properties.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-properties.xml new file mode 100644 index 00000000..ef816bb9 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-properties.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-shared-code.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-shared-code.xml new file mode 100644 index 00000000..f4f3a68c --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-shared-code.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-state.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-state.xml new file mode 100644 index 00000000..c7b98806 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/duplicate-state.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name1.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name1.xml new file mode 100644 index 00000000..59e35296 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name1.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name2.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name2.xml new file mode 100644 index 00000000..5e5289c5 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/invalid-element-name2.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/malformed-path.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/malformed-path.xml new file mode 100644 index 00000000..f29225c6 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L0-syntax/malformed-path.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-device-id.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-device-id.xml new file mode 100644 index 00000000..f33fc609 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-device-id.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-edge-path.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-edge-path.xml new file mode 100644 index 00000000..c978126e --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/duplicate-edge-path.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/non-existent-message-type.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/non-existent-message-type.xml new file mode 100644 index 00000000..40449c5d --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/non-existent-message-type.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/reversed-edge-path.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/reversed-edge-path.xml new file mode 100644 index 00000000..16eddcc5 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L1-graph-topology/reversed-edge-path.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features1.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features1.xml new file mode 100644 index 00000000..389f1f4c --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features1.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features2.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features2.xml new file mode 100644 index 00000000..196d1666 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features2.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features3.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features3.xml new file mode 100644 index 00000000..76e771c6 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L2-graph-attributes/struct-with-extra-features3.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/invalid-rts-flag.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/invalid-rts-flag.xml new file mode 100644 index 00000000..5d935f44 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/invalid-rts-flag.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties.xml new file mode 100644 index 00000000..4759bf31 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + x = 10; + ]]> + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties2.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties2.xml new file mode 100644 index 00000000..9f3be37e --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L3-compilation/modifying-device-properties2.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/invalid/L4-run-time/return-in-handler.xml b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L4-run-time/return-in-handler.xml new file mode 100644 index 00000000..b6b0f982 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/invalid/L4-run-time/return-in-handler.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev-two-ports.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev-two-ports.xml new file mode 100644 index 00000000..84ddfdc4 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev-two-ports.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev.xml new file mode 100644 index 00000000..67080b7d --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/one-dev.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-no-spaces.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-no-spaces.xml new file mode 100644 index 00000000..339f2e98 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-no-spaces.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata1.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata1.xml new file mode 100644 index 00000000..a5dec7e1 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata1.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata2.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata2.xml new file mode 100644 index 00000000..a32a6535 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest-plus-metadata2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest.xml new file mode 100644 index 00000000..8fd40a2f --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L3-compilation/tiniest.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/example-dt10.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/example-dt10.xml new file mode 100644 index 00000000..2d86a61d --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/example-dt10.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + b=message->y; + ]]> + + + + + b=message->y; + ]]> + + + + y = deviceState->b; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.external.cpp b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.external.cpp new file mode 100644 index 00000000..f195ff6c --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.external.cpp @@ -0,0 +1,53 @@ +#include "poets_protocol/InProcessBinaryUpstreamConnection.hpp" + +void poets_in_proc_external_main(InProcessBinaryUpstreamConnection &conn, int argc, const char **argv) +{ + conn.external_log(0, "Calling connect."); + conn.connect("external_fan_inst_in_proc", "external_fan_inst_in_proc_inst", { + {"ext0","ping"}, {"ext1","ping"}, {"ext2","ping"}, {"ext3","ping"} + }); + conn.external_log(0, "Connect complete."); + + auto ext0_address=conn.get_device_address("ext0"); + auto ext1_address=conn.get_device_address("ext1"); + auto ext2_address=conn.get_device_address("ext2"); + auto ext3_address=conn.get_device_address("ext3"); + + while(1){ + conn.external_log(0, "Waiting for message"); + conn.wait_until(false); + + conn.external_log(0, "Receiving message"); + if(conn.can_recv()){ + std::shared_ptr> payload; + std::pair fanout; + conn.recv(fanout, payload); + + for(unsigned i=0; iat(0)); + conn.send( makeEndpoint(ext0_address, poets_pin_index_t{0}), payload ); + + }else if(dst== makeEndpoint(ext1_address,poets_pin_index_t{0})){ + conn.external_log(0, "Sending message from ext1 : %u.", *(uint32_t*)&payload->at(0)); + conn.send( makeEndpoint(ext1_address, poets_pin_index_t{0}), payload ); + + }else if(dst== makeEndpoint(ext2_address,poets_pin_index_t{0})){ + conn.external_log(0, "Sending message from ext2 : %u.", *(uint32_t*)&payload->at(0)); + conn.send( makeEndpoint(ext2_address, poets_pin_index_t{0}), payload ); + + }else if(dst== makeEndpoint(ext3_address,poets_pin_index_t{0})){ + conn.external_log(0, "Sending message from ext3 : %u.", *(uint32_t*)&payload->at(0)); + conn.send( makeEndpoint(ext3_address, poets_pin_index_t{0}), payload ); + + }else{ + throw std::runtime_error("Unknown dest device."); + } + } + + + } + } +} diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.xml new file mode 100644 index 00000000..255fde24 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-fan-inst-in-proc.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + received++; + deviceState->sum+=message->value; + handler_log(4, "sent=%u, received=%u, sum=%u", deviceState->sent, deviceState->received, deviceState->sum); + if(deviceState->received==4*deviceState->sent){ + assert(deviceState->sum == 4 * (deviceState->sent+1)*deviceState->sent/2); + } + if(deviceState->received==100){ + handler_log(0,"_HANDLER_EXIT_SUCCESS_9be65737_"); + } + ]]> + + + sent++; + message->value=deviceState->sent; + handler_log(2, "Sending %d", message->value); + ]]> + + sent==deviceState->received ? RTS_FLAG_out : 0; + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-no-inst.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-no-inst.xml new file mode 100644 index 00000000..47e3b3e6 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-no-inst.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + received++; + deviceState->sum+=message->value; + assert(deviceState->sum == (deviceState->received+1)*deviceState->received/2); + if(deviceState->received==100){ + handler_log(0,"_HANDLER_EXIT_SUCCESS_9be65737_"); + } + ]]> + + + sent++; + message->value=deviceState->sent; + ]]> + + sent==deviceState->received ? RTS_FLAG_out : 0; + ]]> + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-one-inst-in-proc.external.cpp b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-one-inst-in-proc.external.cpp new file mode 100644 index 00000000..c333c56e --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-one-inst-in-proc.external.cpp @@ -0,0 +1,32 @@ +#include "poets_protocol/InProcessBinaryUpstreamConnection.hpp" + +void poets_in_proc_external_main(InProcessBinaryUpstreamConnection &conn, int argc, const char **argv) +{ + conn.external_log(0, "Calling connect."); + conn.connect("external_one_inst_in_proc", "external_one_inst_in_proc_inst", {{"ext0","ping"}}); + conn.external_log(0, "Connect complete."); + + auto ext0_address=conn.get_device_address("ext0"); + + while(1){ + conn.external_log(0, "Waiting for message"); + conn.wait_until(false); + + conn.external_log(0, "Receiving message"); + if(conn.can_recv()){ + std::shared_ptr> payload; + std::pair fanout; + conn.recv(fanout, payload); + + for(unsigned i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + received++; + deviceState->sum+=message->value; + assert(deviceState->sum == (deviceState->received+1)*deviceState->received/2); + if(deviceState->received==100){ + handler_log(0,"_HANDLER_EXIT_SUCCESS_9be65737_"); + } + ]]> + + + sent++; + message->value=deviceState->sent; + handler_log(2, "Sending %d", message->value); + ]]> + + sent==deviceState->received ? RTS_FLAG_out : 0; + ]]> + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.external.cpp b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.external.cpp new file mode 100644 index 00000000..9512634e --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.external.cpp @@ -0,0 +1,42 @@ +#include "poets_protocol/InProcessBinaryUpstreamConnection.hpp" + +void poets_in_proc_external_main(InProcessBinaryUpstreamConnection &conn, int argc, const char **argv) +{ + conn.external_log(0, "Calling connect."); + conn.connect("external_two_inst_in_proc", "external_two_inst_in_proc_inst", { + {"ext0","ping"}, {"ext1","ping"} + }); + conn.external_log(0, "Connect complete."); + + auto ext0_address=conn.get_device_address("ext0"); + auto ext1_address=conn.get_device_address("ext1"); + + while(1){ + conn.external_log(0, "Waiting for message"); + conn.wait_until(false); + + conn.external_log(0, "Receiving message"); + if(conn.can_recv()){ + std::shared_ptr> payload; + std::pair fanout; + conn.recv(fanout, payload); + + for(unsigned i=0; iat(0)); + conn.send( makeEndpoint(ext0_address, poets_pin_index_t{0}), payload ); + + }else if(dst== makeEndpoint(ext1_address,poets_pin_index_t{0})){ + conn.external_log(0, "Sending message from ext1 : %u.", *(uint32_t*)&payload->at(0)); + conn.send( makeEndpoint(ext1_address, poets_pin_index_t{0}), payload ); + }else{ + throw std::runtime_error("Unknown dest device."); + } + } + + + } + } +} diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.xml new file mode 100644 index 00000000..e94162db --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/external-two-inst-in-proc.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + received++; + deviceState->sum+=message->value; + assert(deviceState->sum == (deviceState->received+1)*deviceState->received/2); + if(deviceState->received==100){ + handler_log(0,"_HANDLER_EXIT_SUCCESS_9be65737_"); + } + ]]> + + + sent++; + message->value=deviceState->sent; + handler_log(2, "Sending %d", message->value); + ]]> + + sent==deviceState->received ? RTS_FLAG_out : 0; + ]]> + + + + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-recv.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-recv.xml new file mode 100644 index 00000000..7294b768 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-recv.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + sent){ + *readyToSend=0; + }else{ + *readyToSend=RTS_FLAG_out; + } + ]]> + + + + + sent=1; + handler_log(0, "Message sent."); + ]]> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-send.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-send.xml new file mode 100644 index 00000000..d3fb9aa5 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once--succeed-send.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + sent){ + *readyToSend=0; + }else{ + *readyToSend=RTS_FLAG_out; + } + ]]> + + + + + sent=1; + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); + ]]> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once-no-edge--succeed-send.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once-no-edge--succeed-send.xml new file mode 100644 index 00000000..b365f0f4 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-loopback-once-no-edge--succeed-send.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + sent){ + *readyToSend=0; + }else{ + *readyToSend=RTS_FLAG_out; + } + ]]> + + + + + sent=1; + handler_log(0, "_HANDLER_EXIT_SUCCESS_9be65737_"); + ]]> + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-print-hello-in-init.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-print-hello-in-init.xml new file mode 100644 index 00000000..72aced60 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid/L4-run-time/single-device-print-hello-in-init.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata3.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata3.xml new file mode 100644 index 00000000..f09e1846 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata3.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata4.xml b/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata4.xml new file mode 100644 index 00000000..f2c5bef9 --- /dev/null +++ b/Tests/ReferenceXML/v4/PEP20/tests/valid_but_unsupported/L3-compilation/tiniest-plus-metadata4.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/Tinsel b/Tinsel index e67c21c9..e90193e5 160000 --- a/Tinsel +++ b/Tinsel @@ -1 +1 @@ -Subproject commit e67c21c9c277377927ef0a27697d823222e8849d +Subproject commit e90193e586603444caa5d60fac71ed527f9985f9