
commit 2ac5b61d544fb46a7f74e62729882ba15100bf1f Author: Carl Pearson <pearson@illinois.edu> Date: Fri Sep 20 14:53:10 2019 -0500 changelog in readme commit 1072efa135c840753892d350985129d6ebc88e7e Author: Carl Pearson <pearson@illinois.edu> Date: Fri Sep 20 14:50:09 2019 -0500 clean up gpu_monitor example commit a8b111a84e61d466d1eb3f4ed9133b428f775714 Author: Carl Pearson <pearson@illinois.edu> Date: Fri Sep 20 14:47:52 2019 -0500 add examples/gpu_monitor commit b0a46680c666c06119d74d462acb2e9a69bf7d85 Author: Carl Pearson <pearson@illinois.edu> Date: Fri Sep 20 14:46:12 2019 -0500 update readme commit b8d29e4d89b5ca0e7fffe71dc969e44cbbd53ab9 Author: Carl Pearson <pearson@illinois.edu> Date: Fri Sep 20 14:41:27 2019 -0500 add GPU monitor
37 lines
568 B
C++
37 lines
568 B
C++
#pragma once
|
|
|
|
#ifdef __NVCC__
|
|
#ifndef PERFECT_HAS_CUDA
|
|
#define PERFECT_HAS_CUDA
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef PERFECT_HAS_CUDA
|
|
#include <nvml.h>
|
|
#endif
|
|
|
|
#include "perfect/result.hpp"
|
|
|
|
namespace perfect {
|
|
|
|
/*! initialize the benchmark
|
|
*/
|
|
Result init() {
|
|
static bool init_ = false;
|
|
if (init_)
|
|
return Result::SUCCESS;
|
|
|
|
// init nvml
|
|
#ifdef PERFECT_HAS_CUDA
|
|
nvmlReturn_t ret = nvmlInit();
|
|
if (ret != NVML_SUCCESS) {
|
|
return from_nvml(ret);
|
|
}
|
|
#endif
|
|
|
|
// don't init again if init() called twice
|
|
init_ = true;
|
|
return Result::SUCCESS;
|
|
}
|
|
|
|
}; // namespace perfect
|