1e5c31af7Sopenharmony_ci#!amber 2e5c31af7Sopenharmony_ci# Copyright 2019 The Amber Authors. 3e5c31af7Sopenharmony_ci# 4e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 5e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 6e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 7e5c31af7Sopenharmony_ci# 8e5c31af7Sopenharmony_ci# https://www.apache.org/licenses/LICENSE-2.0 9e5c31af7Sopenharmony_ci# 10e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 11e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 12e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 14e5c31af7Sopenharmony_ci# limitations under the License. 15e5c31af7Sopenharmony_ci 16e5c31af7Sopenharmony_ciDEVICE_EXTENSION VK_KHR_storage_buffer_storage_class 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ciSHADER compute my_compute SPIRV-ASM 19e5c31af7Sopenharmony_ciOpCapability Shader 20e5c31af7Sopenharmony_ciOpExtension "SPV_KHR_storage_buffer_storage_class" 21e5c31af7Sopenharmony_ciOpMemoryModel Logical GLSL450 22e5c31af7Sopenharmony_ciOpEntryPoint GLCompute %main "main" %lid_var %gid_var %idx_var %wgid_var 23e5c31af7Sopenharmony_ciOpDecorate %lid_var BuiltIn LocalInvocationId 24e5c31af7Sopenharmony_ciOpDecorate %gid_var BuiltIn GlobalInvocationId 25e5c31af7Sopenharmony_ciOpDecorate %idx_var BuiltIn LocalInvocationIndex 26e5c31af7Sopenharmony_ciOpDecorate %wgid_var BuiltIn WorkgroupId 27e5c31af7Sopenharmony_ciOpDecorate %wg_size BuiltIn WorkgroupSize 28e5c31af7Sopenharmony_ciOpDecorate %x SpecId 1 29e5c31af7Sopenharmony_ciOpDecorate %y SpecId 2 30e5c31af7Sopenharmony_ciOpDecorate %z SpecId 3 31e5c31af7Sopenharmony_ciOpDecorate %struct Block 32e5c31af7Sopenharmony_ciOpMemberDecorate %struct 0 Offset 0 33e5c31af7Sopenharmony_ciOpDecorate %rta ArrayStride 4 34e5c31af7Sopenharmony_ciOpDecorate %x_var DescriptorSet 0 35e5c31af7Sopenharmony_ciOpDecorate %x_var Binding 0 36e5c31af7Sopenharmony_ciOpDecorate %y_var DescriptorSet 0 37e5c31af7Sopenharmony_ciOpDecorate %y_var Binding 1 38e5c31af7Sopenharmony_ciOpDecorate %z_var DescriptorSet 0 39e5c31af7Sopenharmony_ciOpDecorate %z_var Binding 2 40e5c31af7Sopenharmony_ciOpDecorate %s_var DescriptorSet 0 41e5c31af7Sopenharmony_ciOpDecorate %s_var Binding 3 42e5c31af7Sopenharmony_ci%void = OpTypeVoid 43e5c31af7Sopenharmony_ci%int = OpTypeInt 32 0 44e5c31af7Sopenharmony_ci%int_0 = OpConstant %int 0 45e5c31af7Sopenharmony_ci%device = OpConstant %int 1 46e5c31af7Sopenharmony_ci%relaxed = OpConstant %int 0 47e5c31af7Sopenharmony_ci%int3 = OpTypeVector %int 3 48e5c31af7Sopenharmony_ci%x = OpSpecConstant %int 1 49e5c31af7Sopenharmony_ci%y = OpSpecConstant %int 1 50e5c31af7Sopenharmony_ci%z = OpSpecConstant %int 1 51e5c31af7Sopenharmony_ci%wg_size = OpSpecConstantComposite %int3 %x %y %z 52e5c31af7Sopenharmony_ci%rta = OpTypeRuntimeArray %int 53e5c31af7Sopenharmony_ci%struct = OpTypeStruct %rta 54e5c31af7Sopenharmony_ci%ptr_input_int3 = OpTypePointer Input %int3 55e5c31af7Sopenharmony_ci%ptr_input_int = OpTypePointer Input %int 56e5c31af7Sopenharmony_ci%lid_var = OpVariable %ptr_input_int3 Input 57e5c31af7Sopenharmony_ci%gid_var = OpVariable %ptr_input_int3 Input 58e5c31af7Sopenharmony_ci%idx_var = OpVariable %ptr_input_int Input 59e5c31af7Sopenharmony_ci%wgid_var = OpVariable %ptr_input_int3 Input 60e5c31af7Sopenharmony_ci%ptr_ssbo_struct = OpTypePointer StorageBuffer %struct 61e5c31af7Sopenharmony_ci%ptr_ssbo_int = OpTypePointer StorageBuffer %int 62e5c31af7Sopenharmony_ci%x_var = OpVariable %ptr_ssbo_struct StorageBuffer 63e5c31af7Sopenharmony_ci%y_var = OpVariable %ptr_ssbo_struct StorageBuffer 64e5c31af7Sopenharmony_ci%z_var = OpVariable %ptr_ssbo_struct StorageBuffer 65e5c31af7Sopenharmony_ci%s_var = OpVariable %ptr_ssbo_struct StorageBuffer 66e5c31af7Sopenharmony_ci%void_fn = OpTypeFunction %void 67e5c31af7Sopenharmony_ci%main = OpFunction %void None %void_fn 68e5c31af7Sopenharmony_ci%entry = OpLabel 69e5c31af7Sopenharmony_ci%lid = OpLoad %int3 %lid_var 70e5c31af7Sopenharmony_ci%lid_x = OpCompositeExtract %int %lid 0 71e5c31af7Sopenharmony_ci%lid_y = OpCompositeExtract %int %lid 1 72e5c31af7Sopenharmony_ci%lid_z = OpCompositeExtract %int %lid 2 73e5c31af7Sopenharmony_ci%gid = OpLoad %int3 %gid_var 74e5c31af7Sopenharmony_ci%gid_x = OpCompositeExtract %int %gid 0 75e5c31af7Sopenharmony_ci%gid_y = OpCompositeExtract %int %gid 1 76e5c31af7Sopenharmony_ci%gid_z = OpCompositeExtract %int %gid 2 77e5c31af7Sopenharmony_ci%wgid = OpLoad %int3 %wgid_var 78e5c31af7Sopenharmony_ci%wgid_x = OpCompositeExtract %int %wgid 0 79e5c31af7Sopenharmony_ci%wgid_y = OpCompositeExtract %int %wgid 1 80e5c31af7Sopenharmony_ci%wgid_z = OpCompositeExtract %int %wgid 2 81e5c31af7Sopenharmony_ci%local_index = OpLoad %int %idx_var 82e5c31af7Sopenharmony_ci%wg_x = OpCompositeExtract %int %wg_size 0 83e5c31af7Sopenharmony_ci%wg_y = OpCompositeExtract %int %wg_size 1 84e5c31af7Sopenharmony_ci%wg_z = OpCompositeExtract %int %wg_size 2 85e5c31af7Sopenharmony_ci%x_y = OpIMul %int %wg_x %wg_y 86e5c31af7Sopenharmony_ci%x_y_z = OpIMul %int %x_y %wg_z 87e5c31af7Sopenharmony_ci%mul = OpIMul %int %wgid_x %x_y_z 88e5c31af7Sopenharmony_ci; only support multiple wgs on x 89e5c31af7Sopenharmony_ci%linear = OpIAdd %int %mul %local_index 90e5c31af7Sopenharmony_ci%x_gep = OpAccessChain %ptr_ssbo_int %x_var %int_0 %linear 91e5c31af7Sopenharmony_ci%y_gep = OpAccessChain %ptr_ssbo_int %y_var %int_0 %linear 92e5c31af7Sopenharmony_ci%z_gep = OpAccessChain %ptr_ssbo_int %z_var %int_0 %linear 93e5c31af7Sopenharmony_ci%s_gep = OpAccessChain %ptr_ssbo_int %s_var %int_0 %linear 94e5c31af7Sopenharmony_ciOpStore %x_gep %lid_x 95e5c31af7Sopenharmony_ciOpStore %y_gep %lid_y 96e5c31af7Sopenharmony_ciOpStore %z_gep %lid_z 97e5c31af7Sopenharmony_ciOpStore %s_gep %linear 98e5c31af7Sopenharmony_ciOpReturn 99e5c31af7Sopenharmony_ciOpFunctionEnd 100e5c31af7Sopenharmony_ciEND 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_ciBUFFER x_buf DATA_TYPE uint32 SIZE 16 FILL 0 103e5c31af7Sopenharmony_ciBUFFER y_buf DATA_TYPE uint32 SIZE 16 FILL 0 104e5c31af7Sopenharmony_ciBUFFER z_buf DATA_TYPE uint32 SIZE 16 FILL 0 105e5c31af7Sopenharmony_ciBUFFER s_buf DATA_TYPE uint32 SIZE 16 FILL 0 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ciPIPELINE compute small 108e5c31af7Sopenharmony_ci ATTACH my_compute \ 109e5c31af7Sopenharmony_ci SPECIALIZE 1 AS uint32 2 \ 110e5c31af7Sopenharmony_ci SPECIALIZE 2 AS uint32 2 \ 111e5c31af7Sopenharmony_ci SPECIALIZE 3 AS uint32 2 112e5c31af7Sopenharmony_ci BIND BUFFER x_buf AS storage DESCRIPTOR_SET 0 BINDING 0 113e5c31af7Sopenharmony_ci BIND BUFFER y_buf AS storage DESCRIPTOR_SET 0 BINDING 1 114e5c31af7Sopenharmony_ci BIND BUFFER z_buf AS storage DESCRIPTOR_SET 0 BINDING 2 115e5c31af7Sopenharmony_ci BIND BUFFER s_buf AS storage DESCRIPTOR_SET 0 BINDING 3 116e5c31af7Sopenharmony_ciEND 117e5c31af7Sopenharmony_ci 118e5c31af7Sopenharmony_ciRUN small 2 1 1 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ciEXPECT s_buf IDX 0 EQ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 121e5c31af7Sopenharmony_ciEXPECT x_buf IDX 0 EQ 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 122e5c31af7Sopenharmony_ciEXPECT y_buf IDX 0 EQ 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 123e5c31af7Sopenharmony_ciEXPECT z_buf IDX 0 EQ 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 124e5c31af7Sopenharmony_ci 125