-
Notifications
You must be signed in to change notification settings - Fork 968
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
327 additions
and
7 deletions.
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
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,23 @@ | ||
( | ||
god_mode: true, | ||
spv: ( | ||
version: (1, 0), | ||
capabilities: [ Int64, Int64ImageEXT, Int64Atomics ], | ||
), | ||
hlsl: ( | ||
shader_model: V6_0, | ||
binding_map: {}, | ||
fake_missing_bindings: true, | ||
special_constants_binding: Some((space: 1, register: 0)), | ||
push_constants_target: Some((space: 0, register: 0)), | ||
zero_initialize_workgroup_memory: true, | ||
), | ||
msl: ( | ||
lang_version: (3, 1), | ||
per_entry_point_map: {}, | ||
inline_samplers: [], | ||
spirv_cross_compatibility: false, | ||
fake_missing_bindings: true, | ||
zero_initialize_workgroup_memory: true, | ||
), | ||
) |
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,34 @@ | ||
const SIZE: u64 = 128u; | ||
|
||
@group(0) @binding(0) | ||
var<storage,read_write> arr_i64: array<atomic<i64>, SIZE>; | ||
@group(0) @binding(1) | ||
var<storage,read_write> arr_u64: array<atomic<u64>, SIZE>; | ||
|
||
@compute @workgroup_size(1) | ||
fn test_atomic_compare_exchange_i64() { | ||
for(var i = 0u; i < SIZE; i++) { | ||
var old = atomicLoad(&arr_i64[i]); | ||
var exchanged = false; | ||
while(!exchanged) { | ||
let new_ = bitcast<i64>(bitcast<f32>(old) + 1.0); | ||
let result = atomicCompareExchangeWeak(&arr_i64[i], old, new_); | ||
old = result.old_value; | ||
exchanged = result.exchanged; | ||
} | ||
} | ||
} | ||
|
||
@compute @workgroup_size(1) | ||
fn test_atomic_compare_exchange_u64() { | ||
for(var i = 0u; i < SIZE; i++) { | ||
var old = atomicLoad(&arr_u64[i]); | ||
var exchanged = false; | ||
while(!exchanged) { | ||
let new_ = bitcast<u64>(bitcast<f32>(old) + 1.0); | ||
let result = atomicCompareExchangeWeak(&arr_u64[i], old, new_); | ||
old = result.old_value; | ||
exchanged = result.exchanged; | ||
} | ||
} | ||
} |
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 @@ | ||
( | ||
god_mode: true, | ||
spv: ( | ||
version: (1, 0), | ||
capabilities: [ Int64, Int64ImageEXT, Int64Atomics ], | ||
), | ||
hlsl: ( | ||
shader_model: V6_0, | ||
binding_map: {}, | ||
fake_missing_bindings: true, | ||
special_constants_binding: Some((space: 1, register: 0)), | ||
push_constants_target: Some((space: 0, register: 0)), | ||
zero_initialize_workgroup_memory: true, | ||
), | ||
msl: ( | ||
lang_version: (3, 1), | ||
per_entry_point_map: {}, | ||
inline_samplers: [], | ||
spirv_cross_compatibility: false, | ||
fake_missing_bindings: true, | ||
zero_initialize_workgroup_memory: true, | ||
), | ||
) |
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,141 @@ | ||
// This test covers the cross product of: | ||
// | ||
// * All atomic operations. | ||
// * On all applicable scopes (storage read-write, workgroup). | ||
// * For all shapes of modeling atomic data. | ||
|
||
struct Struct { | ||
atomic_scalar: atomic<u64>, | ||
atomic_arr: array<atomic<i64>, 2>, | ||
} | ||
|
||
@group(0) @binding(0) | ||
var<storage, read_write> storage_atomic_scalar: atomic<u64>; | ||
@group(0) @binding(1) | ||
var<storage, read_write> storage_atomic_arr: array<atomic<i64>, 2>; | ||
@group(0) @binding(2) | ||
var<storage, read_write> storage_struct: Struct; | ||
|
||
var<workgroup> workgroup_atomic_scalar: atomic<u64>; | ||
var<workgroup> workgroup_atomic_arr: array<atomic<i64>, 2>; | ||
var<workgroup> workgroup_struct: Struct; | ||
|
||
@compute | ||
@workgroup_size(2) | ||
fn cs_main(@builtin(local_invocation_id) id: vec3<u64>) { | ||
atomicStore(&storage_atomic_scalar, 1lu); | ||
atomicStore(&storage_atomic_arr[1], 1li); | ||
atomicStore(&storage_struct.atomic_scalar, 1lu); | ||
atomicStore(&storage_struct.atomic_arr[1], 1li); | ||
atomicStore(&workgroup_atomic_scalar, 1lu); | ||
atomicStore(&workgroup_atomic_arr[1], 1li); | ||
atomicStore(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicStore(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
let l0 = atomicLoad(&storage_atomic_scalar); | ||
let l1 = atomicLoad(&storage_atomic_arr[1]); | ||
let l2 = atomicLoad(&storage_struct.atomic_scalar); | ||
let l3 = atomicLoad(&storage_struct.atomic_arr[1]); | ||
let l4 = atomicLoad(&workgroup_atomic_scalar); | ||
let l5 = atomicLoad(&workgroup_atomic_arr[1]); | ||
let l6 = atomicLoad(&workgroup_struct.atomic_scalar); | ||
let l7 = atomicLoad(&workgroup_struct.atomic_arr[1]); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicAdd(&storage_atomic_scalar, 1lu); | ||
atomicAdd(&storage_atomic_arr[1], 1li); | ||
atomicAdd(&storage_struct.atomic_scalar, 1lu); | ||
atomicAdd(&storage_struct.atomic_arr[1], 1li); | ||
atomicAdd(&workgroup_atomic_scalar, 1lu); | ||
atomicAdd(&workgroup_atomic_arr[1], 1li); | ||
atomicAdd(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicAdd(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicSub(&storage_atomic_scalar, 1lu); | ||
atomicSub(&storage_atomic_arr[1], 1li); | ||
atomicSub(&storage_struct.atomic_scalar, 1lu); | ||
atomicSub(&storage_struct.atomic_arr[1], 1li); | ||
atomicSub(&workgroup_atomic_scalar, 1lu); | ||
atomicSub(&workgroup_atomic_arr[1], 1li); | ||
atomicSub(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicSub(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicMax(&storage_atomic_scalar, 1lu); | ||
atomicMax(&storage_atomic_arr[1], 1li); | ||
atomicMax(&storage_struct.atomic_scalar, 1lu); | ||
atomicMax(&storage_struct.atomic_arr[1], 1li); | ||
atomicMax(&workgroup_atomic_scalar, 1lu); | ||
atomicMax(&workgroup_atomic_arr[1], 1li); | ||
atomicMax(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicMax(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicMin(&storage_atomic_scalar, 1lu); | ||
atomicMin(&storage_atomic_arr[1], 1li); | ||
atomicMin(&storage_struct.atomic_scalar, 1lu); | ||
atomicMin(&storage_struct.atomic_arr[1], 1li); | ||
atomicMin(&workgroup_atomic_scalar, 1lu); | ||
atomicMin(&workgroup_atomic_arr[1], 1li); | ||
atomicMin(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicMin(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicAnd(&storage_atomic_scalar, 1lu); | ||
atomicAnd(&storage_atomic_arr[1], 1li); | ||
atomicAnd(&storage_struct.atomic_scalar, 1lu); | ||
atomicAnd(&storage_struct.atomic_arr[1], 1li); | ||
atomicAnd(&workgroup_atomic_scalar, 1lu); | ||
atomicAnd(&workgroup_atomic_arr[1], 1li); | ||
atomicAnd(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicAnd(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicOr(&storage_atomic_scalar, 1lu); | ||
atomicOr(&storage_atomic_arr[1], 1li); | ||
atomicOr(&storage_struct.atomic_scalar, 1lu); | ||
atomicOr(&storage_struct.atomic_arr[1], 1li); | ||
atomicOr(&workgroup_atomic_scalar, 1lu); | ||
atomicOr(&workgroup_atomic_arr[1], 1li); | ||
atomicOr(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicOr(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
workgroupBarrier(); | ||
|
||
atomicXor(&storage_atomic_scalar, 1lu); | ||
atomicXor(&storage_atomic_arr[1], 1li); | ||
atomicXor(&storage_struct.atomic_scalar, 1lu); | ||
atomicXor(&storage_struct.atomic_arr[1], 1li); | ||
atomicXor(&workgroup_atomic_scalar, 1lu); | ||
atomicXor(&workgroup_atomic_arr[1], 1li); | ||
atomicXor(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicXor(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
atomicExchange(&storage_atomic_scalar, 1lu); | ||
atomicExchange(&storage_atomic_arr[1], 1li); | ||
atomicExchange(&storage_struct.atomic_scalar, 1lu); | ||
atomicExchange(&storage_struct.atomic_arr[1], 1li); | ||
atomicExchange(&workgroup_atomic_scalar, 1lu); | ||
atomicExchange(&workgroup_atomic_arr[1], 1li); | ||
atomicExchange(&workgroup_struct.atomic_scalar, 1lu); | ||
atomicExchange(&workgroup_struct.atomic_arr[1], 1li); | ||
|
||
// // TODO: https://github.com/gpuweb/gpuweb/issues/2021 | ||
// atomicCompareExchangeWeak(&storage_atomic_scalar, 1lu); | ||
// atomicCompareExchangeWeak(&storage_atomic_arr[1], 1li); | ||
// atomicCompareExchangeWeak(&storage_struct.atomic_scalar, 1lu); | ||
// atomicCompareExchangeWeak(&storage_struct.atomic_arr[1], 1li); | ||
// atomicCompareExchangeWeak(&workgroup_atomic_scalar, 1lu); | ||
// atomicCompareExchangeWeak(&workgroup_atomic_arr[1], 1li); | ||
// atomicCompareExchangeWeak(&workgroup_struct.atomic_scalar, 1lu); | ||
// atomicCompareExchangeWeak(&workgroup_struct.atomic_arr[1], 1li); | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
god_mode: true, | ||
spv: ( | ||
version: (1, 0), | ||
capabilities: [ Int64 ], | ||
), | ||
hlsl: ( | ||
shader_model: V6_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
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
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
Oops, something went wrong.