Skip to content

Commit

Permalink
- When doing static scheduling, filter out empty systems
Browse files Browse the repository at this point in the history
- When creating the loop for equation systems to solve, if size=0 or 1, unroll the loop


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15444 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 3, 2013
1 parent be4809c commit c4d11c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Compiler/BackEnd/SimCodeUtil.mo
Expand Up @@ -1609,6 +1609,9 @@ algorithm

odeEquations = makeEqualLengthLists(odeEquations, Config.noProc());
algebraicEquations = makeEqualLengthLists(algebraicEquations, Config.noProc());
/* Filter out empty systems to improve code generation */
odeEquations = List.filterOnTrue(odeEquations, List.isNotEmpty);
algebraicEquations = List.filterOnTrue(algebraicEquations, List.isNotEmpty);

Debug.fcall(Flags.EXEC_HASH, print, "*** SimCode -> generate cref2simVar hastable: " +& realString(clock()) +& "\n");
crefToSimVarHT = createCrefToSimVarHT(modelInfo);
Expand Down
7 changes: 6 additions & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -1520,11 +1520,16 @@ template functionXXX_systems(list<list<SimEqSystem>> eqs, String name, Text &loo
let funcs = eqs |> eq hasindex i1 fromindex 0 => functionXXX_system(eq,name,i1) ; separator="\n"
let nFuncs = listLength(eqs)
let funcNames = eqs |> e hasindex i1 fromindex 0 => 'function<%name%>_system<%i1%>' ; separator=",\n"
let head = if Flags.isSet(Flags.OPENMP) then '#pragma omp parallel for private(id,th_id) schedule(<%match noProc() case 0 then "dynamic" else "static"%>)'
let &varDecls += 'int id, th_id;<%\n%>'
let &loop +=
/* Text for the loop body that calls the equations */
match listLength(eqs)
case 0 then ""
case 1 then 'function<%name%>_systems[0](data,omp_get_thread_num());'
else
<<
<% if Flags.isSet(Flags.OPENMP) then '#pragma omp parallel for private(id,th_id) schedule(<%match noProc() case 0 then "dynamic" else "static"%>)' %>
<%head%>
for(id=0; id<<%nFuncs%>; id++) {
th_id = omp_get_thread_num();
function<%name%>_systems[id](data,th_id);
Expand Down

0 comments on commit c4d11c3

Please sign in to comment.