brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · f7b37d9 Raw
85 lines · c
1// RUN: %libomptarget-compile-amdgcn-amd-amdhsa2// RUN:   %libomptarget-run-generic 2>&1 | \3// RUN:   %fcheck-amdgcn-amd-amdhsa -check-prefixes=AMD4 5// RUN: %libomptarget-compile-nvptx64-nvidia-cuda6// RUN:   %libomptarget-run-generic 2>&1 | \7// RUN:   %fcheck-nvptx64-nvidia-cuda -check-prefixes=NVIDIA8 9// REQUIRES: gpu10// XFAIL: nvptx64-nvidia-cuda11// XFAIL: nvptx64-nvidia-cuda-LTO12 13#include <omp.h>14#include <stdio.h>15 16const char *interop_int_to_string(const int interop_int) {17  switch (interop_int) {18  case 1:19    return "cuda";20  case 2:21    return "cuda_driver";22  case 3:23    return "opencl";24  case 4:25    return "sycl";26  case 5:27    return "hip";28  case 6:29    return "level_zero";30  case 7:31    return "hsa";32  default:33    return "unknown";34  }35}36 37int main(int argc, char **argv) {38 39  // Loop over all available devices40  for (int id = 0; id < omp_get_num_devices(); ++id) {41    omp_interop_t iobj = omp_interop_none;42 43    // TODO: Change targetsync to target when AMD toolchain supports it.44#pragma omp interop init(target : iobj) device(id)45 46    int err;47    int interop_int = omp_get_interop_int(iobj, omp_ipr_fr_id, &err);48 49    if (err) {50      fprintf(stderr, "omp_get_interop_int failed: %d\n", err);51      return -1;52    }53 54    // AMD: {{.*}} hsa55    // NVIDIA: {{.*}} cuda56    printf("omp_get_interop_int returned %s\n",57           interop_int_to_string(interop_int));58 59    const char *interop_vendor =60        omp_get_interop_str(iobj, omp_ipr_vendor_name, &err);61    if (err) {62      fprintf(stderr, "omp_get_interop_str failed: %d\n", err);63      return -1;64    }65 66    // AMD: {{.*}} amd67    // NVIDIA: {{.*}} nvidia68    printf("omp_get_interop_str returned %s\n", interop_vendor);69 70    const char *interop_fr_name =71        omp_get_interop_str(iobj, omp_ipr_fr_name, &err);72    if (err) {73      fprintf(stderr, "omp_get_interop_str failed: %d\n", err);74      return -1;75    }76 77    // AMD: {{.*}} hsa78    // NVIDIA: {{.*}} cuda79    printf("omp_get_interop_str returned %s\n", interop_fr_name);80 81#pragma omp interop destroy(iobj)82  }83  return 0;84}85