-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addresses #48 --------- Co-authored-by: robtfm <[email protected]>
- Loading branch information
Showing
6 changed files
with
143 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#define_import_path test_module | ||
|
||
var<workgroup> atom: atomic<u32>; | ||
|
||
fn entry_point() -> f32 { | ||
atomicStore(&atom, 1u); // atom = 1 | ||
var y = atomicLoad(&atom); // y = 1, atom = 1 | ||
y += atomicAdd(&atom, 2u); // y = 2, atom = 3 | ||
y += atomicSub(&atom, 1u); // y = 5, atom = 2 | ||
y += atomicMax(&atom, 5u); // y = 7, atom = 5 | ||
y += atomicMin(&atom, 4u); // y = 12, atom = 4 | ||
y += atomicExchange(&atom, y); // y = 16, atom = 12 | ||
let exchange = atomicCompareExchangeWeak(&atom, 12u, 0u); | ||
if exchange.exchanged { | ||
y += exchange.old_value; // y = 28, atom = 0 | ||
} | ||
|
||
return f32(y); // 28.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,5 @@ | ||
#import test_module | ||
|
||
fn main() -> f32 { | ||
return test_module::entry_point(); | ||
} |
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,43 @@ | ||
struct gen___atomic_compare_exchange_resultUint4_ { | ||
old_value: u32, | ||
exchanged: bool, | ||
} | ||
|
||
var<workgroup> _naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom: atomic<u32>; | ||
|
||
fn _naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberentry_point() -> f32 { | ||
var y: u32; | ||
|
||
atomicStore((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 1u); | ||
let _e3: u32 = atomicLoad((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom)); | ||
y = _e3; | ||
let _e7: u32 = atomicAdd((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 2u); | ||
let _e8: u32 = y; | ||
y = (_e8 + _e7); | ||
let _e12: u32 = atomicSub((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 1u); | ||
let _e13: u32 = y; | ||
y = (_e13 + _e12); | ||
let _e17: u32 = atomicMax((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 5u); | ||
let _e18: u32 = y; | ||
y = (_e18 + _e17); | ||
let _e22: u32 = atomicMin((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 4u); | ||
let _e23: u32 = y; | ||
y = (_e23 + _e22); | ||
let _e25: u32 = y; | ||
let _e27: u32 = atomicExchange((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), _e25); | ||
let _e28: u32 = y; | ||
y = (_e28 + _e27); | ||
let _e33: gen___atomic_compare_exchange_resultUint4_ = atomicCompareExchangeWeak((&_naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberatom), 12u, 0u); | ||
if _e33.exchanged { | ||
let _e36: u32 = y; | ||
y = (_e36 + _e33.old_value); | ||
} | ||
let _e38: u32 = y; | ||
return f32(_e38); | ||
} | ||
|
||
fn main() -> f32 { | ||
let _e0: f32 = _naga_oil_mod_ORSXG5C7NVXWI5LMMU_memberentry_point(); | ||
return _e0; | ||
} | ||
|
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