diff --git a/CMakeLists.txt b/CMakeLists.txt index 1620bfd..8c872e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,12 +51,12 @@ add_subdirectory(./src/sim) # Add the sources files set(SOURCE_MODULES ${SUBCOMMAND_PHANTOM} ${SUBCOMMAND_SIM} ${SUBCOMMAND_DWI} ${SUBCOMMAND_CONFIG}) -set(SOURCE_MAIN ./src/spinwalk.cpp) +set(SOURCE_MAIN ./src/spinwalk.cu) # change extension of the files if CUDA is not found if(NOT CMAKE_CUDA_COMPILER) set(RENAMED_SOURCES) - foreach(OLD_FILE ${SOURCES}) + foreach(OLD_FILE ${SOURCE_MODULES}) # Get the file name without extension get_filename_component(DIR ${OLD_FILE} DIRECTORY) get_filename_component(FILE_NAME_WE ${OLD_FILE} NAME_WE) @@ -67,32 +67,37 @@ if(NOT CMAKE_CUDA_COMPILER) list(APPEND RENAMED_SOURCES ${NEW_FILE}) endforeach() set(SOURCE_MODULES ${RENAMED_SOURCES}) + + file(COPY_FILE ./src/spinwalk.cu ./src/spinwalk.cpp) + set(SOURCE_MAIN ./src/spinwalk.cpp) endif() # Add the executable -add_library (${project_lib} ${SOURCE_MODULES}) -add_executable(${project} ${SOURCE_MAIN} ${SOURCE_MODULES}) +add_library(${project_lib} ${SOURCE_MODULES}) +add_executable(${project} ${SOURCE_MAIN}) # Add the libraries if(CMAKE_CUDA_COMPILER) - target_link_libraries(${project} PRIVATE ${CUDA_LIBRARIES}) + target_link_libraries(${project_lib} ${CUDA_LIBRARIES}) endif() if(OpenMP_CXX_FOUND) message(STATUS "Found OpenMP, adding to target link libraries.") - target_link_libraries(${project} PRIVATE OpenMP::OpenMP_CXX) + target_link_libraries(${project_lib} OpenMP::OpenMP_CXX) else() message(STATUS "OpenMP not found, skipping.") endif() -target_link_libraries(${project} PRIVATE ${Boost_LIBRARIES} ${HDF5_CXX_LIBRARIES} TBB::tbb) +target_link_libraries(${project_lib} ${Boost_LIBRARIES} ${HDF5_CXX_LIBRARIES} TBB::tbb) +target_link_libraries(${project} PRIVATE ${project_lib}) # Set the output name -set_target_properties(${project_lib} PROPERTIES OUTPUT_NAME "spinwalk") set_target_properties(${project} PROPERTIES OUTPUT_NAME "spinwalk") +set_target_properties(${project_lib} PROPERTIES OUTPUT_NAME "spinwalk") + # Install the executable if (UNIX) - install(TARGETS ${project_lib} DESTINATION lib) install(TARGETS ${project} DESTINATION bin) + install(TARGETS ${project_lib} DESTINATION lib) endif() # cmake .. diff --git a/src/definitions.h b/src/definitions.h index 73bfd0f..742d229 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -3,7 +3,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 18 -#define VERSION_PATCH 0 +#define VERSION_PATCH 1 // Helper macros to stringify values #define STRINGIFY_HELPER(x) #x diff --git a/src/sim/monte_carlo.cuh b/src/sim/monte_carlo.cuh index e4328c8..02e3d8a 100644 --- a/src/sim/monte_carlo.cuh +++ b/src/sim/monte_carlo.cuh @@ -52,7 +52,6 @@ class monte_carlo { thrust::device_vector d_mask; #endif - }; diff --git a/src/spinwalk.cpp b/src/spinwalk.cu similarity index 97% rename from src/spinwalk.cpp rename to src/spinwalk.cu index 100232e..771b5fa 100644 --- a/src/spinwalk.cpp +++ b/src/spinwalk.cu @@ -132,6 +132,7 @@ int main(int argc, char * argv[]) return 0; std::cout << "Running simulation for " << config_files.size() << " config(s)..." << "\n\n"; + sim::monte_carlo mc(use_cpu, device_id); for(const auto& config_file : config_files){ std::cout << "<" << std::filesystem::path(config_file).filename().string() << ">\n"; @@ -139,6 +140,7 @@ int main(int argc, char * argv[]) std::cout << ERR_MSG << "Simulation failed. See the log file " << log_filename <<", Aborting...!" << "\n"; return 1; } - } + } + std::cout << "Simulation completed successfully. See the log file " << log_filename << "\n"; return 0; }