// ================================================================================================= // This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This // project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- // width of 100 characters per line. // // Author(s): // Cedric Nugteren // // This file contains the common kernels shared among different BLAS functions. This file contains // a kernel to transpose matrices. This is a 'fast' version with restrictions, see the // 'padtranspose.opencl' file for a general transpose kernel. // // ================================================================================================= // Enables loading of this file using the C++ pre-processor's #include (C++11 standard raw string // literal). Comment-out this line for syntax-highlighting when developing. R"( // ================================================================================================= // Data-widths #if TRA_WPT == 1 typedef real realT; #elif TRA_WPT == 2 typedef real2 realT; #elif TRA_WPT == 4 typedef real4 realT; #elif TRA_WPT == 8 typedef real8 realT; #elif TRA_WPT == 16 typedef real16 realT; #endif // ================================================================================================= // Transposes and copies a matrix. Requires both matrices to be of the same dimensions and without // offset. A more general version is available in 'padtranspose.opencl'. __kernel __attribute__((reqd_work_group_size(TRA_DIM, TRA_DIM, 1))) void TransposeMatrixFast(const int ld, __global const realT* restrict src, __global realT* dest, const real_arg arg_alpha) { const real alpha = GetRealArg(arg_alpha); // Sets the group identifiers. They might be 'shuffled' around to distribute work in a different // way over workgroups, breaking memory-bank dependencies. const int gid0 = get_group_id(0); #if TRA_SHUFFLE == 1 const int gid1 = (get_group_id(0) + get_group_id(1)) % get_num_groups(0); #else const int gid1 = get_group_id(1); #endif // Local memory to store a tile of the matrix (for coalescing) __local realT tile[TRA_WPT*TRA_DIM][TRA_DIM + TRA_PAD]; // Loops over the work per thread #pragma unroll for (int w_one=0; w_one