From 228f6c893380b29b8ccf8d274b051de2824a3364 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Sat, 1 Mar 2025 00:07:01 +0000 Subject: [PATCH 01/10] Add option BUILD_CUDA to CMakeLists to allow building on CUDA-incompatible platforms --- CMakeLists.txt | 9 ++++++++- bitshuffle | 1 + dx2 | 2 +- pyproject.toml | 1 + spotfinder/spotfinder.cc | 5 +++++ 5 files changed, 16 insertions(+), 2 deletions(-) create mode 160000 bitshuffle diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bacb40d..f6c61dc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 3.20...3.30) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") include(ResolveGitVersion) +option(BUILD_CUDA "Build CUDA" ON) +# Uncomment the line below when running on CUDA-incompatible platforms +# set(BUILD_CUDA OFF) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CUDA_STANDARD 20) project(fast-feedback-service LANGUAGES CXX VERSION ${FFS_VERSION_CMAKE}) @@ -70,4 +74,7 @@ enable_testing() add_subdirectory(h5read) add_subdirectory(baseline) -add_subdirectory(spotfinder) + +if(BUILD_CUDA) + add_subdirectory(spotfinder) +endif() diff --git a/bitshuffle b/bitshuffle new file mode 160000 index 00000000..526440a1 --- /dev/null +++ b/bitshuffle @@ -0,0 +1 @@ +Subproject commit 526440a16baff44bd405e0741ebd285858a5408d diff --git a/dx2 b/dx2 index 556051d4..2d152bb5 160000 --- a/dx2 +++ b/dx2 @@ -1 +1 @@ -Subproject commit 556051d4d4e6d51c40c600fc350c07f9b299a435 +Subproject commit 2d152bb561ea6dc011530000b981048ed2121cb7 diff --git a/pyproject.toml b/pyproject.toml index 252128d7..c6607368 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ readme = "README.md" authors = [ { name = "Nicholas Devenish", email = "ndevenish@gmail.com" }, { name = "Dimitri Vlachos", email = "dimitrios.vlachos@diamond.ac.uk" }, + { name = "Yash Karan", email = "yash.karan@diamond.ac.uk} ] requires-python = ">=3.12" diff --git a/spotfinder/spotfinder.cc b/spotfinder/spotfinder.cc index b657e38d..5cfd17ad 100644 --- a/spotfinder/spotfinder.cc +++ b/spotfinder/spotfinder.cc @@ -484,6 +484,10 @@ int main(int argc, char **argv) { fmt::styled(detector.beam_center_x, fmt_cyan), fmt::styled(detector.beam_center_y, fmt_cyan), fmt::styled(wavelength, fmt_cyan)); + fmt::styled(detector.distance * 1000, fmt_cyan), + fmt::styled(detector.beam_center_x, fmt_cyan), + fmt::styled(detector.beam_center_y, fmt_cyan), + fmt::styled(wavelength, fmt_cyan)); auto [oscillation_start, oscillation_width] = reader.get_oscillation(); @@ -987,6 +991,7 @@ int main(int argc, char **argv) { // Step 3: Output the 3D reflections logger->info( fmt::format("Found {} spots", fmt::styled(reflections_3d.size(), fmt_cyan))); + fmt::format("Found {} spots", fmt::styled(reflections_3d.size(), fmt_cyan))); if (do_writeout) { std::ofstream out("3d_reflections.txt"); From 13f561eb0e4685dd8b085eff26ecdafa5ac055f8 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Sat, 1 Mar 2025 00:10:15 +0000 Subject: [PATCH 02/10] Edit CMakeLists to include bitshuffle directories --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6c61dc2..363e04f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ include(ResolveGitVersion) option(BUILD_CUDA "Build CUDA" ON) # Uncomment the line below when running on CUDA-incompatible platforms -# set(BUILD_CUDA OFF) +set(BUILD_CUDA OFF) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CUDA_STANDARD 20) @@ -78,3 +78,5 @@ add_subdirectory(baseline) if(BUILD_CUDA) add_subdirectory(spotfinder) endif() + +include_directories(bitshuffle/src bitshuffle/lz4) \ No newline at end of file From fcc723f1782d618c30d93a15f683400970b7b953 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Sat, 1 Mar 2025 01:39:49 +0000 Subject: [PATCH 03/10] Add additional ARM bitshuffle details to CMakeLists --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 363e04f4..b131188b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,4 +79,15 @@ if(BUILD_CUDA) add_subdirectory(spotfinder) endif() -include_directories(bitshuffle/src bitshuffle/lz4) \ No newline at end of file +include_directories(bitshuffle/src bitshuffle/lz4) + +## TODO: add info on how to use bitshuffle on ARM. The below commands do not CMake properly () +## CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. +## Missing variable is: +## CMAKE_C_COMPILE_OBJECT + +# add_library(bitshuffle +# bitshuffle/src/bitshuffle.c +# bitshuffle/lz4/lz4.c +# bitshuffle/src/bitshuffle_core.c +# bitshuffle/src/iochain.c) \ No newline at end of file From b9f1c392bb7732d0d6f72ce7db8916e3c86f2609 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Sat, 1 Mar 2025 02:08:33 +0000 Subject: [PATCH 04/10] Automatically enable/disable building with CUDA depending on CUDA availability --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b131188b..a40573fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,6 @@ cmake_minimum_required(VERSION 3.20...3.30) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") include(ResolveGitVersion) -option(BUILD_CUDA "Build CUDA" ON) -# Uncomment the line below when running on CUDA-incompatible platforms -set(BUILD_CUDA OFF) - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CUDA_STANDARD 20) project(fast-feedback-service LANGUAGES CXX VERSION ${FFS_VERSION_CMAKE}) @@ -20,6 +16,16 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) include(SetDefaultBuildRelWithDebInfo) include(AlwaysColourCompilation) +include(CheckLanguage) +check_language(CUDA) +if(CMAKE_CUDA_COMPILER) + message("CUDA compiler available; building with CUDA enabled.") + set(BUILD_CUDA ON) +else() + message("CUDA compiler NOT available; building with CUDA disabled.") + set(BUILD_CUDA OFF) +endif() + include_directories(include) # Dependency fetching From d38d6d1e6d714dabf1fb8bbe057a435445c6ff33 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Mon, 3 Mar 2025 19:28:59 +0000 Subject: [PATCH 05/10] Remove bitshuffle info --- CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a40573fd..a6b48c70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,16 +84,3 @@ add_subdirectory(baseline) if(BUILD_CUDA) add_subdirectory(spotfinder) endif() - -include_directories(bitshuffle/src bitshuffle/lz4) - -## TODO: add info on how to use bitshuffle on ARM. The below commands do not CMake properly () -## CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. -## Missing variable is: -## CMAKE_C_COMPILE_OBJECT - -# add_library(bitshuffle -# bitshuffle/src/bitshuffle.c -# bitshuffle/lz4/lz4.c -# bitshuffle/src/bitshuffle_core.c -# bitshuffle/src/iochain.c) \ No newline at end of file From f6943283aac1f0584b54909e32746cee9396329c Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Mon, 3 Mar 2025 20:07:19 +0000 Subject: [PATCH 06/10] Remove bitshuffle directory --- bitshuffle | 1 - 1 file changed, 1 deletion(-) delete mode 160000 bitshuffle diff --git a/bitshuffle b/bitshuffle deleted file mode 160000 index 526440a1..00000000 --- a/bitshuffle +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 526440a16baff44bd405e0741ebd285858a5408d From 9187dc1357383689f2fd87305b4ce536c2ea0b64 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Mon, 3 Mar 2025 20:13:23 +0000 Subject: [PATCH 07/10] Remove unintended changes to spotfinder.cc --- spotfinder/spotfinder.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spotfinder/spotfinder.cc b/spotfinder/spotfinder.cc index 5cfd17ad..b657e38d 100644 --- a/spotfinder/spotfinder.cc +++ b/spotfinder/spotfinder.cc @@ -484,10 +484,6 @@ int main(int argc, char **argv) { fmt::styled(detector.beam_center_x, fmt_cyan), fmt::styled(detector.beam_center_y, fmt_cyan), fmt::styled(wavelength, fmt_cyan)); - fmt::styled(detector.distance * 1000, fmt_cyan), - fmt::styled(detector.beam_center_x, fmt_cyan), - fmt::styled(detector.beam_center_y, fmt_cyan), - fmt::styled(wavelength, fmt_cyan)); auto [oscillation_start, oscillation_width] = reader.get_oscillation(); @@ -991,7 +987,6 @@ int main(int argc, char **argv) { // Step 3: Output the 3D reflections logger->info( fmt::format("Found {} spots", fmt::styled(reflections_3d.size(), fmt_cyan))); - fmt::format("Found {} spots", fmt::styled(reflections_3d.size(), fmt_cyan))); if (do_writeout) { std::ofstream out("3d_reflections.txt"); From 99e29eb430f78dc60e62bb30f43dba7ddce73a87 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Mon, 3 Mar 2025 20:15:01 +0000 Subject: [PATCH 08/10] Amend CMakeLists --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6b48c70..3f8e9891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(CMAKE_CUDA_COMPILER) message("CUDA compiler available; building with CUDA enabled.") set(BUILD_CUDA ON) else() - message("CUDA compiler NOT available; building with CUDA disabled.") + message("CUDA compiler unavailable; building with CUDA disabled.") set(BUILD_CUDA OFF) endif() From 74f932fb5f1f4201242a040b8497e725910bc546 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Mon, 3 Mar 2025 20:21:56 +0000 Subject: [PATCH 09/10] Fix pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c6607368..83efeb9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "README.md" authors = [ { name = "Nicholas Devenish", email = "ndevenish@gmail.com" }, { name = "Dimitri Vlachos", email = "dimitrios.vlachos@diamond.ac.uk" }, - { name = "Yash Karan", email = "yash.karan@diamond.ac.uk} + { name = "Yash Karan", email = "yash.karan@diamond.ac.uk" }, ] requires-python = ">=3.12" From 93a986581b5d5edd44268d7c7473ca186a6d7159 Mon Sep 17 00:00:00 2001 From: Yash Karan Date: Fri, 14 Mar 2025 16:18:17 +0000 Subject: [PATCH 10/10] Add option to manually enable/disable CUDA --- CMakeLists.txt | 19 ++++++++++++------- bitshuffle | 1 + dx2 | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) create mode 160000 bitshuffle diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f8e9891..a4739546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,14 +16,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) include(SetDefaultBuildRelWithDebInfo) include(AlwaysColourCompilation) -include(CheckLanguage) -check_language(CUDA) -if(CMAKE_CUDA_COMPILER) - message("CUDA compiler available; building with CUDA enabled.") - set(BUILD_CUDA ON) +if(NOT DEFINED ENV{BUILD_CUDA}) + include(CheckLanguage) + check_language(CUDA) + if(CMAKE_CUDA_COMPILER) + message("CUDA compiler available.") + set(BUILD_CUDA ON) + else() + message("CUDA compiler unavailable.") + set(BUILD_CUDA OFF) + endif() else() - message("CUDA compiler unavailable; building with CUDA disabled.") - set(BUILD_CUDA OFF) + set(BUILD_CUDA $ENV{BUILD_CUDA}) endif() include_directories(include) @@ -82,5 +86,6 @@ add_subdirectory(h5read) add_subdirectory(baseline) if(BUILD_CUDA) + message("Building with CUDA enabled.") add_subdirectory(spotfinder) endif() diff --git a/bitshuffle b/bitshuffle new file mode 160000 index 00000000..526440a1 --- /dev/null +++ b/bitshuffle @@ -0,0 +1 @@ +Subproject commit 526440a16baff44bd405e0741ebd285858a5408d diff --git a/dx2 b/dx2 index 2d152bb5..ff503db2 160000 --- a/dx2 +++ b/dx2 @@ -1 +1 @@ -Subproject commit 2d152bb561ea6dc011530000b981048ed2121cb7 +Subproject commit ff503db22b7a2f866d46ebf56afcd799d39c1c86