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_shader_float16_int8 17e5c31af7Sopenharmony_ciDEVICE_EXTENSION VK_KHR_16bit_storage 18e5c31af7Sopenharmony_ciDEVICE_EXTENSION VK_KHR_storage_buffer_storage_class 19e5c31af7Sopenharmony_ciDEVICE_FEATURE Float16Int8Features.shaderFloat16 20e5c31af7Sopenharmony_ciDEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess 21e5c31af7Sopenharmony_ci 22e5c31af7Sopenharmony_ciSHADER compute f16 GLSL 23e5c31af7Sopenharmony_ci#version 450 24e5c31af7Sopenharmony_ci#extension GL_AMD_gpu_shader_half_float : enable 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_cilayout(set=0, binding=0) buffer Buf { 27e5c31af7Sopenharmony_ci float16_t h[3]; 28e5c31af7Sopenharmony_ci} data; 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_civoid main() { 31e5c31af7Sopenharmony_ci int idx = int(gl_GlobalInvocationID.x); 32e5c31af7Sopenharmony_ci data.h[idx] = data.h[idx] * 2.0hf; 33e5c31af7Sopenharmony_ci} 34e5c31af7Sopenharmony_ciEND 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ciBUFFER buf DATA_TYPE float16 DATA 37e5c31af7Sopenharmony_ci-0.0 38e5c31af7Sopenharmony_ci2.4 39e5c31af7Sopenharmony_ci-2.4 40e5c31af7Sopenharmony_ciEND 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_ciPIPELINE compute pipeline 43e5c31af7Sopenharmony_ci ATTACH f16 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ci BIND BUFFER buf AS storage DESCRIPTOR_SET 0 BINDING 0 46e5c31af7Sopenharmony_ciEND 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ciRUN pipeline 3 1 1 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ciEXPECT buf IDX 0 TOLERANCE 0.1 EQ 0.0 51e5c31af7Sopenharmony_ciEXPECT buf IDX 2 TOLERANCE 0.1 EQ 4.8 52e5c31af7Sopenharmony_ciEXPECT buf IDX 4 TOLERANCE 0.1 EQ -4.8 53