Sha256: a6dad157438331f02949c1efe62b15297807d476bd58f130973135530b6550a1

Contents?: true

Size: 1007 Bytes

Versions: 19

Compression:

Stored size: 1007 Bytes

Contents

% ctype = dtype_to_c_type(data_type)

__kernel void pack(const int N, const int index, __global const <%= ctype %> *A, __global <%= ctype %> *C) {
    // Get the index of the current element to be processed
    const int globalCol = get_global_id(0); // Col ID of C (0..N)

    int start = index * <%= divisors[0] %>;
    int ptr = start + globalCol;
    int index_map[<%= divisors.size %>] = { <%= Array.new(divisors.size) { 0 }.join(', ') %> };

    // compute effective coordinates
<% divisors.each_with_index do |div, index| %>
    index_map[<%= index %>] = (int)floor(ptr / (float)<%= div %>);<% if index < divisors.size - 1%>ptr = ptr % <%= div %>;<% end %><% end %>

    // Apply axis translation if needed
<% if axis > 0 %>
    int first = index_map[0];
<% axis.times do |i| %>
    index_map[<%= i %>] = index_map[<%= (i + 1) %>];<% end %>
    index_map[<%= axis %>] = first;
<% end%>

    C[<%= multipliers.each_with_index.map { |m, idx| "#{m}*index_map[#{idx}]" }.join(' + ') %>] = A[globalCol];
}

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
tensor_stream-opencl-0.3.2 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.3.1 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.3.0 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.10 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.9 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.8 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.6 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.5 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.4 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.3 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.2 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.1 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.2.0 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.1.3 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.1.2 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.1.1 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-opencl-0.1.0 lib/tensor_stream/opencl/kernels/pack.cl
tensor_stream-0.8.1 lib/tensor_stream/evaluator/opencl/kernels/pack.cl
tensor_stream-0.8.0 lib/tensor_stream/evaluator/opencl/kernels/pack.cl