Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure nvbench initializes nvml context when built statically #486

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions rapids-cmake/cpm/patches/nvbench/nvml_with_static_builds.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/nvbench/device_info.cu b/nvbench/device_info.cu
index 8edad22..a09def3 100644
--- a/nvbench/device_info.cu
+++ b/nvbench/device_info.cu
@@ -25,6 +25,10 @@

#include <cuda_runtime_api.h>

+#ifdef NVBENCH_HAS_NVML
+#include <nvbench/internal/nvml.cxx>
+#endif
+
#define UNUSED(x) (void)(x)

namespace nvbench
@@ -47,6 +51,10 @@ device_info::device_info(int id)
NVBENCH_CUDA_CALL(cudaGetDeviceProperties(&m_prop, m_id));

#ifdef NVBENCH_HAS_NVML
+ // NVML's lifetime should extend for the entirety of the process, so store in a
+ // global.
+ [[maybe_unused]] static auto nvml_lifetime = NVMLLifetimeManager();
+
// Retrieve the current device's pci_id as a null-terminated string.
// Docs say 13 chars should always be sufficient.
constexpr int pci_id_len = 13;
diff --git a/nvbench/internal/nvml.cxx b/nvbench/internal/nvml.cxx
index 4f750bc..ce7d874 100644
--- a/nvbench/internal/nvml.cxx
+++ b/nvbench/internal/nvml.cxx
@@ -64,8 +64,4 @@ private:
bool m_inited{false};
};

-// NVML's lifetime should extend for the entirety of the process, so store in a
-// global.
-auto nvml_lifetime = NVMLLifetimeManager{};
-
} // namespace
9 changes: 8 additions & 1 deletion rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@
"version" : "0.0",
"git_shallow" : false,
"git_url" : "https://github.com/NVIDIA/nvbench.git",
"git_tag" : "b8f0f6b5832dd632006492fd2434c81fdef0f2de"
"git_tag" : "b8f0f6b5832dd632006492fd2434c81fdef0f2de",
"patches" : [
{
"file" : "nvbench/nvml_with_static_builds.diff",
"issue" : "Add support for nvml with static nvbench [https://github.com/NVIDIA/nvbench/pull/148]",
"fixed_in" : ""
}
]
},
"nvcomp" : {
"version" : "3.0.4",
Expand Down