// Select a kernel #define TSM 32 #define TSN 32 #define TSK TSN #define WPT 32 #define RTSM (TSM/WPT) #define RTSN (TSN/WPT) #define RTSK (TSK/WPT) __kernel void sgemm(__global float *A, __global float *B, __global float *C, int M, int N, int K) { // Thread identifiers const int row = get_local_id(0); const int col = get_local_id(1); const int global_row = TSM * get_group_id(0) + row; const int global_col = TSN * get_group_id(1) + col; __local float Asub[TSM][TSK]; __local float Bsub[TSK][TSN]; float intermediate_val[WPT]; for (int w=0; w=K) || ((global_row+w*RTSM)>=M)) Asub[row + w*RTSM][col] = 0; else Asub[row + w*RTSM][col] = A[(global_row + w*RTSM) * K + t_col]; if(((t_row+w*RTSK)>=K) || (global_col>=N)) Bsub[row + w*RTSK][col] = 0; else Bsub[row + w*RTSK][col] = B[(t_row + w*RTSK) * N + global_col]; } barrier(CLK_LOCAL_MEM_FENCE); for(int k = 0; k < TSK; k++) { for (int w=0; w