Set CUDA_MODULE_LOADING=EAGER before main. (#157)

* Set `CUDA_MODULE_LOADING=EAGER` before `main`.

Fixes #136

* Portability for `setenv`.

* Remove pre-main CUDART usage and setup env in main.

* Fail examples if they deadlock.

This is the best way we have to diagnose a regression for
NVIDIA/nvbench#136.

* Add an initialize method to benchmark_manager for CUDA-related setup.

Benchmarks are created statically, so their constructors cannot call the CUDA APIs without breaking the CUDA_MODULE_LOAD setup.

This method is called from `main` after the environment has been configured.
This commit is contained in:
Allison Piper
2024-04-06 11:03:42 -04:00
committed by GitHub
parent e8c8877d36
commit a2f88ff790
6 changed files with 39 additions and 2 deletions

View File

@@ -26,6 +26,12 @@ foreach(example_src IN LISTS example_srcs)
COMMAND "$<TARGET_FILE:${example_name}>" --timeout 0.1 --min-time 1e-5
)
# These should not deadlock. If they do, it may be that the CUDA context was created before
# setting CUDA_MODULE_LOAD=EAGER in main, see NVIDIA/nvbench#136.
set_tests_properties(${example_name} PROPERTIES
FAIL_REGULAR_EXPRESSION "Possible Deadlock Detected"
)
add_dependencies(nvbench.example.all ${example_name})
endforeach()