Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/transpose/kernel.cu # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `openaccel-lab / workloads / transpose / kernel.cu` 27 lines ยท 922 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 #include 3 4 #define TS 16 5 6 // 16x16 tile through static shared memory (one padding column against bank conflicts). 7 __global__ void transpose(const float *a, float *b, int R, int C) 8 { 9 __shared__ float tile[TS][TS + 1]; 10 int tx = threadIdx.x, ty = threadIdx.y; 11 int c0 = blockIdx.x * TS, r0 = blockIdx.y * TS; 12 int r = r0 + ty, c = c0 + tx; 13 if (r < R && c < C) 14 tile[ty][tx] = a[(long long)r * C + c]; 15 __syncthreads(); 16 int orow = c0 + ty, ocol = r0 + tx; // output b is C x R 17 if (orow < C && ocol < R) 18 b[(long long)orow * R + ocol] = tile[tx][ty]; 19 } 20 21 void oal_launch(const long long *p, void *const *buf) 22 { 23 int R = (int)p[0], C = (int)p[1]; 24 dim3 grid((unsigned)((C + TS - 1) / TS), (unsigned)((R + TS - 1) / TS)); 25 dim3 block(TS, TS); 26 transpose<<>>((const float *)buf[0], (float *)buf[1], R, C); 27 }