Skip to content

Commit

Permalink
- interface for external hpcom-scheduler added
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18364 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Marcus Walther committed Dec 2, 2013
1 parent 1f099bf commit 8ae89a1
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
36 changes: 35 additions & 1 deletion Compiler/BackEnd/HpcOmScheduler.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,41 @@ algorithm
end printLevelSchedule1;

//--------------------
// External Scheduling
// External-C Scheduling
//--------------------
public function createExtCSchedule "function createExtSchedule
author: marcusw
Creates a scheduling by reading the required informations from a graphml-file."
input HpcOmTaskGraph.TaskGraph iTaskGraph;
input HpcOmTaskGraph.TaskGraphMeta iTaskGraphMeta;
input Integer iNumberOfThreads;
input array<list<Integer>> iSccSimEqMapping; //Maps each scc to a list of simEqs
output Schedule oSchedule;
protected
list<Integer> extInfo;
array<Integer> extInfoArr;
HpcOmTaskGraph.TaskGraph taskGraphT;
Schedule tmpSchedule;
array<list<Task>> threadTasks;
list<Integer> rootNodes;
array<tuple<Task, Integer>> allTasks;
list<tuple<Task,Integer>> nodeList_refCount; //list of nodes which are ready to schedule
list<Task> nodeList;
algorithm
oSchedule := matchcontinue(iTaskGraph,iTaskGraphMeta,iNumberOfThreads,iSccSimEqMapping)
case(_,_,_,_)
equation
extInfo = HpcOmSchedulerExt.scheduleAdjList(iTaskGraph);
then fail();
else
equation
print("HpcOmScheduler.createExtCSchedule not every node has a scheduler-info.\n");
then fail();
end matchcontinue;
end createExtCSchedule;

//--------------------
// External Scheduling //TODO: Rename to Yed Scheduling
//--------------------
public function createExtSchedule "function createExtSchedule
author: marcusw
Expand Down
6 changes: 6 additions & 0 deletions Compiler/BackEnd/HpcOmSchedulerExt.mo
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ public function readScheduleFromGraphMl
external "C" res=HpcOmSchedulerExt_readScheduleFromGraphMl(filename) annotation(Library = "omcruntime");
end readScheduleFromGraphMl;

public function scheduleAdjList
input array<list<Integer>> adjList;
output list<Integer> res;
external "C" res=HpcOmSchedulerExt_scheduleAdjList(adjList) annotation(Library = "omcruntime");
end scheduleAdjList;

end HpcOmSchedulerExt;
6 changes: 6 additions & 0 deletions Compiler/BackEnd/HpcOmSimCode.mo
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ algorithm
true = stringEq(flagValue, "ext");
print("Using external Scheduler\n");
then HpcOmScheduler.createExtSchedule(iTaskGraph, iTaskGraphMeta, numProc, iSccSimEqMapping, "taskGraph" +& iFilenamePrefix +& "_ext.graphml");
case(_,_,_,_,_)
equation
flagValue = Flags.getConfigString(Flags.HPCOM_SCHEDULER);
true = stringEq(flagValue, "extc");
print("Using external-c Scheduler\n");
then HpcOmScheduler.createExtCSchedule(iTaskGraph, iTaskGraphMeta, numProc, iSccSimEqMapping);
case(_,_,_,_,_)
equation
flagValue = Flags.getConfigString(Flags.HPCOM_SCHEDULER);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ constant ConfigFlag CORBA_OBJECT_REFERENCE_FILE_PATH = CONFIG_FLAG(49, "corbaObj

constant ConfigFlag HPCOM_SCHEDULER = CONFIG_FLAG(50, "hpcomScheduler",
NONE(), EXTERNAL(), STRING_FLAG(""), NONE(),
Util.gettext("Sets the scheduler for task graph scheduling. Default: list scheduling."));
Util.gettext("Sets the scheduler for task graph scheduling (list | level | levelr | ext | mcp). Default: list."));

constant ConfigFlag TEARING_HEURISTIC = CONFIG_FLAG(51, "tearingHeuristic",
NONE(), EXTERNAL(), STRING_FLAG("cellier"),
Expand All @@ -813,7 +813,7 @@ constant ConfigFlag TEARING_HEURISTIC = CONFIG_FLAG(51, "tearingHeuristic",

constant ConfigFlag HPCOM_CODE = CONFIG_FLAG(52, "hpcomCode",
NONE(), EXTERNAL(), STRING_FLAG("openmp"), NONE(),
Util.gettext("Sets the code-type produced by hpcom. Default: openmp."));
Util.gettext("Sets the code-type produced by hpcom (openmp | pthreads | pthreads_spin). Default: openmp."));

// This is a list of all configuration flags. A flag can not be used unless it's
// in this list, and the list is checked at initialization so that all flags are
Expand Down
7 changes: 7 additions & 0 deletions Compiler/runtime/HpcOmSchedulerExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ void* HpcOmSchedulerExtImpl__readScheduleFromGraphMl(const char *filename)
}
return res;
}

void* HpcOmSchedulerExtImpl__scheduleAdjList(std::list<long int> adjLst[])
{
void *res = mk_nil();

return res;
}
23 changes: 23 additions & 0 deletions Compiler/runtime/HpcOmSchedulerExt_omc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,27 @@ extern void* HpcOmSchedulerExt_readScheduleFromGraphMl(const char *filename)
{
return HpcOmSchedulerExtImpl__readScheduleFromGraphMl(filename);
}

extern void* HpcOmSchedulerExt_scheduleAdjList(modelica_metatype adjList)
{
int nelts = (int)MMC_HDRSLOTS(MMC_GETHDR(adjList));
std::list<long int> adjLsts[nelts];

for(int i=0; i<nelts; ++i)
{
modelica_metatype adjLstE = MMC_STRUCTDATA(adjList)[i];
std::list<long int> adjLst;

while(MMC_GETHDR(adjLstE) == MMC_CONSHDR) {
long int i1 = MMC_UNTAGFIXNUM(MMC_CAR(adjLstE));
adjLst.push_back(i1);
adjLstE = MMC_CDR(adjLstE);
}

adjLsts[i] = adjLst;
}

return HpcOmSchedulerExtImpl__scheduleAdjList(adjLsts);
}

}
29 changes: 29 additions & 0 deletions Compiler/runtime/HpcOmSchedulerExt_rml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C" {
}

#include "HpcOmSchedulerExt.cpp"
#include <iostream>
extern "C" {
void HpcOmSchedulerExt_5finit(void)
{
Expand All @@ -44,4 +45,32 @@ RML_BEGIN_LABEL(HpcOmSchedulerExt__readScheduleFromGraphMl)
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(HpcOmSchedulerExt__scheduleAdjList)
{
int nelts = (int)RML_HDRSLOTS(RML_GETHDR(rmlA0)); //number of elements in array
std::list<long int> adjLsts[nelts];

std::cerr << "element count: " << nelts << std::endl;

for(int i=0; i<nelts; i++) {
std::cerr << "bla" << std::endl;
void* adjLstE = RML_STRUCTDATA(rmlA0)[i]; //adjacence list entry
std::list<long int> adjLst;

while(RML_GETHDR(adjLstE) == RML_CONSHDR)
{
long int i1 = RML_UNTAGFIXNUM(RML_CAR(adjLstE));
adjLst.push_back(i1);
std::cerr << "elem: " << i1 << std::endl;
adjLstE = RML_CDR(adjLstE);
}

adjLsts[i] = adjLst;
}

rmlA0 = HpcOmSchedulerExtImpl__scheduleAdjList(adjLsts);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
}

0 comments on commit 8ae89a1

Please sign in to comment.