-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[Clang][AMDGPU] Accept builtins in lambda declarations #135027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
clang/test/SemaHIP/amdgpu-builtin-in-lambda-with-unsupported-attribute.hip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// REQUIRES: amdgpu-registered-target | ||
// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu tahiti -emit-llvm -fcuda-is-device -verify=no-memrealtime -o - %s | ||
// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx950 -emit-llvm -fcuda-is-device -o - %s | ||
|
||
#define __device__ __attribute__((device)) | ||
#define __shared__ __attribute__((shared)) | ||
|
||
struct S { | ||
static constexpr auto memrealtime_lambda = []() { | ||
__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} | ||
}; | ||
}; | ||
|
||
__attribute__((target("s-memrealtime"))) | ||
__device__ void test_target_dependant_builtin_attr_fail() { | ||
S::memrealtime_lambda(); | ||
} | ||
|
||
constexpr auto memrealtime_lambda = []() { | ||
__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} | ||
}; | ||
|
||
__attribute__((target("s-memrealtime"))) | ||
__device__ void global_test_target_dependant_builtin_attr_fail() { | ||
memrealtime_lambda(); | ||
} | ||
|
||
__attribute__((target("s-memrealtime"))) | ||
__device__ void local_test_target_dependant_builtin_attr_fail() { | ||
static constexpr auto f = []() { | ||
__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} | ||
}; | ||
f(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx90a -fsyntax-only -fcuda-is-device -verify=gfx90a -o - %s | ||
// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx950 -fsyntax-only -fcuda-is-device -o - %s | ||
|
||
#define __device__ __attribute__((device)) | ||
#define __shared__ __attribute__((shared)) | ||
|
||
struct S { | ||
static constexpr auto make_buffer_rsrc_lambda = [](void *p, short stride, int num, int flags) { | ||
return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); | ||
}; | ||
|
||
static constexpr auto global_load_lds_lambda = [](void* src, __shared__ void *dst) { | ||
__builtin_amdgcn_global_load_lds(src, dst, 16, 0, 0); // gfx90a-error{{invalid size value}} gfx90a-note{{size must be 1, 2, or 4}} | ||
}; | ||
}; | ||
|
||
__device__ __amdgpu_buffer_rsrc_t test_simple_builtin(void *p, short stride, int num, int flags) { | ||
return S::make_buffer_rsrc_lambda(p, stride, num, flags); | ||
} | ||
|
||
__device__ void test_target_dependant_builtin(void *src, __shared__ void *dst) { | ||
S::global_load_lds_lambda(src, dst); | ||
} | ||
|
||
constexpr auto make_buffer_rsrc_lambda = [](void *p, short stride, int num, int flags) { | ||
return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); | ||
}; | ||
|
||
constexpr auto global_load_lds_lambda = [](void* src, __shared__ void *dst) { | ||
__builtin_amdgcn_global_load_lds(src, dst, 16, 0, 0); // gfx90a-error{{invalid size value}} gfx90a-note{{size must be 1, 2, or 4}} | ||
}; | ||
|
||
__device__ __amdgpu_buffer_rsrc_t global_test_simple_builtin(void *p, short stride, int num, int flags) { | ||
return make_buffer_rsrc_lambda(p, stride, num, flags); | ||
} | ||
|
||
__device__ void global_test_target_dependant_builtin(void *src, __shared__ void *dst) { | ||
global_load_lds_lambda(src, dst); | ||
} | ||
|
||
__device__ __amdgpu_buffer_rsrc_t local_test_simple_builtin(void *p, short stride, int num, int flags) { | ||
constexpr auto f = [](void *p, short stride, int num, int flags) { | ||
return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); | ||
}; | ||
return f(p, stride, num, flags); | ||
} | ||
|
||
__device__ void local_test_target_dependant_builtin(void *src, __shared__ void *dst) { | ||
constexpr auto f = [](void* src, __shared__ void *dst) { | ||
__builtin_amdgcn_global_load_lds(src, dst, 16, 0, 0); // gfx90a-error{{invalid size value}} gfx90a-note{{size must be 1, 2, or 4}} | ||
}; | ||
f(src, dst); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.