Skip to content

Commit

Permalink
[Janitor mode] Fix whitespace
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21882 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
OpenModelica-Hudson committed Aug 15, 2014
1 parent e25466d commit 1a14a33
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 80 deletions.
74 changes: 37 additions & 37 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -1125,8 +1125,8 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__)) then
std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > system = simulation.first->LoadSystem("OMCpp<%fileNamePrefix%><%makefileParams.dllext%>","<%lastIdentOfPath(modelInfo.name)%>");
simulation.first->Start(system.first,simulation.second,"<%lastIdentOfPath(modelInfo.name)%>");
<% if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then 'RDTSC_MeasureTime::deinitialize();' %>
return 0;
<% if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then 'RDTSC_MeasureTime::deinitialize();' %>
return 0;
}
catch(std::exception& ex)
Expand Down Expand Up @@ -1372,7 +1372,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
#LDSYTEMFLAGS=/MD /Debug /link /DLL /NOENTRY /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" /LIBPATH:"<%makefileParams.omhome%>/bin" /LIBPATH:"$(BOOST_LIBS)" OMCppSystem.lib OMCppModelicaUtilities.lib OMCppMath.lib OMCppOMCFactory.lib
LDSYTEMFLAGS= /link /DLL /NOENTRY /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" /LIBPATH:"<%makefileParams.omhome%>/bin" /LIBPATH:"$(BOOST_LIBS)" OMCppSystem.lib OMCppModelicaUtilities.lib OMCppMath.lib OMCppOMCFactory.lib <%timeMeasureLink%>
#LDMAINFLAGS=/MD /Debug /link /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" OMCppOMCFactory.lib /LIBPATH:"<%makefileParams.omhome%>/bin" /LIBPATH:"$(BOOST_LIBS)"
LDMAINFLAGS=/link /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" OMCppOMCFactory.lib <%timeMeasureLink%> /LIBPATH:"<%makefileParams.omhome%>/bin" /LIBPATH:"$(BOOST_LIBS)"
LDMAINFLAGS=/link /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" OMCppOMCFactory.lib <%timeMeasureLink%> /LIBPATH:"<%makefileParams.omhome%>/bin" /LIBPATH:"$(BOOST_LIBS)"
# /MDd link with MSVCRTD.LIB debug lib
# lib names should not be appended with a d just switch to lib/omc/cpp

Expand Down Expand Up @@ -1486,13 +1486,13 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
%>
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
MeasureTime::data ref;
ref.max_time = 0;
ref.num_calcs = 0;
ref.sum_time = 0;
measureTimeArray = std::vector<MeasureTime::data>(<%listLength(simCode.allEquations)%>,ref);
>>
<<
MeasureTime::data ref;
ref.max_time = 0;
ref.num_calcs = 0;
ref.sum_time = 0;
measureTimeArray = std::vector<MeasureTime::data>(<%listLength(simCode.allEquations)%>,ref);
>>
%>
//DAE's are not supported yet, Index reduction is enabled
_dimAE = 0; // algebraic equations
Expand All @@ -1515,13 +1515,13 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
{
if(_functions != NULL)
delete _functions;
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
let n = listLength(simCode.allEquations)
<<
MeasureTime::getInstance()->writeTimeToJason("<%dotPath(modelInfo.name)%>",measureTimeArray);
>>
%>
let n = listLength(simCode.allEquations)
<<
MeasureTime::getInstance()->writeTimeToJason("<%dotPath(modelInfo.name)%>",measureTimeArray);
>>
%>
}
Expand Down Expand Up @@ -3818,7 +3818,7 @@ template InitializeEquationsArray(list<SimEqSystem> allEquations, String classNa
first_equation_index = <%equationIndex(feq)%>;
<%equation_inits%>
}
}
>>
end match
end InitializeEquationsArray;
Expand Down Expand Up @@ -4084,7 +4084,7 @@ match modelInfo
boost::shared_ptr<ISimData> _simData;
<% if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then 'std::vector<MeasureTime::data> measureTimeArray;' %>
<% if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then 'std::vector<MeasureTime::data> measureTimeArray;' %>
<%memberfuncs%>
Expand Down Expand Up @@ -7031,24 +7031,24 @@ end equation_function_call;
(this->*equations_array[<%arrayIndex%>])();
>>
*/

template measureTimeStart(Integer eq_number)
::=
<<
long long unsigned startMeasure_t, endMeasure_t,measure_t;
startMeasure_t = MeasureTime::getInstance()->getTime();
>>
<<
long long unsigned startMeasure_t, endMeasure_t,measure_t;
startMeasure_t = MeasureTime::getInstance()->getTime();
>>
end measureTimeStart;

template measureTimeStop(Integer eq_number)
::=
<<
endMeasure_t = MeasureTime::getInstance()->getTime();
measure_t = endMeasure_t - startMeasure_t;
if(measure_t > measureTimeArray[<%eq_number%>].max_time) measureTimeArray[<%eq_number%>].max_time = measure_t;
measureTimeArray[<%eq_number%>].sum_time += measure_t;
++(measureTimeArray[<%eq_number%>].num_calcs);
>>
<<
endMeasure_t = MeasureTime::getInstance()->getTime();
measure_t = endMeasure_t - startMeasure_t;
if(measure_t > measureTimeArray[<%eq_number%>].max_time) measureTimeArray[<%eq_number%>].max_time = measure_t;
measureTimeArray[<%eq_number%>].sum_time += measure_t;
++(measureTimeArray[<%eq_number%>].num_calcs);
>>
end measureTimeStop;

template equation_function_create_single_func(SimEqSystem eq, Context context, SimCode simCode,Text method,Text classnameext, Boolean useFlatArrayNotation, Boolean createMeasureTime, Integer equa_number)
Expand All @@ -7058,7 +7058,7 @@ template equation_function_create_single_func(SimEqSystem eq, Context context, S
let &additionalFuncs = buffer "" /*BUFD*/
let &measureTimeStartVar = buffer "" /*BUFD*/
let &measureTimeEndVar = buffer "" /*BUFD*/

let body = match eq
case e as SES_SIMPLE_ASSIGN(__)
then
Expand All @@ -7078,30 +7078,30 @@ template equation_function_create_single_func(SimEqSystem eq, Context context, S
case e as SES_NONLINEAR(__)
then
equationLinearOrNonLinear(e, context, &varDeclsLocal,simCode)
case e as SES_MIXED(__)
case e as SES_MIXED(__)
then
/*<%equationMixed(e, context, &varDeclsLocal, simCode)%>*/
let &additionalFuncs += equation_function_create_single_func(e.cont,context,simCode,method,classnameext, useFlatArrayNotation, false, 0)
"throw std::runtime_error(\"Mixed systems are not supported yet\");"
else
"NOT IMPLEMENTED EQUATION"
end match
end match
let &measureTimeStartVar += if boolAnd(boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")),createMeasureTime) then measureTimeStart(equa_number) //else ""
let &measureTimeEndVar += if boolAnd(boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")),createMeasureTime) then measureTimeStop(equa_number) //else ""
<<
<%additionalFuncs%>
<%additionalFuncs%>
/*
<%dumpEqs(fill(eq,1))%>
*/
void <%lastIdentOfPathFromSimCode(simCode)%><%classnameext%>::<%method%>_<%ix_str%>()
{
<%measureTimeStartVar%>
<%measureTimeStartVar%>
<%varDeclsLocal%>
<%body%>
<%measureTimeEndVar%>
<%measureTimeEndVar%>
}
>>

end equation_function_create_single_func;

template equationMixed(SimEqSystem eq, Context context, Text &varDecls /*BUFP*/, SimCode simCode, Boolean useFlatArrayNotation)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCppHpcom.tpl
Expand Up @@ -1175,7 +1175,7 @@ template function_HPCOM_Thread(list<SimEqSystem> allEquationsPlusWhen, array<lis
#pragma omp parallel num_threads(<%arrayLength(threadTasks)%>)
{
int threadNum = omp_get_thread_num();
//Assign locks first
<%threadAssignLocks%>
#pragma omp barrier
Expand Down
84 changes: 42 additions & 42 deletions SimulationRuntime/cpp/Core/Utils/extension/measure_time.cpp
Expand Up @@ -3,58 +3,58 @@

MeasureTime* MeasureTime::getInstance()
{
return instance;
return instance;
}

void MeasureTime::deinitialize()
{
if(instance != 0)
delete instance;
if(instance != 0)
delete instance;
}

unsigned long long MeasureTime::getTime()
{
if(instance == 0)
return 0;
if(instance == 0)
return 0;

return instance->getTimeP();
return instance->getTimeP();
}

void MeasureTime::writeTimeToJason(std::string model_name, std::vector<data> times)
{
std::stringstream date;
date.str("");
time_t sec = time(NULL);
tm * date_t = localtime(&sec);
date << date_t->tm_year+1900 << "-" << date_t->tm_mon+1 << "-" << date_t->tm_mday << " " << date_t->tm_hour << ":" << date_t->tm_min << ":" << date_t->tm_sec;
std::ofstream os;
os.open((model_name+std::string("_prof.json")).c_str());
os << "{\n\"name\":\"" << model_name << "\",\n";
os << "\"prefix\":\"" << model_name << "\",\n";
os << "\"date\":\"" << date.str() << "\",\n";

os << "\"functions\":[\n],\n";
os << "\"profileBlocks\":[\n";

for(unsigned i=0;i<times.size();++i)
{
os << "{\"id\":" << i << ",\"ncall\":" << times[i].num_calcs << ",\"time\":" << times[i].sum_time
<< ",\"maxTime\":" << times[i].max_time << "},\n";
}
os << "]\n}";
os.close();
}
{
std::stringstream date;
date.str("");
time_t sec = time(NULL);
tm * date_t = localtime(&sec);
date << date_t->tm_year+1900 << "-" << date_t->tm_mon+1 << "-" << date_t->tm_mday << " " << date_t->tm_hour << ":" << date_t->tm_min << ":" << date_t->tm_sec;
std::ofstream os;
os.open((model_name+std::string("_prof.json")).c_str());
os << "{\n\"name\":\"" << model_name << "\",\n";
os << "\"prefix\":\"" << model_name << "\",\n";
os << "\"date\":\"" << date.str() << "\",\n";

os << "\"functions\":[\n],\n";
os << "\"profileBlocks\":[\n";

for(unsigned i=0;i<times.size();++i)
{
os << "{\"id\":" << i << ",\"ncall\":" << times[i].num_calcs << ",\"time\":" << times[i].sum_time
<< ",\"maxTime\":" << times[i].max_time << "},\n";
}
os << "]\n}";
os.close();
}

MeasureTime * MeasureTime::instance = 0;

unsigned long long RDTSC_MeasureTime::getTimeP()
{
return RDTSC();
return RDTSC();
}

void RDTSC_MeasureTime::initialize()
{
instance = new RDTSC_MeasureTime();
instance = new RDTSC_MeasureTime();
}


Expand All @@ -63,37 +63,37 @@ void RDTSC_MeasureTime::initialize()
#if defined(__i386__) || defined(__x86_64__)
unsigned long long RDTSC_MeasureTime::RDTSC()
{
return _rdtsc();
return _rdtsc();
}
#else
unsigned long long RDTSC_MeasureTime::RDTSC()
{
throw std::runtime_error("No time measurement for this processor arch.");
return 0;
throw std::runtime_error("No time measurement for this processor arch.");
return 0;
}
#endif // defined(__i386__) || defined(__x86_64__)
#else
#if defined(__i386__)
unsigned long long RDTSC_MeasureTime::RDTSC()
{
unsigned long long res;
asm volatile (".byte 0x0f, 0x31" : "=A" (res)));
return res;
unsigned long long res;
asm volatile (".byte 0x0f, 0x31" : "=A" (res)));
return res;
}

#elif defined(__x86_64__)
unsigned long long RDTSC_MeasureTime::RDTSC()
{
unsigned hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
unsigned hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
}

#else
unsigned long long RDTSC_MeasureTime::RDTSC()
{
throw std::runtime_error("No time measurement for this processor arch.");
return 0;
throw std::runtime_error("No time measurement for this processor arch.");
return 0;
}

#endif //defined(__i386__)
Expand Down

0 comments on commit 1a14a33

Please sign in to comment.