1617a3babSopenharmony_ci#version 450 core 2617a3babSopenharmony_ci 3617a3babSopenharmony_ci#extension GL_KHR_memory_scope_semantics : enable 4617a3babSopenharmony_ci#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable 5617a3babSopenharmony_ci#extension GL_EXT_shader_atomic_float2: enable 6617a3babSopenharmony_ci#pragma use_vulkan_memory_model 7617a3babSopenharmony_ci 8617a3babSopenharmony_cilayout(local_size_x = 16, local_size_y = 16) in; 9617a3babSopenharmony_ci 10617a3babSopenharmony_cilayout(binding = 0) buffer Buffer 11617a3babSopenharmony_ci{ 12617a3babSopenharmony_ci float16_t datah; 13617a3babSopenharmony_ci float dataf; 14617a3babSopenharmony_ci double datad; 15617a3babSopenharmony_ci} buf; 16617a3babSopenharmony_ci 17617a3babSopenharmony_cishared float16_t atomh; 18617a3babSopenharmony_cishared float atomf; 19617a3babSopenharmony_cishared double atomd; 20617a3babSopenharmony_ci 21617a3babSopenharmony_cilayout(binding = 0, r32f) volatile coherent uniform image1D fimage1D; 22617a3babSopenharmony_cilayout(binding = 1, r32f) volatile coherent uniform image1DArray fimage1DArray; 23617a3babSopenharmony_cilayout(binding = 2, r32f) volatile coherent uniform image2D fimage2D; 24617a3babSopenharmony_cilayout(binding = 3, r32f) volatile coherent uniform image2DArray fimage2DArray; 25617a3babSopenharmony_cilayout(binding = 4, r32f) volatile coherent uniform image2DRect fimage2DRect; 26617a3babSopenharmony_cilayout(binding = 5, r32f) volatile coherent uniform imageCube fimageCube; 27617a3babSopenharmony_cilayout(binding = 6, r32f) volatile coherent uniform imageCubeArray fimageCubeArray; 28617a3babSopenharmony_cilayout(binding = 9, r32f) volatile coherent uniform image3D fimage3D; 29617a3babSopenharmony_ci 30617a3babSopenharmony_civoid main() 31617a3babSopenharmony_ci{ 32617a3babSopenharmony_ci //atomicAdd 33617a3babSopenharmony_ci float16_t resulth = float16_t(0.0); 34617a3babSopenharmony_ci resulth = atomicAdd(atomh, float16_t(3.0)); 35617a3babSopenharmony_ci resulth = atomicAdd(atomh, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 36617a3babSopenharmony_ci resulth = atomicAdd(buf.datah, float16_t(3.0)); 37617a3babSopenharmony_ci resulth = atomicAdd(buf.datah, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 38617a3babSopenharmony_ci 39617a3babSopenharmony_ci //atomicMin 40617a3babSopenharmony_ci resulth = atomicMin(atomh, float16_t(3.0)); 41617a3babSopenharmony_ci resulth = atomicMin(atomh, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 42617a3babSopenharmony_ci resulth = atomicMin(buf.datah, float16_t(3.0)); 43617a3babSopenharmony_ci resulth = atomicMin(buf.datah, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 44617a3babSopenharmony_ci 45617a3babSopenharmony_ci float resultf = 0.0; 46617a3babSopenharmony_ci resultf = atomicMin(atomf, 3.0); 47617a3babSopenharmony_ci resultf = atomicMin(atomf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 48617a3babSopenharmony_ci resultf = atomicMin(buf.dataf, 3.0); 49617a3babSopenharmony_ci resultf = atomicMin(buf.dataf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 50617a3babSopenharmony_ci 51617a3babSopenharmony_ci double resultd = 0.0; 52617a3babSopenharmony_ci resultd = atomicMin(atomd, 3.0); 53617a3babSopenharmony_ci resultd = atomicMin(atomd, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 54617a3babSopenharmony_ci resultd = atomicMin(buf.datad, 3.0); 55617a3babSopenharmony_ci resultd = atomicMin(buf.datad, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 56617a3babSopenharmony_ci 57617a3babSopenharmony_ci //atomicMax 58617a3babSopenharmony_ci resulth = atomicMax(atomh, float16_t(3.0)); 59617a3babSopenharmony_ci resulth = atomicMax(atomh, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 60617a3babSopenharmony_ci resulth = atomicMax(buf.datah, float16_t(3.0)); 61617a3babSopenharmony_ci resulth = atomicMax(buf.datah, float16_t(4.5), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 62617a3babSopenharmony_ci 63617a3babSopenharmony_ci resultf = atomicMax(atomf, 3.0); 64617a3babSopenharmony_ci resultf = atomicMax(atomf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 65617a3babSopenharmony_ci resultf = atomicMax(buf.dataf, 3.0); 66617a3babSopenharmony_ci resultf = atomicMax(buf.dataf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 67617a3babSopenharmony_ci 68617a3babSopenharmony_ci resultd = atomicMax(atomd, 3.0); 69617a3babSopenharmony_ci resultd = atomicMax(atomd, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 70617a3babSopenharmony_ci resultd = atomicMax(buf.datad, 3.0); 71617a3babSopenharmony_ci resultd = atomicMax(buf.datad, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 72617a3babSopenharmony_ci 73617a3babSopenharmony_ci //atomicExchange 74617a3babSopenharmony_ci resulth = atomicExchange(buf.datah, resulth); 75617a3babSopenharmony_ci buf.datah += resulth; 76617a3babSopenharmony_ci resulth = atomicExchange(buf.datah, resulth, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 77617a3babSopenharmony_ci buf.datah += resulth; 78617a3babSopenharmony_ci resulth = atomicExchange(atomh, resulth); 79617a3babSopenharmony_ci buf.datah += resulth; 80617a3babSopenharmony_ci resulth = atomicExchange(atomh, resulth, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 81617a3babSopenharmony_ci buf.datah += resulth; 82617a3babSopenharmony_ci 83617a3babSopenharmony_ci //atomic load/store 84617a3babSopenharmony_ci resulth = atomicLoad(buf.datah, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 85617a3babSopenharmony_ci atomicStore(buf.datah, resulth, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 86617a3babSopenharmony_ci buf.datah += resulth; 87617a3babSopenharmony_ci 88617a3babSopenharmony_ci resulth = atomicLoad(atomh, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 89617a3babSopenharmony_ci atomicStore(atomh, resulth, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed); 90617a3babSopenharmony_ci buf.datah += resulth; 91617a3babSopenharmony_ci 92617a3babSopenharmony_ci // image atomics on 1D: 93617a3babSopenharmony_ci atomf = imageAtomicMin(fimage1D, int(0), 2.0); 94617a3babSopenharmony_ci buf.dataf += atomf; 95617a3babSopenharmony_ci atomf = imageAtomicMin(fimage1D, int(1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 96617a3babSopenharmony_ci buf.dataf += atomf; 97617a3babSopenharmony_ci 98617a3babSopenharmony_ci atomf = imageAtomicMax(fimage1D, int(0), 2.0); 99617a3babSopenharmony_ci buf.dataf += atomf; 100617a3babSopenharmony_ci atomf = imageAtomicMax(fimage1D, int(1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 101617a3babSopenharmony_ci buf.dataf += atomf; 102617a3babSopenharmony_ci 103617a3babSopenharmony_ci // image atomics on 1D Array: 104617a3babSopenharmony_ci atomf = imageAtomicMin(fimage1DArray, ivec2(0,0), 2.0); 105617a3babSopenharmony_ci buf.dataf += atomf; 106617a3babSopenharmony_ci atomf = imageAtomicMin(fimage1DArray, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 107617a3babSopenharmony_ci buf.dataf += atomf; 108617a3babSopenharmony_ci 109617a3babSopenharmony_ci atomf = imageAtomicMax(fimage1DArray, ivec2(0,0), 2.0); 110617a3babSopenharmony_ci buf.dataf += atomf; 111617a3babSopenharmony_ci atomf = imageAtomicMax(fimage1DArray, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 112617a3babSopenharmony_ci buf.dataf += atomf; 113617a3babSopenharmony_ci 114617a3babSopenharmony_ci // image atomics on 2D: 115617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2D, ivec2(0,0), 2.0); 116617a3babSopenharmony_ci buf.dataf += atomf; 117617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2D, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 118617a3babSopenharmony_ci buf.dataf += atomf; 119617a3babSopenharmony_ci 120617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2D, ivec2(0,0), 2.0); 121617a3babSopenharmony_ci buf.dataf += atomf; 122617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2D, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 123617a3babSopenharmony_ci buf.dataf += atomf; 124617a3babSopenharmony_ci 125617a3babSopenharmony_ci // image atomics on 2D Rect: 126617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2DRect, ivec2(0,0), 2.0); 127617a3babSopenharmony_ci buf.dataf += atomf; 128617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2DRect, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 129617a3babSopenharmony_ci buf.dataf += atomf; 130617a3babSopenharmony_ci 131617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2DRect, ivec2(0,0), 2.0); 132617a3babSopenharmony_ci buf.dataf += atomf; 133617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2DRect, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 134617a3babSopenharmony_ci buf.dataf += atomf; 135617a3babSopenharmony_ci 136617a3babSopenharmony_ci // image atomics on 2D Array: 137617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2DArray, ivec3(0,0,0), 2.0); 138617a3babSopenharmony_ci buf.dataf += atomf; 139617a3babSopenharmony_ci atomf = imageAtomicMin(fimage2DArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 140617a3babSopenharmony_ci buf.dataf += atomf; 141617a3babSopenharmony_ci 142617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2DArray, ivec3(0,0,0), 2.0); 143617a3babSopenharmony_ci buf.dataf += atomf; 144617a3babSopenharmony_ci atomf = imageAtomicMax(fimage2DArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 145617a3babSopenharmony_ci buf.dataf += atomf; 146617a3babSopenharmony_ci 147617a3babSopenharmony_ci // image atomics on Cube: 148617a3babSopenharmony_ci atomf = imageAtomicMin(fimageCube, ivec3(0,0,0), 2.0); 149617a3babSopenharmony_ci buf.dataf += atomf; 150617a3babSopenharmony_ci atomf = imageAtomicMin(fimageCube, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 151617a3babSopenharmony_ci buf.dataf += atomf; 152617a3babSopenharmony_ci 153617a3babSopenharmony_ci atomf = imageAtomicMax(fimageCube, ivec3(0,0,0), 2.0); 154617a3babSopenharmony_ci buf.dataf += atomf; 155617a3babSopenharmony_ci atomf = imageAtomicMax(fimageCube, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 156617a3babSopenharmony_ci buf.dataf += atomf; 157617a3babSopenharmony_ci 158617a3babSopenharmony_ci // image atomics on Cube Array: 159617a3babSopenharmony_ci atomf = imageAtomicMin(fimageCubeArray, ivec3(0,0,0), 2.0); 160617a3babSopenharmony_ci buf.dataf += atomf; 161617a3babSopenharmony_ci atomf = imageAtomicMin(fimageCubeArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 162617a3babSopenharmony_ci buf.dataf += atomf; 163617a3babSopenharmony_ci 164617a3babSopenharmony_ci atomf = imageAtomicMax(fimageCubeArray, ivec3(0,0,0), 2.0); 165617a3babSopenharmony_ci buf.dataf += atomf; 166617a3babSopenharmony_ci atomf = imageAtomicMax(fimageCubeArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 167617a3babSopenharmony_ci buf.dataf += atomf; 168617a3babSopenharmony_ci 169617a3babSopenharmony_ci // image atomics on 3D: 170617a3babSopenharmony_ci atomf = imageAtomicMin(fimage3D, ivec3(0,0,0), 2.0); 171617a3babSopenharmony_ci buf.dataf += atomf; 172617a3babSopenharmony_ci atomf = imageAtomicMin(fimage3D, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 173617a3babSopenharmony_ci buf.dataf += atomf; 174617a3babSopenharmony_ci 175617a3babSopenharmony_ci atomf = imageAtomicMax(fimage3D, ivec3(0,0,0), 2.0); 176617a3babSopenharmony_ci buf.dataf += atomf; 177617a3babSopenharmony_ci atomf = imageAtomicMax(fimage3D, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed); 178617a3babSopenharmony_ci buf.dataf += atomf; 179617a3babSopenharmony_ci} 180