| 1 |
// RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx90a -verify=device,both %s -fcuda-is-device |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify=host,both %s |
| 3 |
|
| 4 |
#define __device__ __attribute__((device)) |
| 5 |
#define __shared__ __attribute__((shared)) |
| 6 |
|
| 7 |
__device__ void test_ds_atomic_fadd_f32_valid(__shared__ float *lds_ptr, float val) { |
| 8 |
float result; |
| 9 |
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val); |
| 10 |
} |
| 11 |
|
| 12 |
__device__ void test_ds_atomic_fadd_f32_errors(__shared__ float *lds_ptr, float val, |
| 13 |
__shared__ double *lds_ptr_d, |
| 14 |
float *global_ptr) { |
| 15 |
float result; |
| 16 |
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val, 0); // both-error{{too many arguments to function call, expected 2, have 3}} |
| 17 |
result = __builtin_amdgcn_ds_atomic_fadd_f32(global_ptr, val); |
| 18 |
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr_d, val); // device-error{{cannot initialize a parameter of type '__shared__ float *' with an rvalue of type '__shared__ double *'}} host-error{{cannot initialize a parameter of type '__attribute__((address_space(3))) float *' with an rvalue of type '__attribute__((address_space(3))) double *'}} |
| 19 |
} |
| 20 |
|
| 21 |
__device__ void test_ds_atomic_fadd_f64_valid(__shared__ double *lds_ptr, double val) { |
| 22 |
double result; |
| 23 |
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val); |
| 24 |
} |
| 25 |
|
| 26 |
__device__ void test_ds_atomic_fadd_f64_errors(__shared__ double *lds_ptr, double val, |
| 27 |
__shared__ float *lds_ptr_f, |
| 28 |
double *global_ptr) { |
| 29 |
double result; |
| 30 |
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val, 0); // both-error{{too many arguments to function call, expected 2, have 3}} |
| 31 |
result = __builtin_amdgcn_ds_atomic_fadd_f64(global_ptr, val); |
| 32 |
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr_f, val); // device-error{{cannot initialize a parameter of type '__shared__ double *' with an rvalue of type '__shared__ float *'}} host-error{{cannot initialize a parameter of type '__attribute__((address_space(3))) double *' with an rvalue of type '__attribute__((address_space(3))) float *'}} |
| 33 |
} |