blob: 5fb66e6e45eebbfd41a13668ec2965808179263e [file]
// 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
}