blob: 7fb23893408eacca3867f6710e0dc40394efc5ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// RUN: %libomptarget-compilexx-generic
// RUN: env HSA_XNACK=1 %libomptarget-run-generic 2>&1 \
// RUN: | %fcheck-generic
// RUN: %libomptarget-compilexx-generic
// RUN: env HSA_XNACK=0 %libomptarget-run-generic 2>&1 \
// RUN: | %fcheck-generic -check-prefix=NO_USM
// REQUIRES: unified_shared_memory
// XFAIL: nvptx
// CHECK: SUCCESS
// NO_USM: Not accessible
#include <assert.h>
#include <iostream>
#include <omp.h>
#include <stdio.h>
int main() {
int n = 10000;
int *a = new int[n];
int err = 0;
// program must be executed with HSA_XNACK=1
if (!omp_target_is_accessible(a, n * sizeof(int), /*device_num=*/0))
printf("Not accessible\n");
else {
#pragma omp target teams distribute parallel for
for (int i = 0; i < n; i++)
a[i] = i;
for (int i = 0; i < n; i++)
if (a[i] != i)
err++;
}
printf("%s\n", err == 0 ? "SUCCESS" : "FAIL");
return err;
}
|