-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU][GFX12] Add 16 bit atomic fadd instructions #75917
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
mariusz-sikora-at-amd
merged 9 commits into
llvm:main
from
mariusz-sikora-at-amd:masikora/gfx12-atomic-addf16
Jan 18, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f0920d0
[AMDGPU][GFX12] Add 16 bit atomic fadd instructions
mariusz-sikora-at-amd 12b580b
Merge main into masikora/gfx12-atomic-addf16
mariusz-sikora-at-amd f8c0a07
Use bf16 type
mariusz-sikora-at-amd 415c67d
Merge main into masikora/gfx12-atomic-addf16
mariusz-sikora-at-amd 41752e7
Update tests for <4 x bfloat>
mariusz-sikora-at-amd 130823d
Update image.atomic tests for unused return value
mariusz-sikora-at-amd 549678c
Use explicit global-isel=0 in test
mariusz-sikora-at-amd 8571756
Merge main into masikora/gfx12-atomic-addf16
mariusz-sikora-at-amd ca3c62d
Use mtriple instead of march in tests
mariusz-sikora-at-amd 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
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,92 @@ | ||
// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx1200 \ | ||
// RUN: %s -S -emit-llvm -o - | FileCheck %s | ||
|
||
// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx1200 \ | ||
// RUN: -S -o - %s | FileCheck -check-prefix=GFX12 %s | ||
|
||
mariusz-sikora-at-amd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// REQUIRES: amdgpu-registered-target | ||
|
||
typedef half __attribute__((ext_vector_type(2))) half2; | ||
typedef short __attribute__((ext_vector_type(2))) short2; | ||
|
||
// CHECK-LABEL: test_local_add_2bf16 | ||
// CHECK: call <2 x i16> @llvm.amdgcn.ds.fadd.v2bf16(ptr addrspace(3) %{{.*}}, <2 x i16> % | ||
// GFX12-LABEL: test_local_add_2bf16 | ||
// GFX12: ds_pk_add_rtn_bf16 | ||
short2 test_local_add_2bf16(__local short2 *addr, short2 x) { | ||
return __builtin_amdgcn_ds_atomic_fadd_v2bf16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_local_add_2bf16_noret | ||
// CHECK: call <2 x i16> @llvm.amdgcn.ds.fadd.v2bf16(ptr addrspace(3) %{{.*}}, <2 x i16> % | ||
// GFX12-LABEL: test_local_add_2bf16_noret | ||
// GFX12: ds_pk_add_bf16 | ||
void test_local_add_2bf16_noret(__local short2 *addr, short2 x) { | ||
__builtin_amdgcn_ds_atomic_fadd_v2bf16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_local_add_2f16 | ||
// CHECK: call <2 x half> @llvm.amdgcn.ds.fadd.v2f16(ptr addrspace(3) %{{.*}}, <2 x half> % | ||
// GFX12-LABEL: test_local_add_2f16 | ||
// GFX12: ds_pk_add_rtn_f16 | ||
half2 test_local_add_2f16(__local half2 *addr, half2 x) { | ||
return __builtin_amdgcn_ds_atomic_fadd_v2f16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_local_add_2f16_noret | ||
// CHECK: call <2 x half> @llvm.amdgcn.ds.fadd.v2f16(ptr addrspace(3) %{{.*}}, <2 x half> % | ||
// GFX12-LABEL: test_local_add_2f16_noret | ||
// GFX12: ds_pk_add_f16 | ||
void test_local_add_2f16_noret(__local half2 *addr, half2 x) { | ||
__builtin_amdgcn_ds_atomic_fadd_v2f16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_flat_add_2f16 | ||
// CHECK: call <2 x half> @llvm.amdgcn.flat.atomic.fadd.v2f16.p0.v2f16(ptr %{{.*}}, <2 x half> %{{.*}}) | ||
// GFX12-LABEL: test_flat_add_2f16 | ||
// GFX12: flat_atomic_pk_add_f16 | ||
half2 test_flat_add_2f16(__generic half2 *addr, half2 x) { | ||
return __builtin_amdgcn_flat_atomic_fadd_v2f16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_flat_add_2bf16 | ||
// CHECK: call <2 x i16> @llvm.amdgcn.flat.atomic.fadd.v2bf16.p0(ptr %{{.*}}, <2 x i16> %{{.*}}) | ||
// GFX12-LABEL: test_flat_add_2bf16 | ||
// GFX12: flat_atomic_pk_add_bf16 | ||
short2 test_flat_add_2bf16(__generic short2 *addr, short2 x) { | ||
return __builtin_amdgcn_flat_atomic_fadd_v2bf16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_global_add_half2 | ||
// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %{{.*}}, <2 x half> %{{.*}}) | ||
// GFX12-LABEL: test_global_add_half2 | ||
// GFX12: global_atomic_pk_add_f16 v2, v[0:1], v2, off th:TH_ATOMIC_RETURN | ||
void test_global_add_half2(__global half2 *addr, half2 x) { | ||
half2 *rtn; | ||
*rtn = __builtin_amdgcn_global_atomic_fadd_v2f16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_global_add_half2_noret | ||
// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %{{.*}}, <2 x half> %{{.*}}) | ||
// GFX12-LABEL: test_global_add_half2_noret | ||
// GFX12: global_atomic_pk_add_f16 v[0:1], v2, off | ||
void test_global_add_half2_noret(__global half2 *addr, half2 x) { | ||
__builtin_amdgcn_global_atomic_fadd_v2f16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_global_add_2bf16 | ||
// CHECK: call <2 x i16> @llvm.amdgcn.global.atomic.fadd.v2bf16.p1(ptr addrspace(1) %{{.*}}, <2 x i16> %{{.*}}) | ||
// GFX12-LABEL: test_global_add_2bf16 | ||
// GFX12: global_atomic_pk_add_bf16 v2, v[0:1], v2, off th:TH_ATOMIC_RETURN | ||
void test_global_add_2bf16(__global short2 *addr, short2 x) { | ||
short2 *rtn; | ||
*rtn = __builtin_amdgcn_global_atomic_fadd_v2bf16(addr, x); | ||
} | ||
|
||
// CHECK-LABEL: test_global_add_2bf16_noret | ||
// CHECK: call <2 x i16> @llvm.amdgcn.global.atomic.fadd.v2bf16.p1(ptr addrspace(1) %{{.*}}, <2 x i16> %{{.*}}) | ||
// GFX12-LABEL: test_global_add_2bf16_noret | ||
// GFX12: global_atomic_pk_add_bf16 v[0:1], v2, off | ||
void test_global_add_2bf16_noret(__global short2 *addr, short2 x) { | ||
__builtin_amdgcn_global_atomic_fadd_v2bf16(addr, x); | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see the point in running this all the way to codegen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you suggest ? I copied this test from other builtins-fp-atomics-gfxXX.
I thought this is a good test which covers both llvm intrinsic and ISA generation.