benchmark-toolbox: CUDA95 integration
This commit is contained in:
1 parent
5dacd30dd3
commit
4fb9615653
7 files changed
+1464
-3
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#version 430 core
|
||||
layout(local_size_x = 16, local_size_y = 16) in;
|
||||
|
||||
layout(std430, binding = 0) readonly buffer DataBuffer {
|
||||
float data[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) buffer ResultBuffer {
|
||||
uint result;
|
||||
};
|
||||
|
||||
layout(std140, binding = 0) uniform Params {
|
||||
uint n_rows;
|
||||
uint n_repeats;
|
||||
};
|
||||
|
||||
const float THRESHOLD = 0.001f;
|
||||
|
||||
// One partial sum to force one atomic per WGP instead of 256.
|
||||
shared uint s_partial[256];
|
||||
|
||||
void main() {
|
||||
uint total_cols = gl_NumWorkGroups.x * gl_WorkGroupSize.x
|
||||
* gl_NumWorkGroups.y * gl_WorkGroupSize.y;
|
||||
|
||||
uint col = (gl_GlobalInvocationID.y * (gl_NumWorkGroups.x * gl_WorkGroupSize.x))
|
||||
+ gl_GlobalInvocationID.x;
|
||||
|
||||
uint count = 0u;
|
||||
|
||||
if (n_rows >= 2u) {
|
||||
for (uint k = 0u; k < n_repeats; ++k) {
|
||||
// Fuck compiler optimizations, imma start throwing bullshit
|
||||
float bias = float(k) * 1e-9;
|
||||
float ref = data[col] + bias;
|
||||
|
||||
for (uint row = 1u; row < n_rows; ++row) {
|
||||
float val = data[row * total_cols + col];
|
||||
if (abs(ref - val) > THRESHOLD)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint lid = gl_LocalInvocationIndex;
|
||||
s_partial[lid] = count;
|
||||
memoryBarrierShared();
|
||||
barrier();
|
||||
|
||||
for (uint s = 128u; s > 0u; s >>= 1) {
|
||||
if (lid < s)
|
||||
s_partial[lid] += s_partial[lid + s];
|
||||
memoryBarrierShared();
|
||||
barrier();
|
||||
}
|
||||
|
||||
if (lid == 0u)
|
||||
atomicAdd(result, s_partial[0]);
|
||||
}
|
||||
Reference in new issue
Block a user