Skip to content

Commit

Permalink
Add a bit more context info to the benchmark output and make the dlop…
Browse files Browse the repository at this point in the history
…en isolated
  • Loading branch information
achirkin committed Aug 3, 2023
1 parent 1af0342 commit 228b9cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cpp/bench/ann/src/common/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct lib_handle {
void* handle{nullptr};
explicit lib_handle(const std::string& name)
{
handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND | RTLD_NODELETE);
handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL);
if (handle == nullptr) {
auto error_msg = "Failed to load " + name;
auto err = dlerror();
Expand Down
12 changes: 12 additions & 0 deletions cpp/bench/ann/src/common/cuda_stub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ namespace stub {
*device = 0;
return cudaSuccess;
};
[[gnu::weak, gnu::noinline]] cudaError_t cudaDriverGetVersion(int* driver)
{
*driver = 0;
return cudaSuccess;
};
[[gnu::weak, gnu::noinline]] cudaError_t cudaRuntimeGetVersion(int* runtime)
{
*runtime = 0;
return cudaSuccess;
};
[[gnu::weak, gnu::noinline]] cudaError_t cudaGetDeviceProperties(struct cudaDeviceProp* prop,
int device)
{
Expand Down Expand Up @@ -129,6 +139,8 @@ RAFT_DECLARE_CUDART(cudaEventSynchronize);
RAFT_DECLARE_CUDART(cudaEventElapsedTime);
RAFT_DECLARE_CUDART(cudaEventDestroy);
RAFT_DECLARE_CUDART(cudaGetDevice);
RAFT_DECLARE_CUDART(cudaDriverGetVersion);
RAFT_DECLARE_CUDART(cudaRuntimeGetVersion);
RAFT_DECLARE_CUDART(cudaGetDeviceProperties);

#undef RAFT_DECLARE_CUDART
Expand Down
9 changes: 8 additions & 1 deletion cpp/bench/ann/src/common/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ struct cuda_timer {

inline auto cuda_info()
{
int dev;
int dev, driver = 0, runtime = 0;
cudaDriverGetVersion(&driver);
cudaRuntimeGetVersion(&runtime);

cudaDeviceProp device_prop;
cudaGetDevice(&dev);
cudaGetDeviceProperties(&device_prop, dev);
Expand All @@ -151,6 +154,10 @@ inline auto cuda_info()
props.emplace_back("gpu_mem_bus_width", std::to_string(device_prop.memoryBusWidth));
props.emplace_back("gpu_mem_global_size", std::to_string(device_prop.totalGlobalMem));
props.emplace_back("gpu_mem_shared_size", std::to_string(device_prop.sharedMemPerMultiprocessor));
props.emplace_back("gpu_driver_version",
std::to_string(driver / 1000) + "." + std::to_string((driver % 100) / 10));
props.emplace_back("gpu_runtime_version",
std::to_string(runtime / 1000) + "." + std::to_string((runtime % 100) / 10));
return props;
}

Expand Down

0 comments on commit 228b9cc

Please sign in to comment.