Skip to content

Commit

Permalink
20240523
Browse files Browse the repository at this point in the history
  • Loading branch information
sun1638650145 committed May 23, 2024
1 parent 6c7a813 commit d915d71
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion GPU.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int main() {
}
```
## 1.8.使用`atomicAdd`避免数据竞争.
## 1.8.使用`atomicAdd`避免数据竞争
```c++
#include <iostream>
Expand Down Expand Up @@ -524,6 +524,31 @@ int main() {
}
```

## 1.9.使用`__device__`函数

```c++
#include <cstdio>

// 声明的__device__函数只能在GPU上被调用.
__device__ const char* GetString() {
return "Hello, World\n";
}

__global__ void PrintString() {
// 核函数只能调用__device__函数.
const char *string = GetString();

printf("%s", string);
}

int main() {
PrintString<<<1, 1>>>();
cudaDeviceSynchronize();

return 0;
}
```

# 2.cuBLAS

## 2.1.cublas\<t\>gemm()
Expand Down

0 comments on commit d915d71

Please sign in to comment.