Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 wiersze
1.8 KiB
Markdown

2025-03-07 15:20:09 -06:00
# 🛠️ Maintenance Mode Notice 🛠️
2019-02-15 17:23:12 -06:00
2025-05-19 16:03:02 -05:00
Starting with ROCm 7.0, only critical bug fixes will be applied to ROCm-SMI.
2025-03-07 15:20:09 -06:00
For a seamless experience and continued support, please switch to [AMD-SMI](https://github.com/ROCm/amdsmi).
## Use C++ in ROCm SMI
### Device Indices
Many of the functions in the library take a "device index". The device index is a number greater than or equal to 0, and less than the number of devices detected, as determined by `rsmi_num_monitor_devices()`. The index is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different index after a reboot, so an index should not be relied upon to be constant over reboots.
## Hello ROCm SMI
2025-03-07 15:20:09 -06:00
The only required ROCm-SMI call for any program that wants to use ROCm-SMI is the `rsmi_init()` call. This call initializes some internal data structures that will be used by subsequent ROCm-SMI calls.
2019-02-15 17:23:12 -06:00
When ROCm-SMI is no longer being used, `rsmi_shut_down()` should be called. This provides a way to do any releasing of resources that ROCm-SMI may have held. In many cases, this may have no effect, but may be necessary in future versions of the library.
A simple "Hello World" type program that displays the device ID of detected devices would look like this:
2023-05-03 16:15:04 -06:00
```c
2019-02-15 17:23:12 -06:00
#include <stdint.h>
#include "rocm_smi/rocm_smi.h"
int main() {
2020-05-14 14:36:35 -05:00
rsmi_status_t ret;
uint32_t num_devices;
uint16_t dev_id;
// We will skip return code checks for this example, but it
2019-02-15 17:23:12 -06:00
// is recommended to always check this as some calls may not
// apply for some devices or ROCm releases
2020-05-14 14:36:35 -05:00
2019-02-15 17:23:12 -06:00
ret = rsmi_init(0);
ret = rsmi_num_monitor_devices(&num_devices);
2020-05-14 14:36:35 -05:00
2019-02-15 17:23:12 -06:00
for (int i=0; i < num_devices; ++i) {
2019-02-16 13:21:41 -06:00
ret = rsmi_dev_id_get(i, &dev_id);
2019-02-15 17:23:12 -06:00
// dev_id holds the device ID of device i, upon a
2020-05-14 14:36:35 -05:00
// successful call
}
2019-02-15 17:23:12 -06:00
ret = rsmi_shut_down();
return 0;
}
```