Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/BuiltinsAMDGPU.def
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_f64, "dd*0d", "t", "gfx90a-inst
TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmin_f64, "dd*0d", "t", "gfx90a-insts")
TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmax_f64, "dd*0d", "t", "gfx90a-insts")

TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f64, "dd*3d", "t", "gfx90a-insts")
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f32, "ff*3f", "t", "gfx8-insts")
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f64, "dd*3d", "", "gfx90a-insts")
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f32, "ff*3f", "", "gfx8-insts")

TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_f32, "ff*0f", "t", "gfx940-insts")
TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2f16, "V2hV2h*0V2h", "t", "atomic-flat-pk-add-16-insts")
Expand Down
33 changes: 33 additions & 0 deletions clang/test/SemaHIP/amdgpu-ds-atomic-fadd-err.hip
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx90a -verify=device,both %s -fcuda-is-device
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify=host,both %s

#define __device__ __attribute__((device))
#define __shared__ __attribute__((shared))

__device__ void test_ds_atomic_fadd_f32_valid(__shared__ float *lds_ptr, float val) {
float result;
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val);
}

__device__ void test_ds_atomic_fadd_f32_errors(__shared__ float *lds_ptr, float val,
__shared__ double *lds_ptr_d,
float *global_ptr) {
float result;
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val, 0); // both-error{{too many arguments to function call, expected 2, have 3}}
result = __builtin_amdgcn_ds_atomic_fadd_f32(global_ptr, val);
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 *'}}
}

__device__ void test_ds_atomic_fadd_f64_valid(__shared__ double *lds_ptr, double val) {
double result;
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val);
}

__device__ void test_ds_atomic_fadd_f64_errors(__shared__ double *lds_ptr, double val,
__shared__ float *lds_ptr_f,
double *global_ptr) {
double result;
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val, 0); // both-error{{too many arguments to function call, expected 2, have 3}}
result = __builtin_amdgcn_ds_atomic_fadd_f64(global_ptr, val);
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 *'}}
}
29 changes: 29 additions & 0 deletions clang/test/SemaOpenCL/amdgpu-ds-atomic-fadd-err.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %clang_cc1 -fsyntax-only -cl-std=CL2.0 -triple amdgcn -target-cpu gfx90a -verify %s

kernel void test_ds_atomic_fadd_f32_valid(__local float *lds_ptr, float val) {
float result;
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val);
}

kernel void test_ds_atomic_fadd_f32_errors(__local float *lds_ptr, float val,
__local double *lds_ptr_d,
__global float *global_ptr) {
float result;
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr, val, 0); // expected-error{{too many arguments to function call, expected 2, have 3}}
result = __builtin_amdgcn_ds_atomic_fadd_f32(global_ptr, val); // expected-error{{passing '__global float *__private' to parameter of type '__local float *' changes address space of pointer}}
result = __builtin_amdgcn_ds_atomic_fadd_f32(lds_ptr_d, val); // expected-error{{incompatible pointer types passing '__local double *__private' to parameter of type '__local float *'}}
}

kernel void test_ds_atomic_fadd_f64_valid(__local double *lds_ptr, double val) {
double result;
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val);
}

kernel void test_ds_atomic_fadd_f64_errors(__local double *lds_ptr, double val,
__local float *lds_ptr_f,
__global double *global_ptr) {
double result;
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr, val, 0); // expected-error{{too many arguments to function call, expected 2, have 3}}
result = __builtin_amdgcn_ds_atomic_fadd_f64(global_ptr, val);// expected-error{{passing '__global double *__private' to parameter of type '__local double *' changes address space of pointer}}
result = __builtin_amdgcn_ds_atomic_fadd_f64(lds_ptr_f, val); // expected-error{{incompatible pointer types passing '__local float *__private' to parameter of type '__local double *'}}
}