From daf442434405dbe2a95febae6e20f4a9b8d42924 Mon Sep 17 00:00:00 2001 From: Brian Staber Date: Sun, 21 Sep 2025 22:03:56 +0200 Subject: [PATCH 1/5] :rocket: CUDA hello world --- crates/CMakeLists.txt | 3 ++- crates/cuda_hello/CMakeLists.txt | 15 +++++++++++++++ crates/cuda_hello/main.cu | 15 +++++++++++++++ spack.lock | 1 + spack.yaml | 11 ++++++++--- 5 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 crates/cuda_hello/CMakeLists.txt create mode 100644 crates/cuda_hello/main.cu create mode 100644 spack.lock diff --git a/crates/CMakeLists.txt b/crates/CMakeLists.txt index 422b788..8c697f4 100644 --- a/crates/CMakeLists.txt +++ b/crates/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory("kf_linear") add_subdirectory("simple_optimizers") -add_subdirectory("ar_models") \ No newline at end of file +add_subdirectory("ar_models") +add_subdirectory("cuda_hello") \ No newline at end of file diff --git a/crates/cuda_hello/CMakeLists.txt b/crates/cuda_hello/CMakeLists.txt new file mode 100644 index 0000000..aaf93a0 --- /dev/null +++ b/crates/cuda_hello/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.25) +project(cuda_hello LANGUAGES CXX CUDA) + +set(CMAKE_CUDA_STANDARD 17) +set(CMAKE_CUDA_STANDARD_REQUIRED ON) + +set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) + +add_executable(cuda_hello main.cu) + +find_package(CUDAToolkit REQUIRED) +target_link_libraries(cuda_hello PRIVATE CUDA::cudart) + +set_property(TARGET cuda_hello PROPERTY CUDA_ARCHITECTURES native) diff --git a/crates/cuda_hello/main.cu b/crates/cuda_hello/main.cu new file mode 100644 index 0000000..ade8228 --- /dev/null +++ b/crates/cuda_hello/main.cu @@ -0,0 +1,15 @@ +#include + +// Kernel function that runs on the GPU +__global__ void hello_kernel() { + printf("Hello from GPU thread %d in block %d!\n", threadIdx.x, blockIdx.x); +} + +int main() { + // Launch 2 blocks with 4 threads each + hello_kernel<<<2, 4>>>(); + cudaDeviceSynchronize(); // wait for GPU to finish + + printf("Hello from CPU!\n"); + return 0; +} diff --git a/spack.lock b/spack.lock new file mode 100644 index 0000000..2d508ad --- /dev/null +++ b/spack.lock @@ -0,0 +1 @@ +{"_meta":{"file-type":"spack-lockfile","lockfile-version":6,"specfile-version":5},"spack":{"version":"1.1.0.dev0","type":"git","commit":"2c324326aef3a00e42a5665b0d2c470b06a82b8f"},"roots":[{"hash":"jfx7ok5pjfigwd7chkp3myhrqgmn565p","spec":"eigen@3.4"},{"hash":"y2xjskgxyxp4bc2sw6pecncb5dzohkg5","spec":"cuda"},{"hash":"47aecsvim5elidtpsjnomxlitxmrgupp","spec":"catch2@3"},{"hash":"qsopenf2wgyylvdjvi576lfksq3nqzih","spec":"cmake"}],"concrete_specs":{"jfx7ok5pjfigwd7chkp3myhrqgmn565p":{"name":"eigen","version":"3.4.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"cmake","build_type":"RelWithDebInfo","generator":"make","ipo":false,"nightly":false,"rocm":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"ggb23tivzjnufy774uxjtugtvnyifwytnn3fydouex3ibtxgmzfa====","dependencies":[{"name":"cmake","hash":"qsopenf2wgyylvdjvi576lfksq3nqzih","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"jfx7ok5pjfigwd7chkp3myhrqgmn565p"},"qsopenf2wgyylvdjvi576lfksq3nqzih":{"name":"cmake","version":"3.31.8","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","build_type":"Release","doc":false,"ncurses":true,"ownlibs":true,"qtgui":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"6bgxxh5z37foz6b2pkpou65tucfme4y7m54i4p3f4pfyvck3iiwa====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"curl","hash":"zb5unwhwrqbmd3u6gxvkm7pteusf3fmh","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build","run"],"virtuals":[]}},{"name":"ncurses","hash":"xnomw4pvbntpkyngshwxi5pqu4q6qq3b","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"zlib-ng","hash":"qcvktu2ekkzryfalsefferoyrezj3gkb","parameters":{"deptypes":["build","link"],"virtuals":["zlib-api"]}}],"annotations":{"original_specfile_version":5},"hash":"qsopenf2wgyylvdjvi576lfksq3nqzih"},"adr4m722sut3yibwgl2ehvjbtuzeozzm":{"name":"compiler-wrapper","version":"1.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"vohu4wrffrhvsd4padcnlwdcmpwpqei4nzeytzsmkgxsl4cslfxq====","annotations":{"original_specfile_version":5},"hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm"},"zb5unwhwrqbmd3u6gxvkm7pteusf3fmh":{"name":"curl","version":"8.15.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","gssapi":false,"ldap":false,"libidn2":false,"librtmp":false,"libs":["shared","static"],"libssh":false,"libssh2":false,"nghttp2":true,"tls":["openssl"],"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"xe5i2rokqs2ayzzcooqbduhjyrvoxx2irguwnlwzxk5wz35mvfba====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"nghttp2","hash":"bog4bnbmpmoo3pf75t3hqm2klbwdvwaj","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"openssl","hash":"jxa4k45hgl25gl6r5fxucqz6q3upymos","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"perl","hash":"yuhkuelvs3vg62iy5p2dm354jhu2ouis","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"pkgconf","hash":"y6s22357tis2z56z4d4lafxkwozvztpg","parameters":{"deptypes":["build"],"virtuals":["pkgconfig"]}},{"name":"zlib-ng","hash":"qcvktu2ekkzryfalsefferoyrezj3gkb","parameters":{"deptypes":["build","link"],"virtuals":["zlib-api"]}}],"annotations":{"original_specfile_version":5},"hash":"zb5unwhwrqbmd3u6gxvkm7pteusf3fmh"},"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn":{"name":"gcc","version":"13.3.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"binutils":false,"bootstrap":true,"build_system":"autotools","build_type":"RelWithDebInfo","graphite":false,"languages":["c","c++","fortran"],"mold":false,"nvptx":false,"piclibs":false,"profiled":false,"strip":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"external":{"path":"/usr","module":null,"extra_attributes":{"compilers":{"c":"/usr/bin/gcc-13","cxx":"/usr/bin/g++-13","fortran":"/usr/bin/gfortran"}}},"package_hash":"rmpc4gpj5qe2oeoqe5vxa2dqrvf4dznbzkzctftxcc4iiqbrxyca====","annotations":{"original_specfile_version":5},"hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn"},"swzzlz3ox4kierj7njngro53kixbpke2":{"name":"gcc-runtime","version":"13.3.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"q2rk2ibjyixyovjks3huspa2gqfkl7b2q2l4efx54262chl3icjq====","dependencies":[{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}}],"annotations":{"original_specfile_version":5},"hash":"swzzlz3ox4kierj7njngro53kixbpke2"},"thy5vqoaouxdwkh5hofjegtbqsl7r25d":{"name":"glibc","version":"2.39","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"external":{"path":"/usr","module":null,"extra_attributes":{}},"package_hash":"uykmboa2sw2jkcgvgh6ywrvd7l2m6puhzhzdljklfme6w6agh6ia====","annotations":{"original_specfile_version":5},"hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d"},"jepm6yyu5xaigwgyedmkyir34nofvkcm":{"name":"gmake","version":"4.4.1","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","guile":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"h2dsagusnktgdqtmrkidm6otgpj3lzpu4yczjxl77l5i3ckinszq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}}],"annotations":{"original_specfile_version":5},"hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm"},"bog4bnbmpmoo3pf75t3hqm2klbwdvwaj":{"name":"nghttp2","version":"1.65.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"f5vtvrfywxpzvpdxctg6svt5r5b5ln55jplpknobdsbaeeyv4lza====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"diffutils","hash":"omessfs4aynqrdutkragscfrf6gmszqo","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"pkgconf","hash":"y6s22357tis2z56z4d4lafxkwozvztpg","parameters":{"deptypes":["build"],"virtuals":["pkgconfig"]}}],"annotations":{"original_specfile_version":5},"hash":"bog4bnbmpmoo3pf75t3hqm2klbwdvwaj"},"omessfs4aynqrdutkragscfrf6gmszqo":{"name":"diffutils","version":"3.10","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"kf4cloz7zpbeu3sozbbx4xikot25nctbgri6mvwgq23snw55nhoq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"libiconv","hash":"fbonnn6naeywugcythl7bxawgmbgriyl","parameters":{"deptypes":["build","link"],"virtuals":["iconv"]}}],"annotations":{"original_specfile_version":5},"hash":"omessfs4aynqrdutkragscfrf6gmszqo"},"fbonnn6naeywugcythl7bxawgmbgriyl":{"name":"libiconv","version":"1.18","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","libs":["shared","static"],"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"57qcdp5r3pkdlzpwspvufc6ojs26lglepl3zchdj4qaq6s4izg3a====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"fbonnn6naeywugcythl7bxawgmbgriyl"},"y6s22357tis2z56z4d4lafxkwozvztpg":{"name":"pkgconf","version":"2.5.1","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"o6vd55gzw74grnmg4yrt3smyrtsshssqjvxsqbchcjimkv2nkysa====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"y6s22357tis2z56z4d4lafxkwozvztpg"},"jxa4k45hgl25gl6r5fxucqz6q3upymos":{"name":"openssl","version":"3.4.1","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","certs":"mozilla","docs":false,"shared":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"vudyirll2t54l73thtetqb2puaxgasyw6f7pd7yrlprm6iteijxq====","dependencies":[{"name":"ca-certificates-mozilla","hash":"6cgpb6ytmln3jxrnkeqhq4vzzqki6mys","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"perl","hash":"yuhkuelvs3vg62iy5p2dm354jhu2ouis","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"zlib-ng","hash":"qcvktu2ekkzryfalsefferoyrezj3gkb","parameters":{"deptypes":["build","link"],"virtuals":["zlib-api"]}}],"annotations":{"original_specfile_version":5},"hash":"jxa4k45hgl25gl6r5fxucqz6q3upymos"},"6cgpb6ytmln3jxrnkeqhq4vzzqki6mys":{"name":"ca-certificates-mozilla","version":"2025-05-20","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"nb6lb7j6lhuedxkx2sjej2shho6nmaefuhqfrtzphp3zcgmvkgaa====","annotations":{"original_specfile_version":5},"hash":"6cgpb6ytmln3jxrnkeqhq4vzzqki6mys"},"yuhkuelvs3vg62iy5p2dm354jhu2ouis":{"name":"perl","version":"5.42.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","cpanm":true,"opcode":true,"open":true,"shared":true,"threads":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"ebmmblxks7kalf336sgcphbt27ei3676t5zezrndywt3ga3gqgbq====","dependencies":[{"name":"berkeley-db","hash":"ktdh5q2seehihqwgpzldnqmzenmy3re7","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"bzip2","hash":"26busrpemuzmf2igv2xzyt72hacdcf66","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"gdbm","hash":"cp4nlnxqdsgfmavauhx3wf6g25ukmcej","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"zlib-ng","hash":"qcvktu2ekkzryfalsefferoyrezj3gkb","parameters":{"deptypes":["build","link"],"virtuals":["zlib-api"]}}],"annotations":{"original_specfile_version":5},"hash":"yuhkuelvs3vg62iy5p2dm354jhu2ouis"},"ktdh5q2seehihqwgpzldnqmzenmy3re7":{"name":"berkeley-db","version":"18.1.40","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cxx":true,"docs":false,"patches":["26090f418891757af46ac3b89a9f43d6eb5989f7a3dce3d1cfc99fba547203b3","b231fcc4d5cff05e5c3a4814f6a5af0e9a966428dc2176540d2c05aff41de522"],"stl":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"patches":["b231fcc4d5cff05e5c3a4814f6a5af0e9a966428dc2176540d2c05aff41de522","26090f418891757af46ac3b89a9f43d6eb5989f7a3dce3d1cfc99fba547203b3"],"package_hash":"rct4ah5bcdhvxavbhoendusmbpvunpuv6fescvss7thvjca4ohca====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"ktdh5q2seehihqwgpzldnqmzenmy3re7"},"26busrpemuzmf2igv2xzyt72hacdcf66":{"name":"bzip2","version":"1.0.8","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","debug":false,"pic":false,"shared":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"23pafj3kmpyregjxpmso3hf2q5op467msdhghyksoj2sv75ixqga====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"diffutils","hash":"omessfs4aynqrdutkragscfrf6gmszqo","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"26busrpemuzmf2igv2xzyt72hacdcf66"},"cp4nlnxqdsgfmavauhx3wf6g25ukmcej":{"name":"gdbm","version":"1.23","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"ac4euapngqexfcsrwzn7jwesrgli6oct6sezwqb5pmrjfehc5eyq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"readline","hash":"gp6jxsnasvzbpgkpomdih5bkx4jgmumh","parameters":{"deptypes":["build","link"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"cp4nlnxqdsgfmavauhx3wf6g25ukmcej"},"gp6jxsnasvzbpgkpomdih5bkx4jgmumh":{"name":"readline","version":"8.3","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","patches":["21f0a03106dbe697337cd25c70eb0edbaa2bdb6d595b45f83285cdd35bac84de"],"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"patches":["21f0a03106dbe697337cd25c70eb0edbaa2bdb6d595b45f83285cdd35bac84de"],"package_hash":"3bkz3xcmc2bdayaxvpyiryqhgclpc4or64q65pqdj24qona5kotq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"ncurses","hash":"xnomw4pvbntpkyngshwxi5pqu4q6qq3b","parameters":{"deptypes":["build","link"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"gp6jxsnasvzbpgkpomdih5bkx4jgmumh"},"xnomw4pvbntpkyngshwxi5pqu4q6qq3b":{"name":"ncurses","version":"6.5-20250705","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"abi":"none","build_system":"autotools","patches":["7a351bc4953a4ab70dabdbea31c8db0c03d40ce505335f3b6687180dde24c535"],"symlinks":false,"termlib":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"patches":["7a351bc4953a4ab70dabdbea31c8db0c03d40ce505335f3b6687180dde24c535"],"package_hash":"iisfoewmynkxm2y4pfxa2sjzz7nokwbd7cg3lkyfkzx7aulddisq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"pkgconf","hash":"y6s22357tis2z56z4d4lafxkwozvztpg","parameters":{"deptypes":["build"],"virtuals":["pkgconfig"]}}],"annotations":{"original_specfile_version":5},"hash":"xnomw4pvbntpkyngshwxi5pqu4q6qq3b"},"qcvktu2ekkzryfalsefferoyrezj3gkb":{"name":"zlib-ng","version":"2.2.4","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"autotools","compat":true,"new_strategies":true,"opt":true,"pic":true,"shared":true,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"atlinvfh3ttnwgfvl3uftgsyhtyqhhrmvzojzrhlyebq3fbbhptq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"qcvktu2ekkzryfalsefferoyrezj3gkb"},"y2xjskgxyxp4bc2sw6pecncb5dzohkg5":{"name":"cuda","version":"12.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"allow-unsupported-compilers":false,"build_system":"generic","dev":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"external":{"path":"/usr/local/cuda-12.0","module":null,"extra_attributes":{}},"package_hash":"uvp5ldk7xscuf5imcojqmmrd6qsuv6zvntb6u435qknmrep7xupq====","annotations":{"original_specfile_version":5},"hash":"y2xjskgxyxp4bc2sw6pecncb5dzohkg5"},"47aecsvim5elidtpsjnomxlitxmrgupp":{"name":"catch2","version":"3.8.0","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"cmake","build_type":"Release","cxxstd":"17","generator":"make","ipo":false,"pic":true,"shared":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"package_hash":"3yepsk2x2gsokdpfewys73j5lg7dmg5hncgltj4bmhrffdeckona====","dependencies":[{"name":"cmake","hash":"vxh7li2okyefhvmuhkxx7f4h6nvgsqzh","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build"],"virtuals":[]}}],"annotations":{"original_specfile_version":5},"hash":"47aecsvim5elidtpsjnomxlitxmrgupp"},"vxh7li2okyefhvmuhkxx7f4h6nvgsqzh":{"name":"cmake","version":"3.22.6","arch":{"platform":"linux","platform_os":"ubuntu24.04","target":"x86_64"},"namespace":"builtin","parameters":{"build_system":"generic","build_type":"Release","doc":false,"ncurses":true,"ownlibs":true,"patches":["dbc3892939348c71f35973dd30e74c4a84bc7a2446c6930523c9723b88a597d1","fdea723be9713f3ed4624055bf21ef5876647d63c151b91006608ec44a912ae1"],"qtgui":false,"cflags":[],"cppflags":[],"cxxflags":[],"fflags":[],"ldflags":[],"ldlibs":[]},"patches":["dbc3892939348c71f35973dd30e74c4a84bc7a2446c6930523c9723b88a597d1","fdea723be9713f3ed4624055bf21ef5876647d63c151b91006608ec44a912ae1"],"package_hash":"4jh7rrn67xzwqylg665mwntajvsdxao634u7dy6b42ijopawxpxq====","dependencies":[{"name":"compiler-wrapper","hash":"adr4m722sut3yibwgl2ehvjbtuzeozzm","parameters":{"deptypes":["build"],"virtuals":[]}},{"name":"curl","hash":"zb5unwhwrqbmd3u6gxvkm7pteusf3fmh","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"gcc","hash":"4zzwsjhxf55wvg4rpfoefqnhxdhhkepn","parameters":{"deptypes":["build"],"virtuals":["c","cxx"]}},{"name":"gcc-runtime","hash":"swzzlz3ox4kierj7njngro53kixbpke2","parameters":{"deptypes":["link"],"virtuals":[]}},{"name":"glibc","hash":"thy5vqoaouxdwkh5hofjegtbqsl7r25d","parameters":{"deptypes":["link"],"virtuals":["libc"]}},{"name":"gmake","hash":"jepm6yyu5xaigwgyedmkyir34nofvkcm","parameters":{"deptypes":["build","run"],"virtuals":[]}},{"name":"ncurses","hash":"xnomw4pvbntpkyngshwxi5pqu4q6qq3b","parameters":{"deptypes":["build","link"],"virtuals":[]}},{"name":"zlib-ng","hash":"qcvktu2ekkzryfalsefferoyrezj3gkb","parameters":{"deptypes":["build","link"],"virtuals":["zlib-api"]}}],"annotations":{"original_specfile_version":5},"hash":"vxh7li2okyefhvmuhkxx7f4h6nvgsqzh"}}} \ No newline at end of file diff --git a/spack.yaml b/spack.yaml index d00bb2c..539211b 100644 --- a/spack.yaml +++ b/spack.yaml @@ -6,7 +6,8 @@ spack: specs: - eigen@3.4 - catch2@3 - + - cuda + - cmake packages: all: target: [x86_64] @@ -15,6 +16,10 @@ spack: - spec: cmake@3.22.1 prefix: /usr buildable: false - + cuda: + externals: + - spec: cuda@12.0 + prefix: /usr/local/cuda-12.0 + buildable: false config: - install_tree: $spack/opt/spack \ No newline at end of file + install_tree: $spack/opt/spack From 440f48a22a1fe3b6c99df010a5e618676b559460 Mon Sep 17 00:00:00 2001 From: Brian Staber Date: Sun, 21 Sep 2025 22:09:08 +0200 Subject: [PATCH 2/5] fix spack yml --- spack.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spack.yaml b/spack.yaml index 539211b..e27316a 100644 --- a/spack.yaml +++ b/spack.yaml @@ -22,4 +22,5 @@ spack: prefix: /usr/local/cuda-12.0 buildable: false config: - install_tree: $spack/opt/spack + install_tree: + root: $spack/opt/spack From 506f8d9774e36e1e66f49c7cebe54e61b0ea052d Mon Sep 17 00:00:00 2001 From: Brian Staber Date: Sun, 21 Sep 2025 22:17:30 +0200 Subject: [PATCH 3/5] make cuda build optional --- .github/workflows/cpp-tests.yml | 2 +- crates/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp-tests.yml b/.github/workflows/cpp-tests.yml index eb130ec..fb35efd 100644 --- a/.github/workflows/cpp-tests.yml +++ b/.github/workflows/cpp-tests.yml @@ -55,7 +55,7 @@ jobs: shell: spack-bash {0} run: | spack env activate lobxp - cmake -S . -B build -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + cmake -S . -B build -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_CUDA=OFF - name: Build run: cmake --build build -j $(nproc) diff --git a/crates/CMakeLists.txt b/crates/CMakeLists.txt index 8c697f4..3f69ddd 100644 --- a/crates/CMakeLists.txt +++ b/crates/CMakeLists.txt @@ -1,4 +1,6 @@ add_subdirectory("kf_linear") add_subdirectory("simple_optimizers") add_subdirectory("ar_models") -add_subdirectory("cuda_hello") \ No newline at end of file +if(BUILD_CUDA) + add_subdirectory("cuda_hello") +endif() From 570c4b7c23eabd14964dbc386407cc97fd5fbd37 Mon Sep 17 00:00:00 2001 From: Brian Staber Date: Sun, 21 Sep 2025 22:24:48 +0200 Subject: [PATCH 4/5] Update README with dev instructions --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b18d8ff..cd41276 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,49 @@ The purpose of this repository is to provide a space for exploring numerical methods, algorithms, and patterns in C++ in a practical and modular way. It is not intended as a tutorial or comprehensive learning resource, but rather as a set of working examples and references. -Contributions are welcome. If you spot an issue, find an area that could be improved, or want to add your own example, feel free to open an issue or submit a pull request. \ No newline at end of file +Contributions are welcome. If you spot an issue, find an area that could be improved, or want to add your own example, feel free to open an issue or submit a pull request. + +# Developper guide + +## Spack + +We use spack to manage dependencies and build the projects. To get started, clone the repository and run: + +```bash +git clone https://github.com/bstaber/cppplorers.git +cd cppXplorers +spack env activate . +spack concretize -f +spack install +``` + +This will set up the environment and install the necessary packages. You can then enter the environment with: + +```bash +spack env activate . +``` + +Note that we set the CUDA dependency externally, so if you want to use CUDA, make sure to have it installed and configured properly. + +## Building + +Each crate has its own `CMakeLists.txt` file and can be built independently. However, we provide a top-level `CMakeLists.txt` that can be used to build all crates at once. To build all crates, run: + +```bash +just +``` + +This will run the `justfile` which builds all crates and runs all tests. + +## Adding a new crate + +To add a new crate, create a new directory under `crates/` and add a `CMakeLists.txt` file. You can use one of the existing crates as a template. Make sure to update the top-level `CMakeLists.txt` to include your new crate. + +## Documenting a crate +We use `mdbook` to document each crate. You can find the book source files in the `books/` directory. To build and serve the book, run: + +```bash +just serve-book +``` + +This will build the book and serve it at `http://localhost:3000`. You can then navigate to the book in your web browser. \ No newline at end of file From 332fd9e85b2903ae1654e2f4fbd9100c83b8ad59 Mon Sep 17 00:00:00 2001 From: Brian Staber Date: Sun, 21 Sep 2025 22:26:30 +0200 Subject: [PATCH 5/5] More details in README --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd41276..dbbcf55 100644 --- a/README.md +++ b/README.md @@ -49,4 +49,17 @@ We use `mdbook` to document each crate. You can find the book source files in th just serve-book ``` -This will build the book and serve it at `http://localhost:3000`. You can then navigate to the book in your web browser. \ No newline at end of file +This will build the book and serve it at `http://localhost:3000`. You can then navigate to the book in your web browser. + +## Just + +We use `just` as a task runner to automate common tasks. You can find the `justfile` in the root directory. Some common tasks include: + +- `just build`: Build all crates +- `just test`: Run all tests +- `just serve-book`: Build and serve the documentation book +- `just clean`: Clean all build artifacts +- `just fmt`: Format all code using `clang-format` +- `just lint`: Run `clang-tidy` on all code +- `just configure`: Configure all crates with CMake +- `just`: Configure, build, and test all crates \ No newline at end of file