Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CranberryYan authored Sep 11, 2024
1 parent ca57ea3 commit 6c5923c
Show file tree
Hide file tree
Showing 100 changed files with 214,900 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 1.hellocuda/1.hellocuda.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>

// 一维
__global__ void hello_cuda() {
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;

printf("%d hello cuda\n", idx);
}

int main() {

// 核函数
hello_cuda<<<10, 5>>>(); // 10 个 block, 每个 block 中有 5 个 thread -> 50 个 thread

// 同步等待所有 thread 结束
cudaDeviceSynchronize();

return 0;
}
Loading

0 comments on commit 6c5923c

Please sign in to comment.