brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 4771e3c Raw
64 lines · c
1// RUN: %libomp-compile-and-run2#include <string.h>3#include <stdlib.h>4 5enum kmp_target_offload_kind {6  tgt_disabled = 0,7  tgt_default = 1,8  tgt_mandatory = 29};10 11extern int __kmpc_get_target_offload();12extern void kmp_set_defaults(char const *str);13 14const char *disabled_examples[] = {15    // Allowed inputs16    "disabled", "DISABLED", "Disabled", "dIsAbLeD", "DiSaBlEd"};17 18const char *default_examples[] = {19    // Allowed inputs20    "default", "DEFAULT", "Default", "deFAulT", "DEfaULt",21    // These should be changed to default (failed match)22    "mandatry", "defaults", "disable", "enabled", "mandatorynot"};23 24const char *mandatory_examples[] = {25    // Allowed inputs26    "mandatory", "MANDATORY", "Mandatory", "manDatoRy", "MANdATOry"};27 28// Return target-offload-var ICV29int get_target_offload_icv() {30#pragma omp parallel31  {}32  return __kmpc_get_target_offload();33}34 35int main() {36  int i;37  const char *omp_target_offload = "OMP_TARGET_OFFLOAD=";38  char buf[80];39 40  for (i = 0; i < sizeof(disabled_examples) / sizeof(char *); ++i) {41    strcpy(buf, omp_target_offload);42    strcat(buf, disabled_examples[i]);43    kmp_set_defaults(buf);44    if (tgt_disabled != get_target_offload_icv())45      return EXIT_FAILURE;46  }47  for (i = 0; i < sizeof(default_examples) / sizeof(char *); ++i) {48    strcpy(buf, omp_target_offload);49    strcat(buf, default_examples[i]);50    kmp_set_defaults(buf);51    if (tgt_default != get_target_offload_icv())52      return EXIT_FAILURE;53  }54  for (i = 0; i < sizeof(mandatory_examples) / sizeof(char *); ++i) {55    strcpy(buf, omp_target_offload);56    strcat(buf, mandatory_examples[i]);57    kmp_set_defaults(buf);58    if (tgt_mandatory != get_target_offload_icv())59      return EXIT_FAILURE;60  }61 62  return EXIT_SUCCESS;63}64