hello gpu world

This commit is contained in:
Anton Ljungdahl 2024-09-26 22:32:58 +02:00
parent 17078b51fb
commit ebeb0fbb17
5 changed files with 60 additions and 0 deletions

19
build.bat Normal file
View 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
View 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
View File

@ -0,0 +1,5 @@
// Forward declarations
void cuda_entry_point();

17
src/main.c Normal file
View 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

Binary file not shown.