hello gpu world
This commit is contained in:
parent
17078b51fb
commit
ebeb0fbb17
19
build.bat
Normal file
19
build.bat
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
ctime -begin timeBuild.ctm
|
||||||
|
|
||||||
|
@rem /WX /W4 /wd4201 /wd4100 /wd4189 /wd4244 /wd4127 /wd4456
|
||||||
|
set CommonCompilerFlags="/nologo /Zi /FC"
|
||||||
|
set CudaSources=../src/cuda_entry_point.cu
|
||||||
|
set Sources=../src/main.c
|
||||||
|
|
||||||
|
IF NOT EXIST .\build mkdir .\build
|
||||||
|
pushd .\build
|
||||||
|
nvcc -Xcompiler %CommonCompilerFlags% -o program.exe %Sources% %CudaSources%
|
||||||
|
set LastError=%ERRORLEVEL%
|
||||||
|
popd
|
||||||
|
|
||||||
|
ctime -end timeBuild.ctm %LastError%
|
||||||
|
IF NOT %LastError%==0 GOTO :end
|
||||||
|
|
||||||
|
:end
|
||||||
19
src/cuda_entry_point.cu
Normal file
19
src/cuda_entry_point.cu
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define no_name_mangle extern "C"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
__global__ void hello_from_GPU() {
|
||||||
|
printf("HELLO FROM GPUUUU");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
no_name_mangle void cuda_entry_point() {
|
||||||
|
|
||||||
|
hello_from_GPU<<<1, 1>>>();
|
||||||
|
|
||||||
|
|
||||||
|
cudaDeviceSynchronize();
|
||||||
|
}
|
||||||
5
src/kernels.h
Normal file
5
src/kernels.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
void cuda_entry_point();
|
||||||
17
src/main.c
Normal file
17
src/main.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "kernels.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
cuda_entry_point();
|
||||||
|
|
||||||
|
|
||||||
|
printf("hello");
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BIN
timeBuild.ctm
Normal file
BIN
timeBuild.ctm
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user