Skip to content

Commit

Permalink
Merge pull request GOMC-WSU#358 from GregorySchwing/chk
Browse files Browse the repository at this point in the history
Native header only serialization library used if boost not found
  • Loading branch information
GregorySchwing authored Aug 20, 2021
2 parents 84d1062 + 6abfd80 commit c7a7270
Show file tree
Hide file tree
Showing 211 changed files with 51,142 additions and 32 deletions.
15 changes: 10 additions & 5 deletions CMake/FindBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#
# BOOST_USE_STATIC_LIBS : boolean (default: OFF)

option(CMAKE_DOWNLOAD_BOOST "Download and build the boost library" OFF)

if(NOT Boost_FIND_COMPONENTS)
message(FATAL_ERROR "No COMPONENTS specified for Boost")
endif()
Expand Down Expand Up @@ -155,20 +157,23 @@ macro(DO_FIND_BOOST_DOWNLOAD)
)
mark_as_advanced(BOOST_LIBRARIES BOOST_INCLUDE_DIRS)
message(STATUS "Finished Downloading Boost")

set(GOMC_BOOST_LIB CACHE 1
"Build a Boost-enabled version of GOMC" FORCE)
endmacro()


if(NOT BOOST_FOUND)
DO_FIND_BOOST_ROOT()
DO_FIND_BOOST_SYSTEM()
endif()

if(NOT BOOST_FOUND)
DO_FIND_BOOST_SYSTEM()
DO_FIND_BOOST_ROOT()
endif()

if(NOT BOOST_FOUND)
message(STATUS "Downloading Boost")
DO_FIND_BOOST_DOWNLOAD()
if(CMAKE_DOWNLOAD_BOOST)
message(STATUS "Downloading Boost")
DO_FIND_BOOST_DOWNLOAD()
endif()
endif()

36 changes: 28 additions & 8 deletions CMake/GOMCCPUSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)

if(ENSEMBLE_NVT)
add_executable(NVT ${sources} ${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
add_executable(NVT ${sources} ${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(NVT PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(NVT PROPERTIES
OUTPUT_NAME ${NVT_name}
COMPILE_FLAGS "${NVT_flags}")
Expand All @@ -31,11 +34,16 @@ if(ENSEMBLE_NVT)
if(MPI_FOUND)
target_link_libraries(NVT ${MPI_LIBRARIES})
endif()
target_link_libraries( NVT ${BOOST_LIBRARIES} )
if(Boost_FOUND)
target_link_libraries(NVT ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GEMC)
add_executable(GEMC ${sources} ${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
add_executable(GEMC ${sources} ${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GEMC PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GEMC PROPERTIES
OUTPUT_NAME ${GE_name}
COMPILE_FLAGS "${GE_flags}")
Expand All @@ -46,11 +54,16 @@ if(ENSEMBLE_GEMC)
if(MPI_FOUND)
target_link_libraries(GEMC ${MPI_LIBRARIES})
endif()
target_link_libraries(GEMC ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GEMC ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GCMC)
add_executable(GCMC ${sources} ${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
add_executable(GCMC ${sources} ${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GCMC PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GCMC PROPERTIES
OUTPUT_NAME ${GC_name}
COMPILE_FLAGS "${GC_flags}")
Expand All @@ -61,11 +74,16 @@ if(ENSEMBLE_GCMC)
if(MPI_FOUND)
target_link_libraries(GCMC ${MPI_LIBRARIES})
endif()
target_link_libraries(GCMC ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GCMC ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_NPT)
add_executable(NPT ${sources} ${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
add_executable(NPT ${sources} ${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(NPT PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(NPT PROPERTIES
OUTPUT_NAME ${NPT_name}
COMPILE_FLAGS "${NPT_flags}")
Expand All @@ -76,6 +94,8 @@ if(ENSEMBLE_NPT)
if(MPI_FOUND)
target_link_libraries(NPT ${MPI_LIBRARIES})
endif()
target_link_libraries(NPT ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(NPT ${BOOST_LIBRARIES})
endif()
endif()

36 changes: 28 additions & 8 deletions CMake/GOMCCUDASetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
#####################################
if(ENSEMBLE_GPU_NVT)
add_executable(GPU_NVT ${cudaSources} ${cudaHeaders}
${sources} ${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
${sources} ${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GPU_NVT PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GPU_NVT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NVT_name}
Expand All @@ -54,12 +57,17 @@ if(ENSEMBLE_GPU_NVT)
if(MPI_FOUND)
target_link_libraries(GPU_NVT ${MPI_LIBRARIES})
endif()
target_link_libraries(GPU_NVT ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GPU_NVT ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GEMC)
add_executable(GPU_GEMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GPU_GEMC PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GPU_GEMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GE_name}
Expand All @@ -74,12 +82,17 @@ if(ENSEMBLE_GPU_GEMC)
if(MPI_FOUND)
target_link_libraries(GPU_GEMC ${MPI_LIBRARIES})
endif()
target_link_libraries(GPU_GEMC ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GPU_GEMC ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GCMC)
add_executable(GPU_GCMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GPU_GCMC PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GPU_GCMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GC_name}
Expand All @@ -94,12 +107,17 @@ if(ENSEMBLE_GPU_GCMC)
if(MPI_FOUND)
target_link_libraries(GPU_GCMC ${MPI_LIBRARIES})
endif()
target_link_libraries(GPU_GCMC ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GPU_GCMC ${BOOST_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_NPT)
add_executable(GPU_NPT ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
${headers} ${libHeaders} ${libSources})
if(Boost_FOUND)
target_sources(GPU_NPT PRIVATE ${BOOST_INCLUDE_DIRS})
endif()
set_target_properties(GPU_NPT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NPT_name}
Expand All @@ -114,5 +132,7 @@ if(ENSEMBLE_GPU_NPT)
if(MPI_FOUND)
target_link_libraries(GPU_NPT ${MPI_LIBRARIES})
endif()
target_link_libraries(GPU_NPT ${BOOST_LIBRARIES})
if(Boost_FOUND)
target_link_libraries(GPU_NPT ${BOOST_LIBRARIES})
endif()
endif()
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ if(Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${BOOST_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${BOOST_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION_STRING}")
set(GOMC_BOOST_LIB CACHE 1
"Build a Boost-enabled version of GOMC" FORCE)
include_directories(${BOOST_INCLUDE_DIRS})
else()
message(STATUS "Using native checkpointing. To download boost -DCMAKE_DOWNLOAD_BOOST=ON")
include_directories(lib/cereal-1.3.0/include)
endif()

include_directories(${BOOST_INCLUDE_DIRS})

# Enable google test
# for now we will disable testing for intel compiler
Expand Down
5 changes: 4 additions & 1 deletion GOMC_Config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
#define GOMC_MPI (GOMC_LIB_MPI || GOMC_THREAD_MPI)

/* MPI_IN_PLACE exists for collective operations */
#cmakedefine01 MPI_IN_PLACE_EXISTS
#cmakedefine01 MPI_IN_PLACE_EXISTS

/* Boost serialization library exists for checkpointing */
#cmakedefine01 GOMC_BOOST_LIB
84 changes: 84 additions & 0 deletions lib/cereal-1.3.0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
cmake_minimum_required (VERSION 2.6.2)
project (cereal)

option(SKIP_PORTABILITY_TEST "Skip portability (32 bit) tests" OFF)
option(SKIP_PERFORMANCE_COMPARISON "Skip building performance comparison (requires boost)" OFF)
if(NOT CMAKE_VERSION VERSION_LESS 3.0) # installing cereal requires INTERFACE lib
option(JUST_INSTALL_CEREAL "Don't do anything besides installing the library" OFF)
endif()

option(THREAD_SAFE "Use mutexes to ensure thread safety" OFF)
if(THREAD_SAFE)
add_definitions(-DCEREAL_THREAD_SAFE=1)
set(CEREAL_THREAD_LIBS "pthread")
else()
set(CEREAL_THREAD_LIBS "")
endif()

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /W3 /WX")
else()
set(CMAKE_CXX_FLAGS "-Wall -g -Wextra -Wshadow -pedantic -Wold-style-cast ${CMAKE_CXX_FLAGS}")
option(WITH_WERROR "Compile with '-Werror' C++ compiler flag" ON)
if(WITH_WERROR)
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
endif(WITH_WERROR)

option(CLANG_USE_LIBCPP "Use libc++ for clang compilation" OFF)
if(CLANG_USE_LIBCPP)
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif()

if(CMAKE_VERSION VERSION_LESS 3.1)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
else()
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD STREQUAL "98")
set(CMAKE_CXX_STANDARD 11)
endif()

if(CMAKE_CXX_STANDARD GREATER 14)
cmake_minimum_required(VERSION 3.8)
endif()

set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

endif()

if(NOT CMAKE_VERSION VERSION_LESS 3.0)
add_library(cereal INTERFACE)
target_include_directories(cereal INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS cereal EXPORT cereal
DESTINATION lib) # ignored
install(EXPORT cereal FILE cereal-config.cmake
DESTINATION share/cmake/cereal)
install(DIRECTORY include/cereal DESTINATION include)
endif()

if(JUST_INSTALL_CEREAL)
return()
endif()

include_directories(./include)

if(NOT CMAKE_VERSION VERSION_LESS 3.12)
cmake_policy(VERSION 3.12)
endif()

# Boost serialization for performance sandbox
find_package(Boost COMPONENTS serialization)

if(Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)

enable_testing()
add_subdirectory(unittests)

add_subdirectory(sandbox)

add_subdirectory(doc)
24 changes: 24 additions & 0 deletions lib/cereal-1.3.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2014, Randolph Voorhies, Shane Grant
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of cereal nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit c7a7270

Please sign in to comment.