brintos

brintos / llvm-project-archived public Read only

0
0
Text · 907 B · 7fb2389 Raw
41 lines · cpp
1// RUN: %libomptarget-compilexx-generic2// RUN: env HSA_XNACK=1 %libomptarget-run-generic 2>&1 \3// RUN: | %fcheck-generic4 5// RUN: %libomptarget-compilexx-generic6// RUN: env HSA_XNACK=0 %libomptarget-run-generic 2>&1 \7// RUN: | %fcheck-generic -check-prefix=NO_USM8 9// REQUIRES: unified_shared_memory10// XFAIL: nvptx11 12// CHECK: SUCCESS13// NO_USM: Not accessible14 15#include <assert.h>16#include <iostream>17#include <omp.h>18#include <stdio.h>19 20int main() {21  int n = 10000;22  int *a = new int[n];23  int err = 0;24 25  // program must be executed with HSA_XNACK=126  if (!omp_target_is_accessible(a, n * sizeof(int), /*device_num=*/0))27    printf("Not accessible\n");28  else {29#pragma omp target teams distribute parallel for30    for (int i = 0; i < n; i++)31      a[i] = i;32 33    for (int i = 0; i < n; i++)34      if (a[i] != i)35        err++;36  }37 38  printf("%s\n", err == 0 ? "SUCCESS" : "FAIL");39  return err;40}41