-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca57ea3
commit 6c5923c
Showing
100 changed files
with
214,900 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.