Sha256: 83ff8ad40d839291ce525f14715bd012853139fcb3ed0a74c00ce0848cee2fed

Contents?: true

Size: 883 Bytes

Versions: 8

Compression:

Stored size: 883 Bytes

Contents

// First naive implementation
% c_dtype = dtype_to_c_type(dtype)
__kernel void gemm_<%= dtype %>(const int M, const int N, const int K,
                      const __global <%= c_dtype %>* A,
                      const __global <%= c_dtype %>* B,
                      __global <%= c_dtype %>* C) {

    // Get the index of the current element to be processed
    const int globalRow = get_global_id(0); // Row ID of C (0..M)
    const int globalCol = get_global_id(1); // Col ID of C (0..N)

    // Compute a single element (loop over K)
    <%= c_dtype %> acc = 0.0f;
    for (int k=0; k<K; k++) {
        int a_index = globalRow*K + k;
        int b_index = k*N + globalCol;
<% if ta %>a_index = M*k + globalRow;<% end %>
<% if tb %>b_index = globalCol*K + k;<% end %>
        acc += A[a_index] * B[b_index];
    }

    // Store the result
    C[globalRow*N + globalCol] = acc;
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tensor_stream-opencl-0.3.0 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.10 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.9 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.8 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.6 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.5 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.4 lib/tensor_stream/opencl/kernels/gemm.cl
tensor_stream-opencl-0.2.3 lib/tensor_stream/opencl/kernels/gemm.cl