Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ROCm/rocm_smi_lib
ROCm SMI LIB
https://github.com/ROCm/rocm_smi_lib
sysadmin trace
Last synced: about 2 months ago
JSON representation
ROCm SMI LIB
- Host: GitHub
- URL: https://github.com/ROCm/rocm_smi_lib
- Owner: ROCm
- License: mit
- Created: 2017-10-30T15:58:46.000Z (almost 7 years ago)
- Default Branch: amd-staging
- Last Pushed: 2024-08-01T10:36:35.000Z (about 2 months ago)
- Last Synced: 2024-08-01T12:02:23.872Z (about 2 months ago)
- Topics: sysadmin, trace
- Language: C++
- Homepage: https://rocm.docs.amd.com/projects/rocm_smi_lib/en/latest/
- Size: 11.3 MB
- Stars: 114
- Watchers: 37
- Forks: 47
- Open Issues: 53
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: License.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
## 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
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.
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:
```c
#include
#include "rocm_smi/rocm_smi.h"
int main() {
rsmi_status_t ret;
uint32_t num_devices;
uint16_t dev_id;// We will skip return code checks for this example, but it
// is recommended to always check this as some calls may not
// apply for some devices or ROCm releasesret = rsmi_init(0);
ret = rsmi_num_monitor_devices(&num_devices);for (int i=0; i < num_devices; ++i) {
ret = rsmi_dev_id_get(i, &dev_id);
// dev_id holds the device ID of device i, upon a
// successful call
}
ret = rsmi_shut_down();
return 0;
}
```