|
7 months ago | |
---|---|---|
.. | ||
.gitignore | 3 years ago | |
CMakeLists.txt | 1 year ago | |
Makefile | 3 years ago | |
README.md | 1 year ago | |
device_query_vs2017.sln | 2 years ago | |
device_query_vs2017.vcxproj | 7 months ago | |
device_query_vs2017.vcxproj.filters | 7 months ago | |
device_query_vs2019.sln | 1 year ago | |
device_query_vs2019.vcxproj | 7 months ago | |
device_query_vs2019.vcxproj.filters | 7 months ago | |
device_query_vs2022.sln | 2 years ago | |
device_query_vs2022.vcxproj | 7 months ago | |
device_query_vs2022.vcxproj.filters | 7 months ago | |
main.cpp | 1 year ago |
README.md
HIP-Basic Device Query Example
Description
This example shows how the target platform and compiler can be identified, as well as how properties from the device may be queried.
Application flow
- Using compiler-defined macros, the target platform and compiler are identified.
- The number of devices in the system is queried, and for each device:
- The device is set as the active device.
- The device properties are queried and a selected set is printed.
- For each device in the system, it is queried and printed whether this device can access its memory.
- If NVIDIA is the target platform, some NVIDIA-specific device properties are printed.
- The amount of total and free memory of the device is queried and printed.
Key APIs and Concepts
-
HIP code can target the AMD and the NVIDIA platform, and it can be compiled with different compilers. Compiler-defined macros can be used in HIP code to write code that is specific to a target or a compiler. See HIP Programming Guide - Distinguishing Compiler Modes for more details.
-
hipGetDeviceCount
returns the number of devices in the system. Some device management API functions take an identifier for each device, which is a monotonically incrementing number starting from zero. Others require the active device to be set, withhipSetDevice
. A full overview of the device management API can be found at HIP API - Device Management.
Demonstrated API Calls
HIP Runtime
__HIP_PLATFORM_AMD__
__HIP_PLATFORM_NVIDIA__
__CUDACC__
hipGetDeviceCount
hipSetDevice
hipGetDeviceProperties
hipDeviceCanAccessPeer
hipMemGetInfo
cudaDeviceGetLimit
cudaLimit::cudaLimitStackSize
cudaLimit::cudaLimitMallocHeapSize