Place obj file in seperate dir - #494
Conversation
according to CUDA docs https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#objdir-as-tempdir-objtemp same file compiled with different options under same directory will fail or create incorrect result with -objdir-as-tempdir
|
See #372 (comment) IIRC, objtemp is not mandatory to achieve reproducible build. The key is the random seed thing. |
Thanks for the info. seems nvcc_fixed_random_seed_feature only works with cuda > 12.9 ? I'm working with 12.6 so not sure how this affect build behavior. according to https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#frandom-seed-frandom-seed it affect symbol/variable name generation. and --objdump affect temp file path embedded in achive file so both should be required. for my 12.6 cuda environment, set |
|
prior to 12.9, there is no way to stably make the build reproducible, IIUC. Because nvcc almost always encode full path info in the final artifact, and objtemp itself is not stable... |
I did a quick check by running strings ( grep '/' and cpp) on the generated library.a and looking for embedded absolute paths. before adding After adding those options, the corresponding paths became relative: IIUC, the bazel-out/k8-fastbuild/bin prefix should remain stable as long as the same configuration is used, so these paths should be treated as deterministic, or did I miss something ? When you say that objtemp itself is not stable prior to CUDA 12.9, do you mean that using -objtemp may cause nvcc to crash or produce incorrect output, or that it can still generate nondeterministic artifacts under some conditions? |
|
it can still generate nondeterministic artifacts. |
without --objdir-as-tempdir, nvcc will put temp cpp file under shared /tmp directory, while multi compile running in parallel, they create non-deterministic file. using
llvm-nm -a cuda_library.a |grep tmpit might shows
tmpxft_00000002_00000000-6_kernel.cudafe1.cpportmpxft_00000002_00000001-6_kernel.cudafe1.cppapply --objdir-as-tempdir arguments fix this by place stable file under object directory , it explicitly declared same file compiled with different options shouldn't be in same directory. rules_cuda now placed object file and pic object file under same directory, which might break --objdir-as-tempdir.
this PR address this by place output under different category folder.
Note: test is written by codex, revert place-file-under-category commit confirms the test failed as expected.