Skip to content

Commit

Permalink
Add nvml::Device::getClock (#285)
Browse files Browse the repository at this point in the history
* Add nvml::Device::getClock
* Update CHANGELOG
* Add test
  • Loading branch information
csbnw authored Jul 2, 2024
1 parent 2e27795 commit e655242
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
- Added `cu::Device::getUUID()`
- Added initial cudawrappers::nvml target
- Added `nvrtc::findIncludePath()`
- Added `nvml::Device::getClock`

### Changed

Expand Down
6 changes: 6 additions & 0 deletions include/cudawrappers/nvml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class Device {
checkNvmlCall(nvmlDeviceGetFieldValues(device_, valuesCount, values));
}

unsigned int getClock(nvmlClockType_t clockType, nvmlClockId_t clockId) {
unsigned int clockMhz;
checkNvmlCall(nvmlDeviceGetClock(device_, clockType, clockId, &clockMhz));
return clockMhz;
}

private:
nvmlDevice_t device_;
};
Expand Down
10 changes: 9 additions & 1 deletion tests/test_nvml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ TEST_CASE("Test nvml::Device with device number", "[device]") {
nvml::Device device(context, 0);
}

TEST_CASE("Test nvml::Device::getClock", "[device]") {
nvml::Context context;
nvml::Device device(context, 0);
const unsigned int clockMHz =
device.getClock(NVML_CLOCK_GRAPHICS, NVML_CLOCK_ID_CURRENT);
REQUIRE(clockMHz > 0);
}

TEST_CASE("Test nvml::Device with device", "[device]") {
cu::init();
cu::Device cu_device(0);
nvml::Context nvml_context;
nvml::Device nvml_device(nvml_context, cu_device);
}
}

0 comments on commit e655242

Please sign in to comment.