CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
// Copyright Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include <hip/hip_runtime_api.h>
|
|
|
|
#include <iostream>
|
|
|
|
int main(int argc, char **argv) {
|
|
int device_ordinal = -1;
|
|
if (argc > 1) {
|
|
try {
|
|
device_ordinal = std::stoi(argv[1]);
|
|
} catch (std::exception &e) {
|
|
std::cerr << "could not parse device ordinal from command line: "
|
|
<< e.what() << "\n";
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int runtime_version;
|
|
auto err = hipRuntimeGetVersion(&runtime_version);
|
|
if (err != hipSuccess) {
|
|
std::cerr << "Error getting runtime version: " << err << "\n";
|
|
return 2;
|
|
}
|
|
std::cout << "HIP runtime version: " << runtime_version << "\n";
|
|
err = hipInit(0);
|
|
if (device_ordinal < 0) {
|
|
// Not testing actual device - just linkage and ability to run at all.
|
|
std::cout << "Not testing on GPU device (no device ordinal passed)\n";
|
|
return 0;
|
|
}
|
|
if (err != hipSuccess) {
|
|
std::cerr << "Error initializing HIP: " << err << " (ignored)\n";
|
|
return 3;
|
|
}
|
|
|
|
// Get the device.
|
|
hipDevice_t device;
|
|
err = hipDeviceGet(&device, device_ordinal);
|
|
if (err != hipSuccess) {
|
|
std::cerr << "Error getting device ordinal " << device_ordinal << "\n";
|
|
return 4;
|
|
}
|
|
|
|
// Get device name.
|
|
char device_name[80];
|
|
err = hipDeviceGetName(device_name, sizeof(device_name) - 1, device);
|
|
if (err != hipSuccess) {
|
|
std::cerr << "Error getting device name \n";
|
|
return 5;
|
|
}
|
|
std::cout << "Device name: " << device_name << "\n";
|
|
|
|
// Get device memory.
|
|
size_t memory_size;
|
|
err = hipDeviceTotalMem(&memory_size, device);
|
|
if (err != hipSuccess) {
|
|
std::cerr << "Error getting device memory\n";
|
|
return 6;
|
|
}
|
|
std::cout << "Device memory: " << (memory_size / 1024 / 1024) << " MiB\n";
|
|
|
|
return 0;
|
|
}
|