MCPcopy Create free account
hub / github.com/boostorg/compute / make_naive_transpose_kernel

Function make_naive_transpose_kernel

example/matrix_transpose.cpp:61–88  ·  view source on GitHub ↗

generate a naive transpose kernel

Source from the content-addressed store, hash-verified

59
60// generate a naive transpose kernel
61compute::kernel make_naive_transpose_kernel(const compute::context& context)
62{
63 // source for the naive_transpose kernel
64 const char source[] = BOOST_COMPUTE_STRINGIZE_SOURCE(
65 __kernel void naive_transpose(__global const float *src, __global float *dst)
66 {
67 uint x = get_group_id(0) * TILE_DIM + get_local_id(0);
68 uint y = get_group_id(1) * TILE_DIM + get_local_id(1);
69
70 uint width = get_num_groups(0) * TILE_DIM;
71
72 for(uint i = 0 ; i < TILE_DIM; i+= BLOCK_ROWS){
73 dst[x*width + y+i] = src[(y+i)*width + x];
74 }
75 }
76 );
77
78 // setup compilation flags for the naive_transpose program
79 std::stringstream options;
80 options << "-DTILE_DIM=" << TILE_DIM << " -DBLOCK_ROWS=" << BLOCK_ROWS;
81
82 // create and build the naive_transpose program
83 compute::program program =
84 compute::program::build_with_source(source, context, options.str());
85
86 // create and return the naive_transpose kernel
87 return program.create_kernel("naive_transpose");
88}
89
90// generates a coalesced transpose kernel
91compute::kernel make_coalesced_transpose_kernel(const compute::context& context)

Callers 1

mainFunction · 0.85

Calls 1

create_kernelMethod · 0.80

Tested by

no test coverage detected