Last active
January 10, 2021 13:40
-
-
Save lxc-xx/6758945 to your computer and use it in GitHub Desktop.
cuPrintf example
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
/* File: cuprintf_test.cu | |
* Purpose: Illustrate the use of cuPrintf.cu | |
* | |
* Compile: | |
* Linux: | |
* nvcc -o cuprintf_test cuprintf_test.cu | |
* -I/usr/local/NVIDIA_GPU_Computing_SDK/shared/inc | |
* -I/usr/local/NVIDIA_GPU_Computing_SDK/C/common/inc | |
* MacOS: | |
* nvcc -o cuprintf_test cuprintf_test.cu | |
* -I/Developer/GPU\ Computing/shared/inc | |
* -I/Developer/GPU\ Computing/C/common/inc | |
* | |
* Run: ./cuprintf_test | |
* | |
* Input: None | |
* Output: 6 copies of "Value is 10", each preceded by the block and thread | |
* numbers of the the thread that printed. | |
* | |
* Notes: | |
* 1. In addition to adding the include paths listed above, this | |
* assumes you've copied cuPrint.cu and cuPrintf.cuh from the | |
* | |
* /usr/local/NVIDIA_GPU_Computing_SDK/C/src/simplePrintf | |
* | |
* on Linux or | |
* | |
* /Developer/GPU\ Computing/C/src/simplePrintf | |
* | |
* on MacOS | |
* | |
* 2. This is a much simplified version of the program simplePrintf.cu | |
* from the CUDA SDK. | |
*/ | |
#include <stdio.h> | |
#include "cuPrintf.cu" | |
#include "shrUtils.h" | |
#include "cutil_inline.h" | |
__global__ void testKernel(int val) { | |
cuPrintf("\tValue is:%d\n", val); | |
} | |
int main(int argc, char *argv[]) { | |
cudaPrintfInit(); | |
testKernel<<< 2, 3 >>>(10); | |
cudaPrintfDisplay(stdout, true); | |
cudaPrintfEnd(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment