mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
This PR expands LLVMOffloadKernel's error types with `ErrorInvalidResourceHandle` and `ErrorInvalidConfiguration`. It also adds a language local, thread local LastError which can be read/retrieved with `PeekAtLastError`/`GetLastError` respectively. Tests are in #213390 Assisted by GPT-5.5, checked and reviewed manually
81 lines
3 KiB
Text
81 lines
3 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>
|
|
|
|
static void print_error(const char *Label, hipError_t Error) {
|
|
printf("%s value: %u\n", Label, static_cast<unsigned>(Error));
|
|
printf("%s name: %s\n", Label, hipGetErrorName(Error));
|
|
printf("%s string: %s\n", Label, hipGetErrorString(Error));
|
|
}
|
|
|
|
int main() {
|
|
print_error("success", hipSuccess);
|
|
// CHECK: success value: 0
|
|
// CHECK: success name: hipSuccess
|
|
// CHECK: success string: No error
|
|
|
|
print_error("invalid value", hipErrorInvalidValue);
|
|
// CHECK: invalid value value: 1
|
|
// CHECK: invalid value name: hipErrorInvalidValue
|
|
// CHECK: invalid value string: Invalid argument value
|
|
|
|
print_error("invalid device", hipErrorInvalidDevice);
|
|
// CHECK: invalid device value: 2
|
|
// CHECK: invalid device name: hipErrorInvalidDevice
|
|
// CHECK: invalid device string: Invalid device number
|
|
|
|
print_error("unknown", hipErrorUnknown);
|
|
// CHECK: unknown value: 3
|
|
// CHECK: unknown name: Unrecognized error
|
|
// CHECK: unknown string: Unknown error
|
|
|
|
print_error("invalid resource handle", hipErrorInvalidResourceHandle);
|
|
// CHECK: invalid resource handle value: 4
|
|
// CHECK: invalid resource handle name: hipErrorInvalidResourceHandle
|
|
// CHECK: invalid resource handle string: Invalid resource handle
|
|
|
|
print_error("invalid configuration", hipErrorInvalidConfiguration);
|
|
// CHECK: invalid configuration value: 5
|
|
// CHECK: invalid configuration name: hipErrorInvalidConfiguration
|
|
// CHECK: invalid configuration string: Invalid configuration argument
|
|
|
|
hipError_t Unrecognized = static_cast<hipError_t>(999);
|
|
print_error("unrecognized", Unrecognized);
|
|
// CHECK: unrecognized value: 999
|
|
// CHECK: unrecognized name: Unrecognized error
|
|
// CHECK: unrecognized string: Unrecognized error
|
|
|
|
print_error("set invalid device", hipSetDevice(-1));
|
|
// CHECK: set invalid device value: 2
|
|
// CHECK: set invalid device name: hipErrorInvalidDevice
|
|
// CHECK: set invalid device string: Invalid device number
|
|
|
|
print_error("get last error", hipGetLastError());
|
|
// CHECK: get last error value: 2
|
|
// CHECK: get last error name: hipErrorInvalidDevice
|
|
// CHECK: get last error string: Invalid device number
|
|
|
|
print_error("cleared last error", hipGetLastError());
|
|
// CHECK: cleared last error value: 0
|
|
// CHECK: cleared last error name: hipSuccess
|
|
// CHECK: cleared last error string: No error
|
|
|
|
print_error("null stream destroy", hipStreamDestroy(nullptr));
|
|
// CHECK: null stream destroy value: 1
|
|
// CHECK: null stream destroy name: hipErrorInvalidValue
|
|
// CHECK: null stream destroy string: Invalid argument value
|
|
|
|
return 0;
|
|
}
|