| 1 | // Check that mandatory offloading causes various offloading directives to fail |
| 2 | // when omp_get_num_devices() == 0 even if the requested device is the initial |
| 3 | // device. This behavior is proposed for OpenMP 5.2 in OpenMP spec github |
| 4 | // issue 2669. |
| 5 | |
| 6 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda -DDIR=target |
| 7 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 8 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 9 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 10 | |
| 11 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda -DDIR='target teams' |
| 12 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 13 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 14 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 15 | |
| 16 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda -DDIR='target data map(X)' |
| 17 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 18 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 19 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 20 | |
| 21 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda \ |
| 22 | // RUN: -DDIR='target enter data map(to:X)' |
| 23 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 24 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 25 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 26 | |
| 27 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda \ |
| 28 | // RUN: -DDIR='target exit data map(from:X)' |
| 29 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 30 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 31 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 32 | |
| 33 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda \ |
| 34 | // RUN: -DDIR='target update to(X)' |
| 35 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 36 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 37 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 38 | |
| 39 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda \ |
| 40 | // RUN: -DDIR='target update from(X)' |
| 41 | // RUN: env OMP_TARGET_OFFLOAD=mandatory CUDA_VISIBLE_DEVICES= \ |
| 42 | // RUN: %libomptarget-run-fail-nvptx64-nvidia-cuda 2>&1 | \ |
| 43 | // RUN: %fcheck-nvptx64-nvidia-cuda |
| 44 | |
| 45 | // REQUIRES: nvptx64-nvidia-cuda |
| 46 | |
| 47 | #include <omp.h> |
| 48 | #include <stdio.h> |
| 49 | |
| 50 | // CHECK: omptarget fatal error 1: failure of target construct while offloading is mandatory |
| 51 | int main(void) { |
| 52 | int X; |
| 53 | #pragma omp DIR device(omp_get_initial_device()) |
| 54 | ; |
| 55 | return 0; |
| 56 | } |
| 57 | |