-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[AMDGPU][SPIRV] Use SPIR-V syncscopes for some AMDGCN BIs #154867
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
Changes from 1 commit
f65fa1d
4d6413c
577d516
e744e4d
71bf5b3
bfd0192
e76680e
e15d1da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,7 +194,7 @@ static Value *emitFPIntBuiltin(CodeGenFunction &CGF, | |
|
|
||
| // For processing memory ordering and memory scope arguments of various | ||
| // amdgcn builtins. | ||
| // \p Order takes a C++11 comptabile memory-ordering specifier and converts | ||
| // \p Order takes a C++11 compatible memory-ordering specifier and converts | ||
| // it into LLVM's memory ordering specifier using atomic C ABI, and writes | ||
| // to \p AO. \p Scope takes a const char * and converts it into AMDGCN | ||
| // specific SyncScopeID and writes it to \p SSID. | ||
|
|
@@ -227,6 +227,12 @@ void CodeGenFunction::ProcessOrderScopeAMDGCN(Value *Order, Value *Scope, | |
| // Some of the atomic builtins take the scope as a string name. | ||
| StringRef scp; | ||
| if (llvm::getConstantStringInfo(Scope, scp)) { | ||
| if (getTarget().getTriple().isSPIRV()) { | ||
| if (scp == "agent") | ||
| scp = "device"; | ||
| else if (scp == "wavefront") | ||
| scp = "subgroup"; | ||
| } | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID(scp); | ||
| return; | ||
| } | ||
|
|
@@ -238,13 +244,19 @@ void CodeGenFunction::ProcessOrderScopeAMDGCN(Value *Order, Value *Scope, | |
| SSID = llvm::SyncScope::System; | ||
| break; | ||
| case 1: // __MEMORY_SCOPE_DEVICE | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("agent"); | ||
| if (getTarget().getTriple().isSPIRV()) | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("device"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will they be translate back to agent when we convert SPIRV to bitcode for amdgcn? Do we have lit tests to cover that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, reverse translation maps from SPIR-V to AMDGPU; we don't test this in LLVM yet because we don't use the BE, yet, reverse translation is done in the OOT translator. |
||
| else | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("agent"); | ||
| break; | ||
| case 2: // __MEMORY_SCOPE_WRKGRP | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("workgroup"); | ||
| break; | ||
| case 3: // __MEMORY_SCOPE_WVFRNT | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("wavefront"); | ||
| if (getTarget().getTriple().isSPIRV()) | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("subgroup"); | ||
| else | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("wavefront"); | ||
| break; | ||
| case 4: // __MEMORY_SCOPE_SINGLE | ||
| SSID = llvm::SyncScope::SingleThread; | ||
|
|
@@ -1381,7 +1393,10 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, | |
| // | ||
| // The global/flat cases need to use agent scope to consistently produce | ||
| // the native instruction instead of a cmpxchg expansion. | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("agent"); | ||
| if (getTarget().getTriple().isSPIRV()) | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("device"); | ||
| else | ||
| SSID = getLLVMContext().getOrInsertSyncScopeID("agent"); | ||
| AO = AtomicOrdering::Monotonic; | ||
|
|
||
| // The v2bf16 builtin uses i16 instead of a natural bfloat type. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.