-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cuda: add minimal CUDA program + cleanup
- Loading branch information
Showing
5 changed files
with
78 additions
and
6 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ hello-world.ptx | |
threads | ||
inc | ||
array-add | ||
minimal |
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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
VERSION=12.2 | ||
VERSION=12.4 | ||
export PATH=/usr/local/cuda-${VERSION}/bin:$PATH | ||
export LD_LIBRARY_PATH=/usr/local/cuda-${VERSION}/lib64:$LD_LIBRARY_PATH | ||
|
||
# Source Spack so that we can switch to use [email protected] | ||
. ~/work/linux/spack/share/spack/setup-env.sh | ||
spack load [email protected] | ||
gcc --version | ||
#. ~/work/linux/spack/share/spack/setup-env.sh | ||
#spack load [email protected] | ||
#gcc --version |
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
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,32 @@ | ||
#include <stdio.h> | ||
|
||
__global__ void myKernel() {} | ||
|
||
int main() { | ||
cudaError_t err = cudaSuccess; | ||
int count = 0; | ||
|
||
err = cudaGetDeviceCount(&count); | ||
if (err != cudaSuccess) { | ||
printf("cudaGetDeviceCount failed: %s\n", cudaGetErrorString(err)); | ||
return 1; | ||
} | ||
|
||
printf("CUDA device count: %d\n", count); | ||
|
||
myKernel<<<1,1>>>(); | ||
err = cudaGetLastError(); | ||
if (err != cudaSuccess) { | ||
printf("Kernel launch failed: %s\n", cudaGetErrorString(err)); | ||
return 1; | ||
} | ||
|
||
err = cudaDeviceSynchronize(); | ||
if (err != cudaSuccess) { | ||
printf("cudaDeviceSynchronize failed: %s\n", cudaGetErrorString(err)); | ||
return 1; | ||
} | ||
|
||
printf("CUDA program ran successfully\n"); | ||
return 0; | ||
} |