Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ vulkan_test(memory_tracking_1)

if (NOT MOCK_DRIVER MATCHES "1")
vulkan_test(cooperative_matrix)
vulkan_test(cooperative_matrix_math)
vulkan_test(address_remap_test_1)
endif()

Expand Down
23 changes: 23 additions & 0 deletions benchmarking/vulkan_cooperative_matrix_math.bench

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a minimal bench JSON here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added mandatory fields and applicable capabilities

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "vulkan_cooperative_matrix_math",
"description": "Run a compute shader that exercises instructions related to VK_KHR_cooperative_matrix",
"path": "build/vulkan_cooperative_matrix_math",
"capabilities": {
"non_interactive": {
"default": true,
"modifiable": false
},
"frameless": {
"default": true,
"modifiable": false
},
"gpu_fully_deterministic": {
"default": true,
"modifiable": false
},
"file_output": {
"default": false,
"modifiable": false,
},
}
}
63 changes: 63 additions & 0 deletions src/vulkan_cooperative_matrix_math.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#version 460
#extension GL_KHR_memory_scope_semantics : require
#extension GL_KHR_cooperative_matrix : require

struct MatrixData {
int[256] signed_values;
uint[256] unsigned_values;
};

layout(local_size_x=32, local_size_y=32, local_size_z=1) in;

layout(set = 0, binding = 0) readonly buffer InputBuffer
{
MatrixData in_data;
};

layout(set = 0, binding = 1) buffer OutputBuffer
{
MatrixData out_data;
};

void main()
{
coopmat<int, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator> signed_matrix;
coopmat<uint, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator> unsigned_matrix;
coopmat<float,gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator> float_matrix;

coopMatLoad(signed_matrix,
in_data.signed_values,
0,
16,
gl_CooperativeMatrixLayoutRowMajor);
coopMatLoad(unsigned_matrix,
in_data.unsigned_values,
0,
16,
gl_CooperativeMatrixLayoutRowMajor);

float_matrix = coopmat<float,gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator>(signed_matrix);
float_matrix = -float_matrix;

signed_matrix = signed_matrix - coopmat<int, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator>(float_matrix);
signed_matrix = signed_matrix + signed_matrix;
signed_matrix = signed_matrix * signed_matrix;
signed_matrix = signed_matrix / signed_matrix;

unsigned_matrix = unsigned_matrix - coopmat<uint, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator>(float_matrix);
unsigned_matrix = unsigned_matrix + unsigned_matrix;
unsigned_matrix = unsigned_matrix * unsigned_matrix;
unsigned_matrix = unsigned_matrix / unsigned_matrix;

coopMatStore(signed_matrix,
out_data.signed_values,
0,
16,
gl_CooperativeMatrixLayoutRowMajor);

coopMatStore(unsigned_matrix,
out_data.unsigned_values,
0,
16,
gl_CooperativeMatrixLayoutRowMajor);
}
Loading