Skip to content

Commit cf2adf1

Browse files
committed
add more targets to flake
1 parent e7ac578 commit cf2adf1

File tree

2 files changed

+91
-14
lines changed

2 files changed

+91
-14
lines changed

Scripts/shell.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pkgs.mkShell {
2121
gdb
2222
cmake
2323
ninja
24+
cudaPackages.cuda_cudart
25+
cudaPackages.cuda_nvcc
26+
cudaPackages.cuda_cccl
2427

2528
# rayx-core dependencies
2629
hdf5
@@ -30,6 +33,7 @@ pkgs.mkShell {
3033
vulkan-headers
3134
vulkan-loader
3235
vulkan-validation-layers
36+
vulkan-extension-layer
3337
vulkan-tools
3438
vulkan-tools-lunarg
3539
vulkan-utility-libraries
@@ -52,7 +56,9 @@ pkgs.mkShell {
5256
];
5357

5458
shellHook = ''
55-
export CMAKE_PREFIX_PATH=${pkgs.boost}:${pkgs.hdf5}:${pkgs.cmake}:${pkgs.pkg-config};
59+
export CMAKE_PREFIX_PATH=${pkgs.hdf5}:${pkgs.cmake}:${pkgs.pkg-config}:${pkgs.cudaPackages.cuda_cudart}:${pkgs.vulkan-headers}:${pkgs.vulkan-loader}:${pkgs.vulkan-validation-layers}:${pkgs.vulkan-extension-layer}:${pkgs.vulkan-tools}:${pkgs.vulkan-tools-lunarg}:${pkgs.vulkan-utility-libraries}:${pkgs.cudaPackages.cuda_cccl};
5660
export VK_LAYER_PATH="${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
61+
echo ${pkgs.cudaPackages.cuda_cudart}
62+
echo ${pkgs.cudaPackages.cuda_nvcc}
5763
'';
5864
}

flake.nix

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@
7878
cmake
7979
gcc14 # pin gcc version for cuda version 12 compatibility
8080
llvmPackages.openmp
81+
cudaPackages.cuda_nvcc
82+
cudaPackages.cuda_cccl
8183
ninja
8284
patchelf
8385
];
8486

8587
buildInputs = with pkgs; [
8688
hdf5
8789
cudaPackages.cuda_cudart
88-
cudaPackages.cuda_nvcc
8990
];
9091

9192
configurePhase = ''
@@ -117,7 +118,7 @@
117118
installPhase = ''
118119
mkdir -p $out/bin
119120
cp -r bin/release/Data $out/bin
120-
cp -r bin/release/rayx $out/bin
121+
cp -r bin/release/rayx $out/bin/rayx-cuda
121122
122123
mkdir -p $out/lib
123124
cp -r lib/release/* $out/lib
@@ -170,11 +171,82 @@
170171
installPhase = ''
171172
mkdir -p $out
172173
174+
LOG=$out/rayx-tests-log.txt
173175
RML=../Intern/rayx-core/tests/input/METRIX_U41_G1_H1_318eV_PS_MLearn_v114.rml
176+
174177
# run rayx with valgrind to catch memory issues
175-
valgrind --error-exitcode=42 ./bin/release/rayx -x -V -i $RML |& tee $out/log_rayx.txt
178+
echo "\$ valgrind --error-exitcode=42 ./bin/release/rayx -x -V -i $RML" >> $LOG
179+
valgrind --error-exitcode=42 ./bin/release/rayx -x -V -i $RML |& tee $LOG
180+
181+
echo "" >> $LOG
182+
176183
# run tests
177-
./bin/release/rayx-core-tst -x |& tee $out/log_rayx-core-tst.txt
184+
echo "\$ ./bin/release/rayx-core-tst -x" >> $LOG
185+
echo ./bin/release/rayx-core-tst -x |& tee $LOG
186+
'';
187+
188+
meta.description = "TODO"; # TODO: write description
189+
};
190+
191+
rayx-run-tests-cuda = pkgs.stdenv.mkDerivation {
192+
pname = "rayx-run-tests-cuda";
193+
version = "1.1.0";
194+
inherit src;
195+
196+
nativeBuildInputs = with pkgs; [
197+
cmake
198+
gcc
199+
llvmPackages.openmp
200+
ninja
201+
patchelf
202+
valgrind
203+
cudaPackages.cuda_nvcc
204+
cudaPackages.cuda_cccl
205+
];
206+
207+
buildInputs = with pkgs; [
208+
hdf5
209+
cudaPackages.cuda_cudart
210+
];
211+
212+
configurePhase = ''
213+
mkdir build
214+
cd build
215+
cmake -G Ninja .. \
216+
-DCMAKE_BUILD_TYPE=Release \
217+
-DRAYX_ENABLE_CUDA=ON \
218+
-DRAYX_REQUIRE_CUDA=ON \
219+
-DRAYX_ENABLE_OPENMP=ON \
220+
-DRAYX_REQUIRE_OPENMP=ON \
221+
-DRAYX_ENABLE_H5=ON \
222+
-DRAYX_REQUIRE_H5=ON \
223+
-DRAYX_WERROR=ON \
224+
-DRAYX_BUILD_TESTS=ON \
225+
-DRAYX_BUILD_RAYX_CLI=ON \
226+
-DRAYX_BUILD_RAYX_UI=OFF
227+
'';
228+
229+
buildPhase = ''
230+
ninja -v rayx rayx-core-tst
231+
'';
232+
233+
# TODO: provide a better way to access test input file
234+
# TODO: testing should not be in the build phase, but rayx-core-tst depends on source directory being preset
235+
installPhase = ''
236+
mkdir -p $out
237+
238+
LOG=$out/rayx-tests-cuda-log.txt
239+
RML=../Intern/rayx-core/tests/input/METRIX_U41_G1_H1_318eV_PS_MLearn_v114.rml
240+
241+
# run rayx with valgrind to catch memory issues
242+
echo "\$ valgrind --error-exitcode=42 ./bin/release/rayx -X -V -i $RML" >> $LOG
243+
valgrind --error-exitcode=42 ./bin/release/rayx -X -V -i $RML |& tee $LOG
244+
245+
echo "" >> $LOG
246+
247+
# run tests
248+
echo "\$ ./bin/release/rayx-core-tst -X" >> $LOG
249+
echo ./bin/release/rayx-core-tst -X |& tee $LOG
178250
'';
179251

180252
meta.description = "TODO"; # TODO: write description
@@ -197,7 +269,7 @@
197269

198270
rayx-cuda = pkgs.mkShell {
199271
buildInputs = with pkgs; [
200-
self.packages.${system}.rayx
272+
self.packages.${system}.rayx-cuda
201273
hdf5
202274
cudaPackages.cuda_cudart
203275
];
@@ -207,17 +279,16 @@
207279
'';
208280
};
209281

210-
rayx-run-tests = pkgs.mkShell {
211-
buildInputs = with pkgs; [
212-
self.packages.${system}.rayx-run-tests
213-
];
282+
default = rayx;
283+
};
214284

215-
shellHook = ''
216-
echo "Inspect the test results in log_rayx.txt and log_rayx-core-tst.txt"
285+
apps.${system} = {
286+
rayx-tests = {
287+
type = "app";
288+
program = pkgs.writeShellScript "rayx-tests" ''
289+
cat ${self.packages.${system}.rayx-tests}/rayx-tests-log.txt
217290
'';
218291
};
219-
220-
default = rayx;
221292
};
222293
};
223294
}

0 commit comments

Comments
 (0)