Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aghaeifar committed Dec 21, 2024
1 parent 223f4f7 commit a6bfc78
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
23 changes: 14 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ..
Expand Down
2 changes: 1 addition & 1 deletion src/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/sim/monte_carlo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class monte_carlo {
thrust::device_vector<uint8_t> d_mask;
#endif


};


Expand Down
4 changes: 3 additions & 1 deletion src/spinwalk.cpp → src/spinwalk.cu
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ 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";
if(mc.run(config_file) == false){
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;
}

0 comments on commit a6bfc78

Please sign in to comment.