brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · 668b0db Raw
68 lines · plain
1// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.02// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DGENERIC3// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DCONSTANT4// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DLOCAL5 6/* USM (unified shared memory) extension for OpenCLC 2.0 adds two new address7 * spaces: global_device and global_host that are a subset of __global address8 * space. As ISO/IEC TR 18037 5.1.3 declares - it's possible to implicitly9 * convert a subset address space to a superset address space, while conversion10 * in a reversed direction could be achieved only with an explicit cast */11 12#ifdef GENERIC13#define AS_COMP __generic14#else15#define AS_COMP __global16#endif // GENERIC17 18#ifdef CONSTANT19#define AS_INCOMP __constant20#elif LOCAL21#define AS_INCOMP __local22#else // PRIVATE23#define AS_INCOMP __private24#endif // CONSTANT25 26void test(AS_COMP int *arg_comp,27          __attribute__((opencl_global_device)) int *arg_device,28          __attribute__((opencl_global_host)) int *arg_host) {29  AS_COMP int *var_glob1 = arg_device;30  AS_COMP int *var_glob2 = arg_host;31  AS_COMP int *var_glob3 = (AS_COMP int *)arg_device;32  AS_COMP int *var_glob4 = (AS_COMP int *)arg_host;33  arg_device = (__attribute__((opencl_global_device)) int *)arg_comp;34  arg_host = (__attribute__((opencl_global_host)) int *)arg_comp;35#ifdef GENERIC36  // expected-error@+6{{assigning '__generic int *__private' to '__global_device int *__private' changes address space of pointer}}37  // expected-error@+6{{assigning '__generic int *__private' to '__global_host int *__private' changes address space of pointer}}38#else39  // expected-error@+3{{assigning '__global int *__private' to '__global_device int *__private' changes address space of pointer}}40  // expected-error@+3{{assigning '__global int *__private' to '__global_host int *__private' changes address space of pointer}}41#endif // GENERIC42  arg_device = arg_comp;43  arg_host = arg_comp;44 45#ifdef CONSTANT46  // expected-error@+15{{initializing '__constant int *__private' with an expression of type '__global_device int *__private' changes address space of pointer}}47  // expected-error@+15{{initializing '__constant int *__private' with an expression of type '__global_host int *__private' changes address space of pointer}}48  // expected-error@+15{{initializing '__constant int *__private' with an expression of type '__global_device int *' changes address space of pointer}}49  // expected-error@+16{{initializing '__constant int *__private' with an expression of type '__global_host int *' changes address space of pointer}}50#elif LOCAL51  // expected-error@+10{{initializing '__local int *__private' with an expression of type '__global_device int *__private' changes address space of pointer}}52  // expected-error@+10{{initializing '__local int *__private' with an expression of type '__global_host int *__private' changes address space of pointer}}53  // expected-error@+10{{initializing '__local int *__private' with an expression of type '__global_device int *' changes address space of pointer}}54  // expected-error@+11{{initializing '__local int *__private' with an expression of type '__global_host int *' changes address space of pointer}}55#else // PRIVATE56  // expected-error@+5{{initializing '__private int *__private' with an expression of type '__global_device int *__private' changes address space of pointer}}57  // expected-error@+5{{initializing '__private int *__private' with an expression of type '__global_host int *__private' changes address space of pointer}}58  // expected-error@+5{{initializing '__private int *__private' with an expression of type '__global_device int *' changes address space of pointer}}59  // expected-error@+6{{initializing '__private int *__private' with an expression of type '__global_host int *' changes address space of pointer}}60#endif // CONSTANT61  AS_INCOMP int *var_incomp1 = arg_device;62  AS_INCOMP int *var_incomp2 = arg_host;63  AS_INCOMP int *var_incomp3 =64      (__attribute__((opencl_global_device)) int *)arg_device;65  AS_INCOMP int *var_incomp4 =66      (__attribute__((opencl_global_host)) int *)arg_host;67}68