Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fastMW2
Browse files Browse the repository at this point in the history
Conflicts:
	SimulationRuntime/cpp/Core/Utils/extension/measure_time_statistic.cpp
  • Loading branch information
Marcus Walther committed Jun 17, 2015
2 parents a5bdcbf + df48d6e commit 42e3157
Show file tree
Hide file tree
Showing 35 changed files with 2,199 additions and 513 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -798,7 +798,7 @@ algorithm
DAE.InstDims dims;
DAE.ElementSource src;
Option<DAE.VariableAttributes> va;
Option<BackendDAE.TearingSelect> ts;
Option<BackendDAE.TearingSelect> ts;
Option<SCode.Comment> c;
DAE.ConnectorType ct;
Values.Value v;
Expand Down Expand Up @@ -4042,7 +4042,7 @@ public function getAdjacencyMatrixEnhancedScalar
and add some information how the variable occure in the equation(see BackendDAE.BackendDAE.Solvability)."
input BackendDAE.EqSystem syst;
input BackendDAE.Shared shared;
input Boolean trytosolve "determine the solvability by solving for the variable intead of deriving, needed for 'Casual Tearing Set'";
input Boolean trytosolve "determine the solvability by solving for the variable instead of deriving, needed for 'Casual Tearing Set'";
output BackendDAE.AdjacencyMatrixEnhanced outIncidenceMatrix;
output BackendDAE.AdjacencyMatrixTEnhanced outIncidenceMatrixT;
output array<list<Integer>> outMapEqnIncRow;
Expand Down
18 changes: 18 additions & 0 deletions Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -1123,6 +1123,12 @@ algorithm
case ((e as DAE.CALL(path = path,expLst = expl,attr = attr)),repl,cond)
equation
true = replaceExpCond(cond, e);
cr = ComponentReference.toExpCref(Absyn.pathToCref(path));
if hasReplacement(repl,cr) then
e1_1 = getReplacement(repl,cr);
DAE.PARTEVALFUNCTION(path=path,expList = expl_1) = e1_1;
expl = listAppend(expl_1,expl);
end if;
(expl_1,true) = replaceExpList(expl, repl, cond, {}, false);
then
(DAE.CALL(path,expl_1,attr),true);
Expand Down Expand Up @@ -1205,6 +1211,18 @@ algorithm
(e1_1,_) = replaceExp(e1, repl, cond);
(iters,true) = replaceExpIters(iters, repl, cond, {}, false);
then (DAE.REDUCTION(reductionInfo,e1_1,iters),true);
case ((e as DAE.BOX(exp = e1)),repl,cond)
equation
true = replaceExpCond(cond, e);
(e1_1,true) = replaceExp(e1, repl, cond);
then
(DAE.BOX(e1_1),true);
case ((e as DAE.UNBOX(ty=tp, exp = e1)),repl,cond)
equation
true = replaceExpCond(cond, e);
(e1_1,true) = replaceExp(e1, repl, cond);
then
(DAE.UNBOX(e1_1,tp),true);
case (e,_,_)
then (e,false);
end matchcontinue;
Expand Down
545 changes: 458 additions & 87 deletions Compiler/BackEnd/EvaluateFunctions.mo

Large diffs are not rendered by default.

140 changes: 132 additions & 8 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -130,7 +130,7 @@ algorithm
(tmpSchedule,_) := createListSchedule1(nodeList,threadReadyTimes, iTaskGraph, taskGraphT, commCosts, inComps, iSccSimEqMapping, iSimVarMapping, getLocksByPredecessorList, tmpSchedule);
tmpSchedule := addSuccessorLocksToSchedule(iTaskGraph,addReleaseLocksToSchedule,commCosts,inComps,iSimVarMapping,tmpSchedule);
//printSchedule(tmpSchedule);
oSchedule := tmpSchedule;
oSchedule := setScheduleLockIds(tmpSchedule);
end createListSchedule;

protected function createListSchedule1 "function createListSchedule1
Expand Down Expand Up @@ -300,7 +300,7 @@ algorithm
tmpSchedule := addSuccessorLocksToSchedule(iTaskGraph, addReleaseLocksToSchedule, commCosts, inComps, iSimVarMapping,
tmpSchedule);
//printSchedule(tmpSchedule);
oSchedule := tmpSchedule;
oSchedule := setScheduleLockIds(tmpSchedule);
end createRandomSchedule;


Expand Down Expand Up @@ -493,7 +493,7 @@ algorithm
threadTasks := Array.map(threadTasks, listReverse);
tmpSchedule := HpcOmSimCode.THREADSCHEDULE(threadTasks,outgoingDepTasks,{},allCalcTasks);
//printSchedule(tmpSchedule);
oSchedule := tmpSchedule;
oSchedule := setScheduleLockIds(tmpSchedule); // set unique lock ids
end createListScheduleReverse;

protected function addSuccessorLocksToSchedule
Expand Down Expand Up @@ -839,7 +839,7 @@ protected function createDepTask "author: marcusw
input HpcOmSimCode.CommunicationInfo commInfo;
output HpcOmSimCode.Task oAssignTask;
algorithm
oAssignTask := HpcOmSimCode.DEPTASK(iSourceTask,iTargetTask,iOutgoing,commInfo);
oAssignTask := HpcOmSimCode.DEPTASK(iSourceTask,iTargetTask,iOutgoing,0,commInfo);
end createDepTask;

protected function createDepTaskAndCommunicationInfo "author: marcusw
Expand Down Expand Up @@ -2531,7 +2531,7 @@ algorithm
//tmpSchedule = HpcOmSimCode.THREADSCHEDULE(threadTasks,{},{},allCalcTasks);
//tmpSchedule = createExtSchedule1(nodeList,extInfoArr, iTaskGraph, taskGraphT, commCosts, inComps, iSccSimEqMapping, iSimVarMapping, getLocksByPredecessorList, tmpSchedule);
//tmpSchedule = addSuccessorLocksToSchedule(iTaskGraph,addReleaseLocksToSchedule,commCosts,inComps,iSimVarMapping,tmpSchedule);
then tmpSchedule;
then setScheduleLockIds(tmpSchedule); // set unique lock ids
else
equation
print("HpcOmScheduler.createMetisSchedule not every node has a scheduler-info.\n");
Expand Down Expand Up @@ -2684,7 +2684,7 @@ algorithm
tmpSchedule = createExtSchedule1(nodeList,extInfoArr, iTaskGraph, taskGraphT, commCosts, inComps, iSccSimEqMapping, iSimVarMapping, getLocksByPredecessorList, tmpSchedule);
tmpSchedule = addSuccessorLocksToSchedule(iTaskGraph,addReleaseLocksToSchedule,commCosts,inComps,iSimVarMapping,tmpSchedule);
//printSchedule(tmpSchedule);
then tmpSchedule;
then setScheduleLockIds(tmpSchedule); // set unique lock ids
else
equation
print("HpcOmScheduler.createHMetisSchedule not every node has a scheduler-info.\n");
Expand Down Expand Up @@ -4807,7 +4807,7 @@ algorithm
schedule := traverseAndUpdateThreadsInSchedule(schedule,removeLocksFromThread,removeLocks);
schedule := updateLockIdcsInThreadschedule(schedule,removeLocksFromLockList,removeLocks);
//printSchedule(schedule);
oSchedule := schedule;
oSchedule := setScheduleLockIds(schedule); // set unique lock ids
end createMCPschedule;

protected function MCP_getTaskAssignment "gets the assignment which nodes is computed of which processor for the MCP algorithm.
Expand Down Expand Up @@ -6497,6 +6497,130 @@ algorithm
end matchcontinue;
end revertTaskList;

//----------------
// LockIdSetter
//----------------

protected function setScheduleLockIds "Function creates unique Ids for every tuple of out and ingoing locks
author: mhartung"
input HpcOmSimCode.Schedule iSchedule;
output HpcOmSimCode.Schedule oSchedule;
protected
array<list<HpcOmSimCode.Task>> allThreadTasks;
array<list<HpcOmSimCode.Task>> tmpFoldArray;
array<list<HpcOmSimCode.Task>> newAllThreadTasks;
list<HpcOmSimCode.Task> scheduledTasks;
array<list<tuple<Integer,Integer>>> lockIds; // going to contain all outgoing locks by node to the target node with id: BSP: locks[source_node](target_node,lockId)
list<HpcOmSimCode.Task> outgoingDepTasks;
list<HpcOmSimCode.Task> newOutgoingDepTasks = {};
array<tuple<HpcOmSimCode.Task,Integer>> allCalcTasks;
tuple<Integer,Integer> newTuple;
HpcOmSimCode.Task sourceTask;
HpcOmSimCode.Task targetTask;
HpcOmSimCode.Task iterTask;
Integer counter;
Integer id, sourceTaskId, targetTaskId;
Boolean outgoing;
HpcOmSimCode.CommunicationInfo communicationInfo;
algorithm
((HpcOmSimCode.THREADSCHEDULE(allThreadTasks,outgoingDepTasks,scheduledTasks,allCalcTasks))) := iSchedule;
lockIds := arrayCreate(arrayLength(allCalcTasks),{});
newAllThreadTasks := arrayCreate(arrayLength(allThreadTasks),{});
counter := 0;
//getting LockIds:
for iterTask in outgoingDepTasks loop
((HpcOmSimCode.DEPTASK(sourceTask = sourceTask,targetTask = targetTask,outgoing = outgoing,id = id, communicationInfo = communicationInfo))) := iterTask;
HpcOmSimCode.CALCTASK(index = sourceTaskId) := sourceTask;
HpcOmSimCode.CALCTASK(index = targetTaskId) := targetTask;
newTuple := (targetTaskId,counter);
arrayUpdate(lockIds,sourceTaskId,listAppend(arrayGet(lockIds,sourceTaskId),{newTuple}));
newOutgoingDepTasks := HpcOmSimCode.DEPTASK(sourceTask,targetTask,outgoing,counter,communicationInfo)::newOutgoingDepTasks;
counter := counter +1;
end for;
//Setting old locks on new labeled Locks
tmpFoldArray := arrayCreate(arrayLength(allThreadTasks),{});
(newAllThreadTasks,_) := Array.fold(allThreadTasks, function replaceDepTaskIdsByLockIds(lockIds = lockIds),(tmpFoldArray,1));
oSchedule := HpcOmSimCode.THREADSCHEDULE(newAllThreadTasks, newOutgoingDepTasks, scheduledTasks, allCalcTasks);
end setScheduleLockIds;

protected function replaceDepTaskIdsByLockIds
input list<HpcOmSimCode.Task> inTasks;
input array<list<tuple<Integer,Integer>>> lockIds;
input tuple<array<list<HpcOmSimCode.Task>>,Integer> iAllThreadTasks;
output tuple<array<list<HpcOmSimCode.Task>>,Integer> oTasks;
protected
array<list<HpcOmSimCode.Task>> allThreadTasks;
list<HpcOmSimCode.Task> tmpList;
Integer threadId;
algorithm
(allThreadTasks,threadId) := iAllThreadTasks;
tmpList := listReverse(List.fold(inTasks, function replaceDepTasksInListByLockIds(lockIds=lockIds),{}));
arrayUpdate(allThreadTasks,threadId,tmpList);
oTasks:=(allThreadTasks,threadId+1);
end replaceDepTaskIdsByLockIds;

protected function replaceDepTasksInListByLockIds
input HpcOmSimCode.Task inTask;
input array<list<tuple<Integer,Integer>>> lockIds;
input list<HpcOmSimCode.Task> tmpTaskList;
output list<HpcOmSimCode.Task> oList;
protected
HpcOmSimCode.Task tmpTask;
algorithm
tmpTask := findTaskWithLockId(lockIds,inTask);
oList := tmpTask::tmpTaskList;
end replaceDepTasksInListByLockIds;


protected function findTaskWithLockId "Function returns a DepTask with the id regarding lockIds or the identity of the given task"
input array<list<tuple<Integer,Integer>>> lockIds;
input HpcOmSimCode.Task iTask;
output HpcOmSimCode.Task oTask;

protected
HpcOmSimCode.Task tmpTask;
HpcOmSimCode.Task sourceTask;
HpcOmSimCode.Task targetTask;
Boolean outgoing;
Integer lockId, sourceTaskId , targetTaskId;
HpcOmSimCode.CommunicationInfo communicationInfo;
algorithm
oTask := match(iTask)
case(HpcOmSimCode.DEPTASK(sourceTask = sourceTask,targetTask = targetTask,outgoing = outgoing,communicationInfo = communicationInfo))
equation
// Finding Nemo
HpcOmSimCode.CALCTASK(index = sourceTaskId) = sourceTask;
HpcOmSimCode.CALCTASK(index = targetTaskId) = targetTask;
lockId = findInIntTuple1(arrayGet(lockIds,sourceTaskId),targetTaskId);
tmpTask = HpcOmSimCode.DEPTASK(sourceTask,targetTask,outgoing,lockId,communicationInfo);
then tmpTask;
else
then iTask;
end match;
end findTaskWithLockId;

protected function findInIntTuple1
input list<tuple<Integer,Integer>> liste;
input Integer toFind;
output Integer secondElement;

protected
Integer first, second;
tuple<Integer,Integer> iter;

algorithm
for iter in liste loop
(first,second) := iter;
if intEq(first,toFind) then

secondElement := second;
return;
end if;
end for;

end findInIntTuple1;


protected function convertFixedLevelScheduleToTaskListsForLevel
"Convert a level task list into a task list for each thread.
author:marcusw"
Expand Down Expand Up @@ -6584,4 +6708,4 @@ end intListListString;


annotation(__OpenModelica_Interface="backend");
end HpcOmScheduler;
end HpcOmScheduler;
6 changes: 5 additions & 1 deletion Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -66,6 +66,7 @@ protected import DAEUtil;
protected import SimCodeUtil;
protected import Debug;
protected import Error;
protected import EvaluateFunctions;
protected import Expression;
protected import ExpressionDump;
protected import ExpressionSimplify;
Expand Down Expand Up @@ -1749,7 +1750,10 @@ algorithm
case (_, _, _, _, _, (vars, shared as BackendDAE.SHARED(functionTree=functions), eqns, seqns, index, mT, _))
equation
false = Expression.isImpure(exp); // lochel: this is at least needed for impure functions
exp2 = Ceval.cevalSimpleWithFunctionTreeReturnExp(exp, functions);
//exp2 = Ceval.cevalSimpleWithFunctionTreeReturnExp(exp, functions);
exp2 = EvaluateFunctions.evaluateConstantFunctionCallExp(exp,functions);
if not Expression.isConst(exp2) then
exp2 = exp; end if;
if Flags.isSet(Flags.DEBUG_ALIAS) then
BackendDump.debugStrCrefStrExpStr("Const Equation (through Ceval) ", cr, " = ", exp, " found.\n");
end if;
Expand Down
14 changes: 12 additions & 2 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -1919,12 +1919,22 @@ algorithm
print("*\n* The casual tearing set is not smaller\n* than the strict tearing set and there-\n* fore it is discarded.\n*" + BORDER + "\n");
end if;

true := b;
if not b and not Flags.getConfigBool(Flags.FORCE_TEARING) then
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nNote:\n=====\nTearing set is discarded because it is not smaller than the original set. Use +forceTearing to prevent this.\n\n");
end if;
fail();
end if;
casualTearingSet := NONE();
end if;

else
true := b;
if not b and not Flags.getConfigBool(Flags.FORCE_TEARING) then
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nNote:\n=====\nTearing set is discarded because it is not smaller than the original set. Use +forceTearing to prevent this.\n\n");
end if;
fail();
end if;
casualTearingSet := NONE();
end if;

Expand Down

0 comments on commit 42e3157

Please sign in to comment.