-
Notifications
You must be signed in to change notification settings - Fork 12.7k
vulkan: fuse adds #15252
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
Open
jeffbolznv
wants to merge
2
commits into
ggml-org:master
Choose a base branch
from
jeffbolznv:fuse_add
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+300
−25
Open
vulkan: fuse adds #15252
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#version 450 | ||
|
||
#extension GL_EXT_shader_16bit_storage : require | ||
#extension GL_EXT_nonuniform_qualifier : enable | ||
#extension GL_EXT_control_flow_attributes : require | ||
|
||
#include "rte.comp" | ||
#include "types.comp" | ||
#include "utils.comp" | ||
|
||
layout (push_constant) uniform parameter2 | ||
{ | ||
// shape for dst | ||
uint ne20; uint ne21; uint ne22; uint ne23; | ||
|
||
// strides for srcs+dst | ||
uint nb[8][4]; | ||
} p; | ||
|
||
layout (binding = 0) readonly buffer A {A_TYPE data_a[];} a[]; | ||
layout (binding = 0) writeonly buffer D {D_TYPE data_d[];} d[]; | ||
|
||
layout(constant_id = 0) const uint num_srcs = 2; | ||
|
||
uint src_idx(uint s, uint i00, uint i01, uint i02, uint i03) { | ||
return i03*p.nb[s][3] + i02*p.nb[s][2] + i01*p.nb[s][1] + i00*p.nb[s][0]; | ||
} | ||
|
||
uint dst_idx(uint i00, uint i01, uint i02, uint i03) { | ||
uint nb20 = p.nb[num_srcs][0]; | ||
uint nb21 = p.nb[num_srcs][1]; | ||
uint nb22 = p.nb[num_srcs][2]; | ||
uint nb23 = p.nb[num_srcs][3]; | ||
return i03*nb23 + i02*nb22 + i01*nb21 + i00*nb20; | ||
} | ||
|
||
uint get_idx() { | ||
return gl_GlobalInvocationID.z * 262144 + gl_GlobalInvocationID.y * 512 + gl_GlobalInvocationID.x; | ||
} | ||
|
||
const uint num_threads = 256; | ||
|
||
layout(local_size_x = num_threads, local_size_y = 1, local_size_z = 1) in; | ||
|
||
void main() { | ||
uint idx = get_idx(); | ||
|
||
uint ne = p.ne20 * p.ne21 * p.ne22 * p.ne23; | ||
|
||
// num_threads * num_iter must equal 512, to match the wg_denoms and get_idx calculation | ||
const uint num_iter = 2; | ||
|
||
[[unroll]] for (uint i = 0; i < num_iter; ++i) { | ||
if (idx >= ne) { | ||
continue; | ||
} | ||
uint i00, i01, i02, i03; | ||
get_indices(idx, i00, i01, i02, i03, p.ne20, p.ne21, p.ne22, p.ne23); | ||
|
||
FLOAT_TYPE sum = FLOAT_TYPE(0); | ||
[[unroll]] for (uint s = 0; s < num_srcs; ++s) { | ||
sum += FLOAT_TYPE(a[s].data_a[src_idx(s, i00, i01, i02, i03)]); | ||
} | ||
d[num_srcs].data_d[dst_idx(i00, i01, i02, i03)] = D_TYPE(sum); | ||
|
||
idx += num_threads; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not require any support checks on the API side? There seems to be an endless source of obscure GLSL extensions that solve very specific issues. Neat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires the runtimeDescriptorArray feature from the descriptor_indexing extension. This is required to be supported in Vulkan 1.2 so I don't think the check is strictly required, but I'll add it since it's simple.