Commit 19982f2d authored by Sonja Kolen's avatar Sonja Kolen

renaming repasthpc-simulator folder to distaix

parents
cmake_minimum_required(VERSION 2.8.1)
project(repasthpc_simulator)
#TO SWITCH BETWEEN DATABASE USAGE AND NON DATABASE USAGE
# NO_DB = 1: Cassandra, PostreSQL and Protobuf dependencies will not be compiled and are NOT available in the executable
# NO_DB = 0: all database features are compiled
#set(NO_DB "0")
if(${NO_DB} MATCHES "0")
#add a define to use in the code if database stuff shall be compiled
add_definitions(-DUSE_DB)
endif(${NO_DB} MATCHES "0")
#TO SWITCH BETWEEN CUDA AND NON CUDA COMPILE USE THE FOLLOWING VARIABLE
# USE_CUDA = 1: CUDA is used
# USE_CUDE = 0: CUDA is NOT used
#set(USE_CUDA "0")
#aux_source_directory(./src SRC_LIST)
file(GLOB_RECURSE SRC_LIST ./src/*.cpp)
if(${NO_DB} MATCHES "0")
# list of proto file sources
aux_source_directory(libs/protobuf/cpp SRC_LIST_PROTO)
if(NOT SRC_LIST_PROTO)
MESSAGE(FATAL_ERROR "You need to run 'make local' or 'make cluster' in the folder ./libs/protobuf/ before compiling can be successful!")
endif(NOT SRC_LIST_PROTO)
endif(${NO_DB} MATCHES "0")
#find MPI library
MESSAGE(
STATUS
"Checking for working MPI library..."
)
find_package(MPI REQUIRED)
#determine operating system
execute_process(COMMAND uname -a OUTPUT_VARIABLE UNAME)
MESSAGE(STATUS
"Checking OS Distribution...")
#set boost directories for cluster execution
if(NOT ${UNAME} MATCHES "(U|u)buntu")
#running on Centos in cluster with global boost installation
set(Boost_NO_BOOST_CMAKE TRUE)
set(Boost_NO_SYSTEM_PATHS TRUE)
set(BOOST_ROOT "/global/cluster/centos/boost_1_61_0_gcc_6.2.0")
set(BOOST_INCLUDE_DIRS "${BOOST_ROOT}/include")
set(BOOST_LIBRARY_DIRS "${BOOST_ROOT}/lib")
endif(NOT ${UNAME} MATCHES "(U|u)buntu")
MESSAGE(
STATUS
"Checking for boost libraries and includes..."
)
#find boost libraries
find_package(Boost REQUIRED COMPONENTS serialization system filesystem mpi)
#set compiler and compiler flags
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
MESSAGE(
STATUS
"cxx flags: "
${CMAKE_CXX_FLAGS}
" | cxx debug flags: "
${CMAKE_CXX_FLAGS_DEBUG}
" | cxx release flags: "
${CMAKE_CXX_FLAGS_RELEASE}
)
MESSAGE(
STATUS
"Boost include directories: "
${Boost_INCLUDE_DIRS}
)
MESSAGE(
STATUS
"MPI include paths: "
${MPI_CXX_INCLUDE_PATH}
)
MESSAGE(
STATUS
"MPI CXX Libraries: "
${MPI_CXX_LIBRARIES}
)
#find database related libs only if DB stuff shall be compiled
if(${NO_DB} MATCHES "0")
find_library(DATABASE_LIB dbconnector HINTS libs/dbconnector)
if(${DATABASE_LIB} MATCHES "DATABASE_LIB-NOTFOUND")
MESSAGE(FATAL_ERROR "You need to execute 'make buildlib' in the folder ./libs/dbconnector/ to compile the dbconnector library required here. Aborting.")
endif(${DATABASE_LIB} MATCHES "DATABASE_LIB-NOTFOUND")
find_library(CASSANDRA_LIB cassandra HINTS /global/cluster/centos/cassandra-cpp-driver/lib)
find_library(PQ_LIB pq)
endif(${NO_DB} MATCHES "0")
#find GNU scientific library (GSL)
find_library(GSL_LIB gsl)
find_library(GSLCBLAS_LIB gslcblas)
if(NOT ${UNAME} MATCHES "(U|u)buntu")
#include directories for Centos cluster
if(${NO_DB} MATCHES "0")
#include directories with DB
include_directories(
SYSTEM include
${MPI_CXX_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
/usr/include/postgresql/
/global/cluster/centos/repast_hpc_2.2/include
./include
libs/dbconnector/include
/global/cluster/centos/cassandra-cpp-driver/include
libs/protobuf/cpp
/global/cluster/centos/protobuf_3.3.0/include
)
find_library(PROTOBUF_LIB protobuf HINTS /global/cluster/centos/protobuf_3.3.0/lib/)
MESSAGE(
STATUS
"Protobuf Library: "
${PROTOBUF_LIB}
)
else(${NO_DB} MATCHES "0")
#include directories without DB
include_directories(
SYSTEM include
${MPI_CXX_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
/global/cluster/centos/repast_hpc_2.2/include
./include
)
endif(${NO_DB} MATCHES "0")
#find repasthpc library in cluster
find_library(REPASTHPC_LIB repast_hpc-2.2 HINTS /global/cluster/centos/repast_hpc_2.2/lib/)
else(NOT ${UNAME} MATCHES "(U|u)buntu")
#include directories for Ubuntu (no global MPI and RepastHPC)
if(${NO_DB} MATCHES "0")
#include directories with DB
include_directories(
SYSTEM include
${MPI_CXX_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
/usr/include/postgresql/
/usr/include/repast_hpc/repast_hpc-2.2.0/
./include
libs/dbconnector/include
/global/cluster/centos/cassandra-cpp-driver/include
libs/protobuf/cpp
../tools/docker/build/protobuf_dist/include
)
find_library(PROTOBUF_LIB protobuf HINTS ../tools/docker/build/protobuf_dist/lib)
MESSAGE(
STATUS
"Protobuf Library: "
${PROTOBUF_LIB}
)
else(${NO_DB} MATCHES "0")
#include directories without DB
include_directories(
SYSTEM include
${MPI_CXX_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
/usr/include/repast_hpc/repast_hpc-2.2.0/
./include
)
endif(${NO_DB} MATCHES "0")
#find repasthpc library on ubuntu
find_library(REPASTHPC_LIB repast_hpc-2.2.0)
endif(NOT ${UNAME} MATCHES "(U|u)buntu")
if(${USE_CUDA} MATCHES "1")
add_definitions(-DUSE_GPU)
#add cuda-solver and cuda system include dirs
include_directories(./libs/cuda-solver/include
/usr/local/cuda-9.1/include)
#find cuda-solver library
find_library(CUDASOLVER_LIB cuda-solver HINTS ./libs/cuda-solver/lib)
if(${CUDASOLVER_LIB} MATCHES "CUDASOLVER_LIB-NOTFOUND")
MESSAGE(
FATAL_ERROR "You need to execute 'make' in the folder ./libs/cuda-solver to compile the cuda-solver library required here. Aborting."
)
endif(${CUDASOLVER_LIB} MATCHES "CUDASOLVER_LIB-NOTFOUND")
MESSAGE(
STATUS
"cuda-solver Library: "
${CUDASOLVER_LIB}
)
#find cuda system library
find_library(CUDART_LIB cudart HINTS /usr/local/cuda-9.1/lib64)
MESSAGE(
STATUS
"CUDART Library: "
${CUDART_LIB}
)
endif(${USE_CUDA} MATCHES "1")
#use protobuf source files only if DB is activated
if(${NO_DB} MATCHES "0")
add_executable(repasthpc_simulator ${SRC_LIST} ${SRC_LIST_PROTO})
else(${NO_DB} MATCHES "0")
add_executable(repasthpc_simulator ${SRC_LIST})
endif(${NO_DB} MATCHES "0")
if(${USE_CUDA} MATCHES "1")
# link also to CUDA libs if CUDA is used
if(${NO_DB} MATCHES "0")
target_link_libraries(
repasthpc_simulator
${Boost_LIBRARIES}
${REPASTHPC_LIB}
${DATABASE_LIB}
${PQ_LIB}
${GSL_LIB}
${GSLCBLAS_LIB}
${PROTOBUF_LIB}
${CASSANDRA_LIB}
${CUDASOLVER_LIB}
${CUDART_LIB}
)
else(${NO_DB} MATCHES "0")
#do not link against DB related libs if DB is not used
target_link_libraries(
repasthpc_simulator
${Boost_LIBRARIES}
${REPASTHPC_LIB}
${GSL_LIB}
${GSLCBLAS_LIB}
${CUDASOLVER_LIB}
${CUDART_LIB}
)
endif(${NO_DB} MATCHES "0")
else(${USE_CUDA} MATCHES "1")
# omit CUDA libs if CUDA is not used
if(${NO_DB} MATCHES "0")
target_link_libraries(
repasthpc_simulator
${Boost_LIBRARIES}
${REPASTHPC_LIB}
${DATABASE_LIB}
${PQ_LIB}
${GSL_LIB}
${GSLCBLAS_LIB}
${PROTOBUF_LIB}
${CASSANDRA_LIB}
)
else(${NO_DB} MATCHES "0")
#do not link against DB related libs if DB is not used
target_link_libraries(
repasthpc_simulator
${Boost_LIBRARIES}
${REPASTHPC_LIB}
${GSL_LIB}
${GSLCBLAS_LIB}
)
endif(${NO_DB} MATCHES "0")
endif(${USE_CUDA} MATCHES "1")
#additional definitions: DEBUG_OUTPUT_RANKS for output in rankx.log files
# DEBUG_OUTPUT_AGENTS for output in agent_x.log files
# DEBUG_OUTPUT_CABLES for output in cable_x.log files
# DEBUG_OUTPUT_COMMLINKS for output int commlink_x.log files
add_definitions(-DDEBUG_OUTPUT_RANKS)
# How to use the SwarmGrid Simulator
## Configure
A simulaton is configured with the [model.props](https://git.rwth-aachen.de/acs/swarmgrid/blob/master/repasthpc-simulator/props/model.props) file contained in the props folder.
These are the available parameters:
|Parameter| Possible values | Description |
|---|---|---|
|dir.scenario| folder path as string |relative path (from ``bin`` directory) to folder containing scenario files|
|dir.profiles| folder path as string |relative path (from ``bin`` directory) to folder containing profile time series files|
|file.scenario.components| file name as string|name of the file that contains the nodes and components of the scenario as well as their parameters|
|file.scenario.elgrid| file name as string|name of the file that contains all electrical connections between nodes and components as well as the properties of these connections|
|file.scenario.latency| file name as string | name of the file that contains a node to node matrix of the communication latencies in seconds. This file is only needed if use.commdata=1|
|use.commdata| 0 or 1 | Set to 1 if latency input file shall be used to model individual communication link properties. If set to 0, default values for latency and PER are used for all links|
|stop.at| integer > 0 | Number of simulation steps to execute|
|step.size|double | Size of a simulation step in seconds|
|profile.interpolation_type|hold or linear|set to linear for linear profile interpolation; set to hold to hold last profile value until next value; for EV profiles hold is always used|
|distribution_method|"evenly" or "workitem" |Set the agent distribution method. Select "evenly" for a topology-independent distribution and "workitem" for an agent-distribution depending on the topology|
|db.use|0 or 1| Set to 1 if simulation results shall be saved in a PostgreSQL database, set to 0 if no database saving is required|
|db.host|x.x.x.x (x unsigned integer)|IP adress of the PostgreSQL database|
|db.port|unsigend integer|Port of the PostgreSQL database (default: 5432)|
|db.user|username as string|Username of the PostgreSQL database (default: postgres)|
|db.pass|password as string|Password of the PostgreSQL database (default: postgres)|
|db.dbname|name as string|Name of the PostgreSQL database (default: swarmgrid)|
|cassandra.hosts|comma seperated list of IP addresses|IP addresses of all Cassandra DB hosts to be used|
|cassandra.iothreads|Integer > 0|Set number of IO threads used by Cassandra|
|db.loglevel|"normal", "verbose" or "minimal"|Set the result logging level for DB and CSV files. Select "normal" for logging of PQ data, "verbose" for additional logging of swarm specifics and "minimal" for logging of node data only|
|db.use.ranks|0 or 1|Set to 1 if time measurements of processes shall be saved as results|
|csv.use.ranks|0 or 1|set to 1 if rank results (NOT DEBUG OUTPUT) shall be saved to csv files (results/rankX.csv)|
|csv.use..agents|0 or 1|set to 1 if agent results (NOT DEBUG OUTPUT) shall be saved to csv files (results/agents/agent_X.csv)|
|csv.use.edges|0 or 1|set to 1 if edge results (NOT DEBUG OUTPUT) shall be saved to csv files (results/edges/<cable,commlink>_X.csv)|
|ctrl.type|0 or 1| set to 1 if agents shall apply their intelligent behavior, set to 0 if default behavior without agent coordination is desired|
|model.type|0 or 1|set to 1 to simulate with dynamic phasor models, set to 0 to simulate with steady state models|
DEBUG OUTPUT can be turned on and off in the [CMakeLists.txt](https://git.rwth-aachen.de/acs/swarmgrid/blob/master/repasthpc-simulator/CMakeLists.txt) file adding respective debug flags in the last line (see comment above last line in CMakeLists.txt).
There are different flags for rank, agent, and edges debug output. All debug output is saved in the folder ``runlog``.
## Compile
DistAIX uses a build system based on ``cmake``.
To compile successfully all dependencies have to be properly installed. The build system will give an error in case a library is missing.
Before compiling the simulator itself, it is required to build the DBConnector library by executing ``make buildlib`` in the folder ``libs/dbconnector``.
Furthermore, the Google Protocol Buffer Libraries need to be prepared by executing ``make`` in the folder ``libs/protobuf``.
These steps need to be done once.
Only if one of the sources for these libraries are changed, the steps need to be repeated accordingly.