From 8781aa27b621ea31d82b37b44a9d281572afaf4b Mon Sep 17 00:00:00 2001 From: PBerger Date: Thu, 27 Feb 2014 14:45:12 +0100 Subject: [PATCH] Added cudaForStorm as a dynamic library extension Former-commit-id: 31c6be4c1c5a05bfbed018ae6f3a4c6bbb918bfa --- CMakeLists.txt | 24 +++++++++++++++++++++++ resources/cudaForStorm/CMakeLists.txt | 15 ++++++++------ resources/cudaForStorm/src/cudaForStorm.h | 15 ++++++++++++++ resources/cudaForStorm/src/main.cpp | 9 ++++++++- storm-config.h.in | 3 +++ 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 resources/cudaForStorm/src/cudaForStorm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fbc351e4..1e6227e6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precom option(LINK_LIBCXXABI "Sets whether libc++abi should be linked." OFF) option(USE_LIBCXX "Sets whether the standard library is libc++." OFF) option(ENABLE_GLPK "Sets whether StoRM is built with support for glpk." OFF) +option(ENABLE_CUDAFORSTORM "Sets whether StoRM is built with its CUDA extension." OFF) set(GUROBI_ROOT "" CACHE STRING "The root directory of Gurobi (if available).") set(Z3_ROOT "" CACHE STRING "The root directory of Z3 (if available).") set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.") @@ -183,6 +184,13 @@ else() set(STORM_CPP_GLPK_DEF "undef") endif() +# CUDA Defines +if (ENABLE_CUDAFORSTORM) + set(STORM_CPP_CUDAFORSTORM_DEF "define") +else() + set(STORM_CPP_CUDAFORSTORM_DEF "undef") +endif() + # Z3 Defines if (ENABLE_Z3) set(STORM_CPP_Z3_DEF "define") @@ -286,6 +294,9 @@ endif() if (ENABLE_Z3) link_directories("${Z3_ROOT}/bin") endif() +if (ENABLE_CUDAFORSTORM) + link_directories("${PROJECT_SOURCE_DIR}/build/cudaForStorm/lib") +endif() if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL "")) set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib") endif () @@ -317,6 +328,19 @@ target_link_libraries(storm-performance-tests ${Boost_LIBRARIES}) #message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}") #message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}") +############################################################# +## +## CUDA For Storm +## +############################################################# +if (ENABLE_CUDAFORSTORM) + message (STATUS "StoRM - Linking with CudaForStorm") + include_directories("${PROJECT_SOURCE_DIR}/build/cudaForStorm/include") + target_link_libraries(storm cudaForStorm) + target_link_libraries(storm-functional-tests cudaForStorm) + target_link_libraries(storm-performance-tests cudaForStorm) +endif(ENABLE_CUDAFORSTORM) + ############################################################# ## ## CUDD diff --git a/resources/cudaForStorm/CMakeLists.txt b/resources/cudaForStorm/CMakeLists.txt index 1b01ca337..ab2c2c8c7 100644 --- a/resources/cudaForStorm/CMakeLists.txt +++ b/resources/cudaForStorm/CMakeLists.txt @@ -27,6 +27,7 @@ set(GUROBI_ROOT "" CACHE STRING "The root directory of Gurobi (if available).") set(Z3_ROOT "" CACHE STRING "The root directory of Z3 (if available).") set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.") set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.") +set(STORM_LIB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/../../build/cudaForStorm" CACHE STRING "The Build directory of storm, where the library files should be installed to (if available).") ############################################################# ## @@ -258,11 +259,11 @@ endif() # Since this will be a library include (GenerateExportHeader) -add_library(cudaForStorm STATIC ${CUDAFORSTORM_HEADERS} ${CUDAFORSTORM_SOURCES}) +add_library(cudaForStorm SHARED ${CUDAFORSTORM_HEADERS} ${CUDAFORSTORM_SOURCES}) GENERATE_EXPORT_HEADER( cudaForStorm BASE_NAME cudaForStorm EXPORT_MACRO_NAME cudaForStorm_EXPORT - EXPORT_FILE_NAME cudaForStorm_Export.h + EXPORT_FILE_NAME include/cudaForStorm_Export.h STATIC_DEFINE cudaForStorm_BUILT_AS_STATIC ) @@ -333,7 +334,9 @@ endif(MSVC) # Link against libc++abi if requested. May be needed to build on Linux systems using clang. if (LINK_LIBCXXABI) message (STATUS "StoRM - Linking against libc++abi.") - target_link_libraries(storm "c++abi") - target_link_libraries(storm-functional-tests "c++abi") - target_link_libraries(storm-performance-tests "c++abi") -endif(LINK_LIBCXXABI) \ No newline at end of file + target_link_libraries(cudaForStorm "c++abi") +endif(LINK_LIBCXXABI) + +# Install Directive +install(TARGETS cudaForStorm DESTINATION "${STORM_LIB_INSTALL_DIR}/lib") +install(FILES "${PROJECT_SOURCE_DIR}/src/cudaForStorm.h" "${PROJECT_BINARY_DIR}/cudaForStorm_Export.h" DESTINATION "${STORM_LIB_INSTALL_DIR}/include") \ No newline at end of file diff --git a/resources/cudaForStorm/src/cudaForStorm.h b/resources/cudaForStorm/src/cudaForStorm.h new file mode 100644 index 000000000..ebcb4eaa2 --- /dev/null +++ b/resources/cudaForStorm/src/cudaForStorm.h @@ -0,0 +1,15 @@ +#ifndef STORM_CUDAFORSTORM_CUDAFORSTORM_H_ +#define STORM_CUDAFORSTORM_CUDAFORSTORM_H_ + +// Library exports +#include "cudaForStorm_Export.h" + +/* + * List of exported functions in this library + */ + +cudaForStorm_EXPORT int cudaForStormTest(int value); + + + +#endif // STORM_CUDAFORSTORM_CUDAFORSTORM_H_ \ No newline at end of file diff --git a/resources/cudaForStorm/src/main.cpp b/resources/cudaForStorm/src/main.cpp index 52f1d1678..b555cd103 100644 --- a/resources/cudaForStorm/src/main.cpp +++ b/resources/cudaForStorm/src/main.cpp @@ -1,3 +1,5 @@ +#include "cudaForStorm.h" + #include #include @@ -7,7 +9,12 @@ #include "cudaTests.h" -int main(int argc, char **argv){ +int cudaForStormTest(int value) { + return value + 42; +} + + +int main_Test12345(int argc, char **argv){ resetCudaDevice(); int testNumber = 0; diff --git a/storm-config.h.in b/storm-config.h.in index d44ae122c..101928b59 100644 --- a/storm-config.h.in +++ b/storm-config.h.in @@ -22,6 +22,9 @@ // Whether GLPK is available and to be used (define/undef) #@STORM_CPP_GLPK_DEF@ STORM_HAVE_GLPK +// Whether CudaForStorm is available and to be used (define/undef) +#@STORM_CPP_CUDAFORSTORM_DEF@ STORM_HAVE_CUDAFORSTORM + // Whether Z3 is available and to be used (define/undef) #@STORM_CPP_Z3_DEF@ STORM_HAVE_Z3