mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-11-03 09:22:01 +00:00
* vulkan (DRAFT): split shader generation by GLSL source file, to improve incremental build times * support dep-files so shaders are recompiled if their included files change * rename shader files which are used as "headers" to use .glsl extension * move glslc extension detection shaders to separate folders * the above is to prevent them from getting glob'd with the actual compute shaders that need to be compiled * vulkan : only write embedded shader .hpp/.cpp when they change * avoid recompiling ggml-vulkan.cpp when editing shaders * pass single --source argument instead of --input-dir & --filter to shader gen * check for source file match earlier * fix hang in vulkan-shaders-gen when there are compilation errors * early out did not decrement compile_count * clean up * fix glslc integer dot product test * unconditionally write the embedded shader cpp output * replace output filepath in generated dep-files to match output in CMakeLists --------- Co-authored-by: Jeff Bolz <jbolz@nvidia.com>
43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
#version 450
|
|
|
|
#include "types.glsl"
|
|
#include "generic_binary_head.glsl"
|
|
|
|
layout(local_size_x = 512, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
void main() {
|
|
const uint i00 = gl_GlobalInvocationID.x;
|
|
|
|
if (i00 >= p.ne00) {
|
|
return;
|
|
}
|
|
|
|
uint gid_z = gl_GlobalInvocationID.z;
|
|
while (gid_z < p.ne11 * p.ne12) {
|
|
uint gid_y = gl_GlobalInvocationID.y;
|
|
while (gid_y < p.ne10) {
|
|
const uint i10 = gid_y;
|
|
const uint i11 = gid_z / p.ne12;
|
|
const uint i12 = gid_z % p.ne12;
|
|
|
|
const uint i01 = data_b[get_boffset() + i10*p.nb10 + i11*p.nb11 + i12*p.nb12];
|
|
|
|
const uint a_offset = get_aoffset() + i01*p.nb01 + i11*p.nb02 + i12*p.nb03;
|
|
const uint d_offset = get_doffset() + i10*p.nb21 + i11*p.nb22 + i12*p.nb23;
|
|
|
|
#if defined(DATA_A_BF16)
|
|
FLOAT_TYPE v = FLOAT_TYPE(bf16_to_fp32(data_a[a_offset + i00]));
|
|
#else
|
|
FLOAT_TYPE v = FLOAT_TYPE(data_a[a_offset + i00]);
|
|
#endif
|
|
#ifndef OPTIMIZATION_ERROR_WORKAROUND
|
|
data_d[d_offset + i00] = D_TYPE(v);
|
|
#else
|
|
data_d[d_offset + i00] = D_TYPE(v);
|
|
#endif
|
|
gid_y += gl_WorkGroupSize.y * gl_NumWorkGroups.y;
|
|
}
|
|
gid_z += gl_WorkGroupSize.z * gl_NumWorkGroups.z;
|
|
}
|
|
}
|