mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
Continuing the work to cover cuda/hip runtime in LLVMOffloadKernel, this PR introduces the `GetErrorName` and `GetErrorString` functions for pretty printing LLVMOffload errors, in a separate `LanguageUtils.cpp` Additionally moves out helper functions ` convertResult` and `getQueueFromStream` into the utils file too. Assisted by GPT-5.5, checked and reviewed manually
45 lines
1.1 KiB
Text
45 lines
1.1 KiB
Text
// clang-format off
|
|
// RUN: %clang++ %flags -foffload-via-llvm --offload-arch=native %s -o %t
|
|
// RUN: %t | %fcheck-generic
|
|
// RUN: %clang++ %flags -foffload-via-llvm --offload-arch=native %s -o %t -fopenmp
|
|
// RUN: %t | %fcheck-generic
|
|
// clang-format on
|
|
|
|
// UNSUPPORTED: aarch64-unknown-linux-gnu
|
|
// UNSUPPORTED: x86_64-unknown-linux-gnu
|
|
// UNSUPPORTED: nvptx64-nvidia-cuda-LTO
|
|
// UNSUPPORTED: amdgcn-amd-amdhsa-LTO
|
|
// UNSUPPORTED: amdgpu-amd-amdhsa-LTO
|
|
// UNSUPPORTED: intelgpu
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
int Count = 0;
|
|
if (hipGetDeviceCount(&Count) != hipSuccess)
|
|
return 1;
|
|
|
|
printf("device count: %d\n", Count);
|
|
// CHECK: device count: {{[1-9][0-9]*}}
|
|
|
|
int Device = -1;
|
|
if (hipGetDevice(&Device) != hipSuccess)
|
|
return 1;
|
|
|
|
printf("device: %d\n", Device);
|
|
// CHECK: device: {{[0-9]+}}
|
|
|
|
if (hipSetDevice(Device) != hipSuccess)
|
|
return 1;
|
|
|
|
int After = -1;
|
|
if (hipGetDevice(&After) != hipSuccess)
|
|
return 1;
|
|
|
|
printf("device after set: %d\n", After);
|
|
// CHECK: device after set: {{[0-9]+}}
|
|
|
|
hipError_t Err = hipSetDevice(-1);
|
|
printf("set invalid device: %u\n", Err);
|
|
// CHECK: set invalid device: 2
|
|
}
|