Skip to content

Commit

Permalink
- fixed profiling in hpcom
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Walther committed Aug 27, 2015
1 parent a783b5e commit fcbfeb5
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions Compiler/Template/CodegenCppHpcom.tpl
Expand Up @@ -173,26 +173,20 @@ template additionalHpcomProtectedMemberDeclaration(SimCode simCode, Text& extraF
>>
end match %>
}
<%
match schedulesOpt
case SOME((odeSchedule as THREADSCHEDULE(__),_,_)) then
<<
#ifdef MEASURETIME_MODELFUNCTIONS
std::vector<MeasureTimeData> measureTimeThreadArrayOdeHpcom;
std::vector<MeasureTimeData> measureTimeThreadArrayDaeHpcom;
std::vector<MeasureTimeData> measureTimeThreadArrayZeroFuncHpcom;
<%List.intRange(arrayLength(odeSchedule.threadTasks)) |> threadIdx => 'MeasureTimeValues* measuredSchedulerStartValues_<%intSub(threadIdx,1)%>;'; separator="\n"%>
<%List.intRange(arrayLength(odeSchedule.threadTasks)) |> threadIdx => 'MeasureTimeValues* measuredSchedulerEndValues_<%intSub(threadIdx,1)%>;'; separator="\n"%>
#endif //MEASURETIME_MODELFUNCTIONS
>>
end match
%>
<% if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
std::vector<MeasureTimeData> measureTimeArrayHpcom;
std::vector<MeasureTimeData> measureTimeSchedulerArrayHpcom;
//MeasureTimeValues *measuredStartValuesODE, *measuredEndValuesODE;
MeasureTimeValues *measuredSchedulerStartValues, *measuredSchedulerEndValues;

#ifdef MEASURETIME_MODELFUNCTIONS
std::vector<MeasureTimeData> measureTimeThreadArrayOdeHpcom;
std::vector<MeasureTimeData> measureTimeThreadArrayDaeHpcom;
std::vector<MeasureTimeData> measureTimeThreadArrayZeroFuncHpcom;
<%List.intRange(getConfigInt(NUM_PROC)) |> threadIdx => 'MeasureTimeValues* measuredSchedulerStartValues_<%intSub(threadIdx,1)%>;'; separator="\n"%>
<%List.intRange(getConfigInt(NUM_PROC)) |> threadIdx => 'MeasureTimeValues* measuredSchedulerEndValues_<%intSub(threadIdx,1)%>;'; separator="\n"%>
#endif //MEASURETIME_MODELFUNCTIONS
>>%>
>>
end match
Expand Down Expand Up @@ -440,7 +434,8 @@ end additionalHpcomConstructorDefinitions;
template additionalHpcomConstructorBodyStatements(Option<tuple<Schedule,Schedule,Schedule>> schedulesOpt, String modelNamePrefixStr, String fullModelName)
::=
let type = getConfigString(HPCOM_CODE)
match schedulesOpt
let threadMeasureTimeBlocks = if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then generateThreadMeasureTimeDeclaration(fullModelName, getConfigInt(NUM_PROC)) else ""
let schedulerSpecificReturn = match schedulesOpt
case SOME((odeSchedule as LEVELSCHEDULE(useFixedAssignments=true),_,_)) then
match type
case ("pthreads")
Expand Down Expand Up @@ -471,8 +466,6 @@ template additionalHpcomConstructorBodyStatements(Option<tuple<Schedule,Schedule
let initLocksZeroFunc = initializeArrayLocks(listLength(zeroFuncSchedule.outgoingDepTasks),"_lockZeroFunc",type)//daeSchedule.outgoingDepTasks |> task => initializeLockByDepTask(task, "_lockDae", type); separator="\n"
let assignLocksZeroFunc = assignArrayLocks(listLength(zeroFuncSchedule.outgoingDepTasks),"_lockZeroFunc",type)//daeSchedule.outgoingDepTasks |> task => assignLockByDepTask(task, "_lockDae", type); separator="\n"

let threadMeasureTimeBlocks = generateThreadMeasureTimeDeclaration(fullModelName, arrayLength(odeSchedule.threadTasks))

match type
case ("openmp") then
let threadFuncs = arrayList(odeSchedule.threadTasks) |> tt hasindex i0 fromindex 0 => generateThread(i0, type, modelNamePrefixStr,"evaluateThreadFunc"); separator="\n"
Expand All @@ -482,7 +475,6 @@ template additionalHpcomConstructorBodyStatements(Option<tuple<Schedule,Schedule
<%initLocksOde%>
<%initLocksDae%>
<%initLocksZeroFunc%>
<%threadMeasureTimeBlocks%>
>>
case ("mpi") then
<<
Expand Down Expand Up @@ -512,7 +504,6 @@ template additionalHpcomConstructorBodyStatements(Option<tuple<Schedule,Schedule
<%threadAssignLocks1%>

<%threadFuncs%>
<%threadMeasureTimeBlocks%>
>>
case SOME((odeSchedule as TASKDEPSCHEDULE(__),daeSchedule as TASKDEPSCHEDULE(__),zeroFuncSchedule as TASKDEPSCHEDULE(__))) then
match type
Expand All @@ -524,6 +515,10 @@ template additionalHpcomConstructorBodyStatements(Option<tuple<Schedule,Schedule
else ""
else ""
end match
<<
<%schedulerSpecificReturn%>
<%threadMeasureTimeBlocks%>
>>
end additionalHpcomConstructorBodyStatements;

template generateThreadMeasureTimeDeclaration(String fullModelName, Integer numberOfThreads)
Expand All @@ -535,7 +530,7 @@ template generateThreadMeasureTimeDeclaration(String fullModelName, Integer numb
measureTimeThreadArrayZeroFuncHpcom = std::vector<MeasureTimeData>(<%numberOfThreads%>);
MeasureTime::addResultContentBlock("<%fullModelName%>","evaluateODE_threads",&measureTimeThreadArrayOdeHpcom);
MeasureTime::addResultContentBlock("<%fullModelName%>","evaluateDAE_threads",&measureTimeThreadArrayDaeHpcom);
MeasureTime::addResultContentBlock("<%fullModelName%>","evaluateZeroFunc_threads",&measureTimeThreadArrayDaeHpcom);
MeasureTime::addResultContentBlock("<%fullModelName%>","evaluateZeroFunc_threads",&measureTimeThreadArrayZeroFuncHpcom);
<%List.intRange(numberOfThreads) |> threadIdx => 'measuredSchedulerStartValues_<%intSub(threadIdx,1)%> = MeasureTime::getZeroValues();'; separator="\n"%>
<%List.intRange(numberOfThreads) |> threadIdx => 'measuredSchedulerEndValues_<%intSub(threadIdx,1)%> = MeasureTime::getZeroValues();'; separator="\n"%>
<%List.intRange(numberOfThreads) |> threadIdx => 'measureTimeThreadArrayOdeHpcom[<%intSub(threadIdx,1)%>] = MeasureTimeData("evaluateODE_thread_<%threadIdx%>");'; separator="\n"%>
Expand Down Expand Up @@ -1148,21 +1143,28 @@ template generateLevelFixedCodeForThread(list<SimEqSystem> allEquationsPlusWhen,
if(_evaluateMode == 0)
{
evaluateThreadFuncODE_<%iThreadIdx%>();
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
<%generateMeasureTimeEndCode("valuesStart", "valuesEnd", 'measureTimeThreadArrayOdeHpcom[<%iThreadIdx%>]', 'evaluateODEThread<%iThreadIdx%>', "MEASURETIME_MODELFUNCTIONS")%>
>>%>
}
else if(_evaluateMode < 0)
{
evaluateThreadFuncAll_<%iThreadIdx%>();
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
<%generateMeasureTimeEndCode("valuesStart", "valuesEnd", 'measureTimeThreadArrayDaeHpcom[<%iThreadIdx%>]', 'evaluateDaeThread<%iThreadIdx%>', "MEASURETIME_MODELFUNCTIONS")%>
>>%>
}
else
{
evaluateThreadFuncZeroFunc_<%iThreadIdx%>();
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
<%generateMeasureTimeEndCode("valuesStart", "valuesEnd", 'measureTimeThreadArrayZeroFuncHpcom[<%iThreadIdx%>]', 'evaluateZeroFuncThread<%iThreadIdx%>', "MEASURETIME_MODELFUNCTIONS")%>
>>%>
}

<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
<%generateMeasureTimeEndCode("valuesStart", "valuesEnd", 'measureTimeArrayHpcom[<%iThreadIdx%>]', 'evaluateODEThread<%iThreadIdx%>', "MEASURETIME_MODELFUNCTIONS")%>
>>%>

//_evaluateBarrier.wait();
_levelBarrier.wait();
}
Expand Down

0 comments on commit fcbfeb5

Please sign in to comment.