Skip to content

Commit

Permalink
- included cjson into build and HpcOmBenchmarkExt.cpp
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20442 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Marcus Walther committed May 7, 2014
1 parent d1b2327 commit c6d05d8
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Compiler/omc_release/Makefile.in
Expand Up @@ -42,7 +42,7 @@ ifdef USE_GRAPH
endif
endif

LDFLAGS = @LDFLAGS@ -lm -L$(RMLHOME)/lib/plain -lrml $(GRAPHSTREAMLIB) $(LIBSOCKET) $(CORBALIBS) $(LIBLPSOLVE55) $(METISLIB) $(PATOHLIB) -L../../build/lib/omc @RPATH@ @OMC_LIBS@ -lgc -lexpat @RT_LDFLAGS@
LDFLAGS = @LDFLAGS@ -lm -L$(RMLHOME)/lib/plain -lrml $(GRAPHSTREAMLIB) $(LIBSOCKET) $(CORBALIBS) $(LIBLPSOLVE55) $(METISLIB) $(PATOHLIB) -L../../build/lib/omc @RPATH@ @OMC_LIBS@ -lgc -lexpat -lcjson @RT_LDFLAGS@

PROG = omc
RMLC = @rmlc_bin@
Expand Down
74 changes: 46 additions & 28 deletions Compiler/runtime/HpcOmBenchmarkExt.cpp
Expand Up @@ -27,6 +27,7 @@
#include <sstream>
#include <stdio.h>
#include <fstream>
#include "cJSON.h"

struct Equation {
int id;
Expand Down Expand Up @@ -335,35 +336,52 @@ class XmlBenchReader {

std::list<std::list<double> > ReadJsonBenchFileEquations(std::string filePath)
{
std::list<std::list<double> > resultList = std::list<std::list<double> >();
// boost::property_tree::ptree pt;
//
// std::ifstream fileStream(filePath.c_str());
//
// if(fileStream)
// {
// std::stringstream stringStream;
// stringStream << fileStream.rdbuf();
// boost::property_tree::read_json(stringStream, pt);
//
// BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("profileBlocks"))
// {
// std::list<double> tmpLst = std::list<double>();
// assert(v.first.empty());
// double id = v.second.get<double>("id");
// double ncall = v.second.get<double>("ncall");
// double time = v.second.get<double>("time");
// //std::cerr << "id: " << id << " ncall: " << ncall << " time: " << time << std::endl;
// tmpLst.push_back(id);
// tmpLst.push_back(time);
// tmpLst.push_back(ncall);
// resultList.push_back(tmpLst);
// }
//
// fileStream.close();
// }
std::list<std::list<double> > resultList = std::list<std::list<double> >();

FILE *fp;
long lSize;
char *buffer;
int arraySize, i;
cJSON *root;
cJSON *profileBlocks;

fp = fopen ( filePath.c_str() , "rb" );
if( !fp ) perror(filePath.c_str()),exit(1);

fseek( fp , 0L , SEEK_END);
lSize = ftell( fp );
rewind( fp );

/* allocate memory for entire content */
buffer = (char*)calloc( 1, lSize+1 );
if( !buffer ) fclose(fp),fputs("memory alloc fails",stderr),exit(1);

/* copy the file into the buffer */
if( 1!=fread( buffer , lSize, 1 , fp) )
fclose(fp),free(buffer),fputs("entire read fails",stderr),exit(1);

/* do your work here, buffer is a string contains the whole text */
root = cJSON_Parse(buffer);
profileBlocks = cJSON_GetObjectItem(root,"profileBlocks");
arraySize = cJSON_GetArraySize(profileBlocks);
for(i = 0; i < arraySize; i++)
{
cJSON *item = cJSON_GetArrayItem(profileBlocks, i);
cJSON *idItem = cJSON_GetObjectItem(item, "id");
cJSON *ncallItem = cJSON_GetObjectItem(item, "ncall");
cJSON *timeItem = cJSON_GetObjectItem(item, "time");
std::list<double> tmpLst = std::list<double>();

tmpLst.push_back(idItem->valuedouble);
tmpLst.push_back(timeItem->valuedouble);
tmpLst.push_back(ncallItem->valuedouble);
resultList.push_back(tmpLst);
}

fclose(fp);
free(buffer);

return resultList;
return resultList;
}

void* HpcOmBenchmarkExtImpl__readCalcTimesFromXml(const char *filename)
Expand Down
5 changes: 3 additions & 2 deletions Makefile.common
Expand Up @@ -49,7 +49,7 @@ mkbuilddirs:

release: omc-diff omc

bootstrap-dependencies: omc-diff interactive docs fmi fmil opencl_rt lis graphstream
bootstrap-dependencies: omc-diff interactive docs fmi fmil opencl_rt lis graphstream cjson
# NOTE: OpenModelicaBootstrappingHeader.h has to be regenerated without any other process writing to so/etc or you get bus errors
$(MAKE) -C Compiler OpenModelicaBootstrappingHeader.h
$(MAKE) -C Compiler/runtime install
Expand Down Expand Up @@ -189,6 +189,7 @@ qjson:
test "(" ! `uname` = Darwin ")" -o "(" ! -f 3rdParty/qjson-0.8.1/build/lib/libqjson$(SHREXT) ")" || install_name_tool -id @rpath/libqjson$(SHREXT) 3rdParty/qjson-0.8.1/build/lib/libqjson$(SHREXT)
cp -a 3rdParty/qjson-0.8.1/build/lib/libqjson*$(SHREXT)* $(builddir_lib)/omc/
cp -a 3rdParty/qjson-0.8.1/src/*.h 3rdParty/qjson-0.8.1/build/include/qjson

CMinpack:
test -d 3rdParty/CMinpack
mkdir -p 3rdParty/CMinpack/build
Expand Down Expand Up @@ -313,7 +314,7 @@ bootstrap-clean:
openblas-clean:
# OpenBLAS make clean actually gives error-messages. Let it do it, but silently
$(MAKE) -C 3rdParty/OpenBLAS-0.2.8 clean > /dev/null 2>&1
clean: qtclean fmil-clean opencl_rt_clean gc-clean lis-clean runtimeCPPclean CMinpack-clean Cdaskr-clean bootstrap-clean msgpack-clean graphstream-clean openblas-clean
clean: qtclean fmil-clean opencl_rt_clean gc-clean lis-clean runtimeCPPclean CMinpack-clean Cdaskr-clean bootstrap-clean msgpack-clean graphstream-clean openblas-clean cjson-clean
(cd SimulationRuntime/c && $(MAKE) -f $(defaultMakefileTarget) clean)
(cd SimulationRuntime/interactive && $(MAKE) -f $(defaultMakefileTarget) clean)
(cd Compiler && $(MAKE) -f $(defaultMakefileTarget) clean)
Expand Down
7 changes: 7 additions & 0 deletions Makefile.in
Expand Up @@ -217,3 +217,10 @@ emcc: msl-external-libs-emcc emcc-simulationruntime
emcc-simulationruntime:
mkdir -p build/lib/omc/emcc/
$(MAKE) -C SimulationRuntime/c emcc

cjson:
cd 3rdParty/cJSON && ./configure && $(MAKE)
cp 3rdParty/cJSON/libcjson.so build/lib/omc/

cjson-clean:
cd 3rdParty/cJSON && $(MAKE) clean

0 comments on commit c6d05d8

Please sign in to comment.