siboehm/SGEMM_CUDA (19 files):
siboehm_sgemm.cu, siboehm_runner.cu, siboehm_runner.cuh, siboehm_kernels.cuh
siboehm_cuBLAS_sgemm.cu, siboehm_simplest_kernel.cu, siboehm_CMakeLists.txt
siboehm_{1_naive..12_kernel_double_buffering}.cuh
wangzyon/NVIDIA_SGEMM_PRACTICE (12 files):
wangzyon_sgemm.cu, wangzyon_utils.cu, wangzyon_utils.cuh, wangzyon_kernel.cuh
wangzyon_CMakeLists.txt, wangzyon_kernel_{1..7}.cuh
edtallison/sgemm-cuda (19 files):
edtallison_sgemm.cu, edtallison_runner.cu, edtallison_runner.cuh
edtallison_kernels.cuh, edtallison_cuBLAS_sgemm.cu, edtallison_simplest_kernel.cu
edtallison_CMakeLists.txt, edtallison_{01_naive..12_kernel_double_buffering}.cuh
cat_files/ total: 25 → 75 files
29 lines
685 B
Plaintext
29 lines
685 B
Plaintext
#pragma once
|
||
|
||
#include <cstdio>
|
||
#include <cstdlib>
|
||
#include <cublas_v2.h>
|
||
#include <cuda_runtime.h>
|
||
|
||
/*
|
||
|
||
Matrix sizes:
|
||
MxK * KxN = MxN
|
||
|
||
*/
|
||
|
||
__global__ void sgemm_naive(int M, int N, int K, float alpha, const float *A,
|
||
const float *B, float beta, float *C) {
|
||
const uint x = blockIdx.x * blockDim.x + threadIdx.x;
|
||
const uint y = blockIdx.y * blockDim.y + threadIdx.y;
|
||
|
||
// if statement is necessary to make things work under tile quantization
|
||
if (x < M && y < N) {
|
||
float tmp = 0.0;
|
||
for (int i = 0; i < K; ++i) {
|
||
tmp += A[x * K + i] * B[i * N + y];
|
||
}
|
||
// C = α*(A@B)+β*C
|
||
C[x * N + y] = alpha * tmp + beta * C[x * N + y];
|
||
}
|
||
} |