Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redundant 'float16_t' conversion triggers optimization internal error #1418

Closed
FanShupei opened this issue Jun 4, 2024 · 1 comment
Closed

Comments

@FanShupei
Copy link

When compiling the following shader with optimization, glslc throws internal error. Although the 'float16_t' conversion is redundant, it should be harmful. Compiling without optimization, or use glslang directly glslang --target-env vulkan1.3 -Os issue2.comp is OK.

The issue keeps if we replace 'float16_t' with other 16-bit types, like 'uint16_t' or 'int16_t', but the issue disappears with other types, like 'float', 'int' or 'uint'

$ glslc --target-env=vulkan1.3 -O issue2.comp
shaderc: internal error: compilation succeeded but failed to optimize: Expected input to have different bit width from Result Type: FConvert
  %33 = OpFConvert %half %31
#version 450
#extension GL_EXT_shader_16bit_storage : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

#define TYPE float16_t
layout(binding = 0) readonly buffer A { TYPE data_a[]; };
layout(binding = 1) writeonly buffer D { TYPE data_d[]; };

void main() {
    const uint i = gl_GlobalInvocationID.x;
    data_d[i] = TYPE(data_a[i]);
}

The case is minified from https://github.com/ggerganov/llama.cpp/blob/adc9ff384121f4d550d28638a646b336d051bf42/ggml_vk_generate_shaders.py#L2057C1-L2079C4, when I was curious why there exists optimization workaround.

Version

$ glslc --version
2024.0
2024.1
14.1.0
Target: SPIR-V 1.0

$ glslang --version
Glslang Version: 11:14.1.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 14.1.0
GLSL Version: 4.60 glslang Khronos. 14.1.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

OS: Archlinux

@dneto0
Copy link
Collaborator

dneto0 commented Jun 17, 2024

The fix should go into Glslang. KhronosGroup/glslang#3622
There's no further action here, so I will close this.

@dneto0 dneto0 closed this as completed Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants