| 1 |
// RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx942 -verify %s -fcuda-is-device |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify %s |
| 3 |
|
| 4 |
#define __device__ __attribute__((device)) |
| 5 |
#define __shared__ __attribute__((shared)) |
| 6 |
|
| 7 |
__device__ float global_float; |
| 8 |
__device__ float global_double; |
| 9 |
|
| 10 |
__device__ void test_global_atomic_fadd_f32_valid(float *ptr, float val) { |
| 11 |
float result; |
| 12 |
result = __builtin_amdgcn_global_atomic_fadd_f32(ptr, val); |
| 13 |
result = __builtin_amdgcn_global_atomic_fadd_f32(&global_float, val); |
| 14 |
} |
| 15 |
|
| 16 |
__device__ void test_global_atomic_fadd_f32_errors(float *ptr, float val, |
| 17 |
__shared__ float *lds_ptr, |
| 18 |
double *ptr_d) { |
| 19 |
float result; |
| 20 |
result = __builtin_amdgcn_global_atomic_fadd_f32(ptr, val, 0); // expected-error{{too many arguments to function call, expected 2, have 3}} |
| 21 |
result = __builtin_amdgcn_global_atomic_fadd_f32(lds_ptr, val); |
| 22 |
result = __builtin_amdgcn_global_atomic_fadd_f32(ptr_d, val); // expected-error{{cannot initialize a parameter of type}} |
| 23 |
} |
| 24 |
|
| 25 |
__device__ void test_global_atomic_fadd_f64_valid(double *ptr, double val) { |
| 26 |
double result; |
| 27 |
result = __builtin_amdgcn_global_atomic_fadd_f64(ptr, val); |
| 28 |
result = __builtin_amdgcn_global_atomic_fadd_f32(&global_double, val); |
| 29 |
} |
| 30 |
|
| 31 |
__device__ void test_global_atomic_fadd_f64_errors(double *ptr, double val, |
| 32 |
__shared__ double *lds_ptr, |
| 33 |
float *ptr_f) { |
| 34 |
double result; |
| 35 |
result = __builtin_amdgcn_global_atomic_fadd_f64(ptr, val, 0); // expected-error{{too many arguments to function call, expected 2, have 3}} |
| 36 |
result = __builtin_amdgcn_global_atomic_fadd_f64(lds_ptr, val); |
| 37 |
result = __builtin_amdgcn_global_atomic_fadd_f64(ptr_f, val); // expected-error{{cannot initialize a parameter of type}} |
| 38 |
} |