Skip to content

Commit

Permalink
Remove pre-main CUDART usage and setup env in main.
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Apr 5, 2024
1 parent d77f335 commit c5a40d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 0 additions & 2 deletions nvbench/benchmark_base.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <nvbench/axes_metadata.cuh>
#include <nvbench/device_info.cuh>
#include <nvbench/device_manager.cuh>
#include <nvbench/state.cuh>
#include <nvbench/stopping_criterion.cuh>

Expand Down Expand Up @@ -53,7 +52,6 @@ struct benchmark_base
template <typename TypeAxes>
explicit benchmark_base(TypeAxes type_axes)
: m_axes(type_axes)
, m_devices(nvbench::device_manager::get().get_devices())
{}

virtual ~benchmark_base();
Expand Down
19 changes: 8 additions & 11 deletions nvbench/main.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@
#include <cstdlib>
#include <iostream>

static int _nvbench_env [[maybe_unused]] = []() -> int
{
// See NVIDIA/NVBench#136
#ifdef _MSC_VER
int retval = _putenv_s("CUDA_MODULE_LOADING", "EAGER");
#else
int retval = setenv("CUDA_MODULE_LOADING", "EAGER", 1);
#endif
return retval;
}();

#define NVBENCH_MAIN \
int main(int argc, char const *const *argv) \
try \
Expand Down Expand Up @@ -70,9 +59,17 @@ static int _nvbench_env [[maybe_unused]] = []() -> int
nvbench::option_parser parser; \
parser.parse(argc, argv)

// See NVIDIA/NVBench#136 for CUDA_MODULE_LOADING
#ifdef _MSC_VER
#define NVBENCH_INITIALIZE_CUDA_ENV _putenv_s("CUDA_MODULE_LOADING", "EAGER")
#else
#define NVBENCH_INITIALIZE_CUDA_ENV setenv("CUDA_MODULE_LOADING", "EAGER", 1)
#endif

#define NVBENCH_MAIN_BODY(argc, argv) \
do \
{ \
NVBENCH_INITIALIZE_CUDA_ENV; \
NVBENCH_INITIALIZE_DRIVER_API; \
NVBENCH_MAIN_PARSE(argc, argv); \
auto &printer = parser.get_printer(); \
Expand Down
3 changes: 3 additions & 0 deletions nvbench/option_parser.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <nvbench/benchmark_manager.cuh>
#include <nvbench/csv_printer.cuh>
#include <nvbench/criterion_manager.cuh>
#include <nvbench/device_manager.cuh>
#include <nvbench/git_revision.cuh>
#include <nvbench/json_printer.cuh>
#include <nvbench/markdown_printer.cuh>
Expand Down Expand Up @@ -781,6 +782,8 @@ catch (std::exception &e)

void option_parser::replay_global_args()
{
// Initialize benchmark with all devices:
m_benchmarks.back()->set_devices(nvbench::device_manager::get().get_devices());
this->parse_range(m_global_benchmark_args.cbegin(), m_global_benchmark_args.cend());
}

Expand Down

0 comments on commit c5a40d8

Please sign in to comment.