Skip to content

Commit b6cf3a2

Browse files
authored
feat: add Gpc and Mem clock offset methods (#61)
Adds getters and setters for gpc_clock_vf_offset and mem_clock_vf_offset. This enables the ability to increase or decrease the base frequency of the pclk and mclk.
1 parent 1ece8b9 commit b6cf3a2

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

nvml-wrapper/src/device.rs

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,116 @@ impl<'nvml> Device<'nvml> {
13221322
}
13231323
}
13241324

1325+
/**
1326+
Gets the GPU clock frequency offset value.
1327+
1328+
# Errors
1329+
1330+
* `Uninitialized`, if the library has not been successfully initialized
1331+
* `InvalidArg`, if this `Device` is invalid
1332+
* `NotSupported`, if this `Device` does not support this feature
1333+
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
1334+
* `UnexpectedVariant`, for which you can read the docs for
1335+
* `Unknown`, on any unexpected error
1336+
1337+
# Device Support
1338+
1339+
Supports all discrete products with unlocked overclocking capabilities.
1340+
*/
1341+
// Checked against local
1342+
// Tested (no-run)
1343+
#[doc(alias = "nvmlDeviceGetGpcClkVfOffset")]
1344+
pub fn gpc_clock_vf_offset(&self) -> Result<i32, NvmlError> {
1345+
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetGpcClkVfOffset.as_ref())?;
1346+
1347+
unsafe {
1348+
let mut offset: c_int = mem::zeroed();
1349+
nvml_try(sym(self.device, &mut offset))?;
1350+
1351+
Ok(offset)
1352+
}
1353+
}
1354+
1355+
/**
1356+
Sets the GPU clock frequency offset value.
1357+
1358+
# Errors
1359+
1360+
* `Uninitialized`, if the library has not been successfully initialized
1361+
* `InvalidArg`, if this `Device` is invalid
1362+
* `NotSupported`, if this `Device` does not support this feature
1363+
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
1364+
* `UnexpectedVariant`, for which you can read the docs for
1365+
* `Unknown`, on any unexpected error
1366+
1367+
# Device Support
1368+
1369+
Supports all discrete products with unlocked overclocking capabilities.
1370+
*/
1371+
// Checked against local
1372+
// Tested (no-run)
1373+
#[doc(alias = "nvmlDeviceGetGpcClkVfOffset")]
1374+
pub fn set_gpc_clock_vf_offset(&self, offset: i32) -> Result<(), NvmlError> {
1375+
let sym = nvml_sym(self.nvml.lib.nvmlDeviceSetGpcClkVfOffset.as_ref())?;
1376+
1377+
unsafe { nvml_try(sym(self.device, offset)) }
1378+
}
1379+
1380+
/**
1381+
Gets the memory clock frequency offset value.
1382+
1383+
# Errors
1384+
1385+
* `Uninitialized`, if the library has not been successfully initialized
1386+
* `InvalidArg`, if this `Device` is invalid
1387+
* `NotSupported`, if this `Device` does not support this feature
1388+
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
1389+
* `UnexpectedVariant`, for which you can read the docs for
1390+
* `Unknown`, on any unexpected error
1391+
1392+
# Device Support
1393+
1394+
Supports all discrete products with unlocked overclocking capabilities.
1395+
*/
1396+
// Checked against local
1397+
// Tested (no-run)
1398+
#[doc(alias = "nvmlDeviceGetGpcMemClkVfOffset")]
1399+
pub fn mem_clock_vf_offset(&self) -> Result<i32, NvmlError> {
1400+
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetMemClkVfOffset.as_ref())?;
1401+
1402+
unsafe {
1403+
let mut offset: c_int = mem::zeroed();
1404+
nvml_try(sym(self.device, &mut offset))?;
1405+
1406+
Ok(offset)
1407+
}
1408+
}
1409+
1410+
/**
1411+
Sets the memory clock frequency offset value.
1412+
1413+
# Errors
1414+
1415+
* `Uninitialized`, if the library has not been successfully initialized
1416+
* `InvalidArg`, if this `Device` is invalid
1417+
* `NotSupported`, if this `Device` does not support this feature
1418+
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
1419+
* `UnexpectedVariant`, for which you can read the docs for
1420+
* `Unknown`, on any unexpected error
1421+
1422+
# Device Support
1423+
1424+
Supports all discrete products with unlocked overclocking capabilities.
1425+
*/
1426+
// Checked against local
1427+
// Tested (no-run)
1428+
#[doc(alias = "nvmlDeviceSetGpcMemClkVfOffset")]
1429+
pub fn set_mem_clock_vf_offset(&self, offset: i32) -> Result<(), NvmlError> {
1430+
let sym = nvml_sym(self.nvml.lib.nvmlDeviceSetMemClkVfOffset.as_ref())?;
1431+
1432+
unsafe { nvml_try(sym(self.device, offset)) }
1433+
}
1434+
13251435
/**
13261436
Gets the intended operating speed of the specified fan as a percentage of the
13271437
maximum fan speed (100%).

0 commit comments

Comments
 (0)