1/* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9#version 450 core 10 11#define PRECISION ${PRECISION} 12 13${define_required_extensions(DTYPE)} 14 15#define T ${buffer_scalar_type(DTYPE)} 16 17layout(std430) buffer; 18 19${layout_declare_tensor(0, "rw", "buffer_in", DTYPE, "buffer")} 20${layout_declare_ubo(1, "int", "numel")} 21 22layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; 23 24layout(constant_id = 3) const float scalar = 2.0; 25 26void main() { 27 const int t_id = ivec3(gl_GlobalInvocationID).x; 28 if (t_id >= numel) { 29 return; 30 } 31 32 buffer_in[t_id] = buffer_in[t_id] + T(scalar); 33} 34