From f27958f2d08028e8a9e489db47f16d3ac6d67b1d Mon Sep 17 00:00:00 2001 From: Incardona Pietro <incardon@mpi-cbg.de> Date: Wed, 17 Nov 2021 23:39:10 +0100 Subject: [PATCH] Fixing examples --- CMakeLists.txt | 24 ++++++++++++++++++- example/Vector/1_gpu_first_step/Makefile | 3 +-- .../Vector/3_molecular_dynamic_gpu/Makefile | 2 +- example/Vector/7_SPH_dlb_gpu/Makefile | 2 +- example/Vector/7_SPH_dlb_gpu_opt/Makefile | 4 ++-- example/Vector/7_SPH_dlb_gpu_opt/main.cu | 1 + install | 2 -- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dde2346c4..827dc37b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,24 @@ if (OPENMP_FOUND) set(DEFINE_HAVE_OPENMP "#define HAVE_OPENMP") endif() +macro(getAllLinkedLibraries iTarget iReturnValue) + if(NOT TARGET ${iTarget}) + message(WARNING "${iTarget} is not a target") + else() + get_target_property(path ${iTarget} LOCATION) + if(NOT ${path} IN_LIST ${iReturnValue}) + if (NOT ${path} STREQUAL "path-NOTFOUND") + list(APPEND ${iReturnValue} ${path}) + endif() + endif() + get_target_property(linkedLibrairies ${iTarget} INTERFACE_LINK_LIBRARIES) + if(NOT "${linkedLibrairies}" STREQUAL "") + FOREACH(linkedLibrary ${linkedLibrairies}) + getAllLinkedLibraries(${linkedLibrary} ${iReturnValue}) + ENDFOREACH() + endif() + endif() +endmacro() if(MPI_FOUND) get_filename_component(OPENFPM_MPI_DEP "${MPI_C_INCLUDE_DIRS}" DIRECTORY) @@ -180,7 +198,11 @@ if (Boost_FOUND) file(WRITE error_code "202") message( FATAL_ERROR "BOOST is invalid reinstalling" ) endif() - file(WRITE optional_boost_libs "${OPTIONAL_BOOST_LIBS}") + # Get the library names + getAllLinkedLibraries(Boost::context OPENFPM_CONTEXT_LIBS) + getAllLinkedLibraries(Boost::fiber OPENFPM_CONTEXT_LIBS) + string (REPLACE ";" " " OPENFPM_CONTEXT_LIBS "${OPENFPM_CONTEXT_LIBS}") + file(WRITE optional_boost_libs "${OPENFPM_CONTEXT_LIBS}") else() file(WRITE error_code "202") message( FATAL_ERROR "BOOST is required in order to install OpenFPM" ) diff --git a/example/Vector/1_gpu_first_step/Makefile b/example/Vector/1_gpu_first_step/Makefile index 5234dece5..95cd7ef02 100644 --- a/example/Vector/1_gpu_first_step/Makefile +++ b/example/Vector/1_gpu_first_step/Makefile @@ -1,5 +1,4 @@ include ../../example.mk -LIBS_CUDA_ON_CPU=$(LIBS) CUDA_CC= CC=mpic++ @@ -13,7 +12,7 @@ else CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) INCLUDE_PATH_NVCC= CUDA_OPTIONS=-DCUDA_ON_CPU -D__NVCC__ -DCUDART_VERSION=11000 - LIBS_SELECT=$(LIBS_CUDA_ON_CPU) + LIBS_SELECT=$(LIBS) else ifeq (, $(shell which nvcc)) CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) diff --git a/example/Vector/3_molecular_dynamic_gpu/Makefile b/example/Vector/3_molecular_dynamic_gpu/Makefile index 43a60ef14..09de80fcb 100644 --- a/example/Vector/3_molecular_dynamic_gpu/Makefile +++ b/example/Vector/3_molecular_dynamic_gpu/Makefile @@ -8,7 +8,7 @@ ifdef CUDA_ON_CPU CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) INCLUDE_PATH_NVCC= CUDA_CC_LINK=mpic++ - LIBS_SELECT=$(LIBS_CUDA_ON_CPU) + LIBS_SELECT=$(LIBS) else ifeq (, $(shell which nvcc)) CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) diff --git a/example/Vector/7_SPH_dlb_gpu/Makefile b/example/Vector/7_SPH_dlb_gpu/Makefile index b4ebc3431..5b81687f4 100644 --- a/example/Vector/7_SPH_dlb_gpu/Makefile +++ b/example/Vector/7_SPH_dlb_gpu/Makefile @@ -18,7 +18,7 @@ else INCLUDE_PATH_NVCC= CUDA_CC_LINK=mpic++ CUDA_OPTIONS=-DCUDA_ON_CPU -D__NVCC__ -DCUDART_VERSION=11000 - LIBS_SELECT=$(LIBS_CUDA_ON_CPU) + LIBS_SELECT=$(LIBS) else ifeq (, $(shell which nvcc)) CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) diff --git a/example/Vector/7_SPH_dlb_gpu_opt/Makefile b/example/Vector/7_SPH_dlb_gpu_opt/Makefile index e5b464ed3..4bef27170 100644 --- a/example/Vector/7_SPH_dlb_gpu_opt/Makefile +++ b/example/Vector/7_SPH_dlb_gpu_opt/Makefile @@ -15,8 +15,8 @@ else CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) INCLUDE_PATH_NVCC= CUDA_CC_LINK=mpic++ - CUDA_OPTIONS=-DCUDA_ON_CPU -D__NVCC__ -DCUDART_VERSION=11000 - LIBS_SELECT=$(LIBS_CUDA_ON_CPU) + CUDA_OPTIONS=-D__NVCC__ -DCUDART_VERSION=11000 + LIBS_SELECT=$(LIBS) else ifeq (, $(shell which nvcc)) CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH) diff --git a/example/Vector/7_SPH_dlb_gpu_opt/main.cu b/example/Vector/7_SPH_dlb_gpu_opt/main.cu index 8dc98d604..1392b2ddf 100644 --- a/example/Vector/7_SPH_dlb_gpu_opt/main.cu +++ b/example/Vector/7_SPH_dlb_gpu_opt/main.cu @@ -890,6 +890,7 @@ int main(int argc, char* argv[]) { Vcluster<> & v_cl = create_vcluster(); timer it_time; + it_time.start(); ////// Do rebalancing every 200 timesteps it_reb++; diff --git a/install b/install index 26549a3e0..d7f8e4411 100755 --- a/install +++ b/install @@ -446,10 +446,8 @@ if [ x"$cuda_on_cpu" == x"YES" ]; then fi if [ x"$gpu_support" == x"1" ]; then echo "LIBS=$mpi_libs -lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $(cat cuda_lib) $lin_alg_lib -ldl -lboost_filesystem -lboost_system" >> example.mk - echo "LIBS_CUDA_ON_CPU=-lvcluster_cuda_on_cpu -lofpmmemory_cuda_on_cpu -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $(cat cuda_lib) $lin_alg_lib -lboost_filesystem -lboost_system -lboost_context" >> example.mk else echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $lin_alg_lib -ldl -lboost_filesystem -lboost_system $optional_boost" >> example.mk - echo "LIBS_CUDA_ON_CPU=\$(LIBS)" >> example.mk fi echo "INCLUDE_PATH_NVCC=-Xcompiler="-Wno-deprecated-declarations" $(cat openmp_flags) "$(cat cuda_options)" $mpi_include_dirs -I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include $lin_alg_inc -I$i_dir/BLITZ/include -I$i_dir/ALGOIM/include" >> example.mk cp example.mk src/example.mk -- GitLab