// Copyright (c) Advanced Micro Devices, Inc., or its affiliates. // // SPDX-License-Identifier: MIT // [sphinx-start] #include #include #include #define HIP_CHECK(expression) \ { \ const hipError_t status = expression; \ if (status != hipSuccess) \ { \ std::cerr << "HIP error " << status \ << ": " << hipGetErrorString(status) \ << " at " << __FILE__ << ":" \ << __LINE__ << std::endl; \ std::exit(EXIT_FAILURE); \ } \ } int main() { int deviceCount; HIP_CHECK(hipGetDeviceCount(&deviceCount)); std::cout << "Number of devices: " << deviceCount << std::endl; for (int deviceId = 0; deviceId < deviceCount; ++deviceId) { hipDeviceProp_t deviceProp; HIP_CHECK(hipGetDeviceProperties(&deviceProp, deviceId)); std::cout << "Device " << deviceId << std::endl << " Properties:" << std::endl; std::cout << " Name: " << deviceProp.name << std::endl; std::cout << " Total Global Memory: " << deviceProp.totalGlobalMem / (1024 * 1024) << " MiB" << std::endl; std::cout << " Shared Memory per Block: " << deviceProp.sharedMemPerBlock / 1024 << " KiB" << std::endl; std::cout << " Registers per Block: " << deviceProp.regsPerBlock << std::endl; std::cout << " Warp Size: " << deviceProp.warpSize << std::endl; std::cout << " Max Threads per Block: " << deviceProp.maxThreadsPerBlock << std::endl; std::cout << " Max Threads per Multiprocessor: " << deviceProp.maxThreadsPerMultiProcessor << std::endl; std::cout << " Number of Multiprocessors: " << deviceProp.multiProcessorCount << std::endl; std::cout << " Max Threads Dimensions: [" << deviceProp.maxThreadsDim[0] << ", " << deviceProp.maxThreadsDim[1] << ", " << deviceProp.maxThreadsDim[2] << "]" << std::endl; std::cout << " Max Grid Size: [" << deviceProp.maxGridSize[0] << ", " << deviceProp.maxGridSize[1] << ", " << deviceProp.maxGridSize[2] << "]" << std::endl; std::cout << std::endl; } return EXIT_SUCCESS; } // [sphinx-end]