-
Notifications
You must be signed in to change notification settings - Fork 250
Atomic unit tests #898
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
Open
wesselfr
wants to merge
4
commits into
EmbarkStudios:main
Choose a base branch
from
Traverse-Research:atomic-unit-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Atomic unit tests #898
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e4d78bc
Added atomic flag operations
wesselfr b4ce5ba
Added unit tests for atomic operations
wesselfr f949a26
Removed redundant feature flags from the atomic unit tests
wesselfr 2ade8b2
Changed memory scope on failing tests as it seems to fail on the CI S…
wesselfr 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 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 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_and::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,18 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
unsafe { | ||
let old = spirv_std::arch::atomic_compare_exchange::< | ||
_, | ||
{ Scope::Device as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5, 10); | ||
} | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
unsafe { | ||
let old = spirv_std::arch::atomic_exchange::< | ||
_, | ||
{ Scope::Device as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5); | ||
} | ||
} |
This file contains 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,23 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[cfg(target_arch = "spirv")] | ||
use core::arch::asm; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
// Ensure kernel capabilities. | ||
unsafe { asm!("OpCapability Kernel") }; | ||
|
||
let old = unsafe { | ||
spirv_std::arch::atomic_flag_clear::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0)) | ||
}; | ||
} |
This file contains 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,23 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[cfg(target_arch = "spirv")] | ||
use core::arch::asm; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
// Ensure kernel capabilities. | ||
unsafe { asm!("OpCapability Kernel") }; | ||
|
||
let old = unsafe { | ||
spirv_std::arch::atomic_flag_test_and_set::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0)) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_i_add::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,19 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let reference = unsafe { buffer.index_unchecked_mut(0) }; | ||
|
||
let old = unsafe { | ||
spirv_std::arch::atomic_i_decrement::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::NONE.bits() }, | ||
>(reference) | ||
}; | ||
} |
This file contains 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,19 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let reference = unsafe { buffer.index_unchecked_mut(0) }; | ||
|
||
let old = unsafe { | ||
spirv_std::arch::atomic_i_increment::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::NONE.bits() }, | ||
>(reference) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_i_sub::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
unsafe { | ||
let output = spirv_std::arch::atomic_load::< | ||
_, | ||
{ Scope::Device as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0)); | ||
} | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_or::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [i32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_s_max::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [i32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_s_min::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_store::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_u_max::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_u_min::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
This file contains 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,17 @@ | ||
// build-pass | ||
|
||
use spirv_std::{ | ||
arch::IndexUnchecked, | ||
memory::{Scope, Semantics}, | ||
}; | ||
|
||
#[spirv(compute(threads(64)))] | ||
pub fn main(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffer: &mut [u32]) { | ||
let old = unsafe { | ||
spirv_std::arch::atomic_xor::< | ||
_, | ||
{ Scope::Workgroup as u32 }, | ||
{ Semantics::UNIFORM_MEMORY.bits() }, | ||
>(&mut *buffer.index_unchecked_mut(0), 5) | ||
}; | ||
} |
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.
Do we have other tests that do this? My understanding was that we've given up on
Kernel
support (could be wrong though).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.
Kernel
capability is required for the atomic flag operations. Other test that require specific capabilities are the atomic floats, which I've omitted for the reason that the capability is vendor specific (Nvidia only if I'm correct). The same can be done for the atomic flags tests if required