feat(week1): add docs and task for week 1.

This commit is contained in:
Yi Pan
2024-07-09 11:45:35 +08:00
parent f0a44579c4
commit 66430108a4
5 changed files with 256 additions and 87 deletions

21
csrc/hello_world.cu Normal file
View File

@ -0,0 +1,21 @@
#include <cstdio>
#include <cuda_runtime.h>
__global__ void hello() {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
for (int i = 0; i < 8; i++) {
if (tid == i) {
printf("Hello from thread %d\n", tid);
}
__syncthreads();
}
}
int main() {
int nthreads = 8;
int nblocks = 1;
hello<<<nblocks, nthreads>>>();
cudaDeviceSynchronize();
return 0;
}