Here's a minimal makefile to compile and execute the NVidia sample code jpegNPP.cpp
CC=g++
NVCC=nvcc
CXXFLAGS= -m64 -gencode arch=compute_30,code=compute_30
CUDAFLAGS= -ccbin
LIBS= -lnppisu -lnppicom -lnppig -lnppc -lfreeimage
LIBDIRS=-L/usr/local/cuda-10.2/lib64 \
-L/usr/local/cuda-10.2/samples/7_CUDALibraries/common/FreeImage/lib/x64 \
-L/usr/local/cuda-10.2/samples/7_CUDALibraries/common/FreeImage/lib/linux \
-L/usr/local/cuda-10.2/samples/7_CUDALibraries/common/FreeImage/lib/linux/aarch64
INCDIRS=-I/usr/local/cuda-10.2/include \
-I/usr/local/cuda-10.2/samples/7_CUDALibraries/common/UtilNPP/ \
-I/usr/local/cuda-10.2/samples/common/inc/
all: jpegNPP
./jpegNPP -input=../Data/1.jpg -output=tmp.jpg -scale=.5
xdg-open tmp.jpg
xdg-open ../Data/1.jpg
jpegNPP.o: jpegNPP.cpp
$(NVCC) $(CUDAFLAGS) $(CC) $(INCDIRS) $(CXXFLAGS) -o jpegNPP.o -c jpegNPP.cpp
jpegNPP: jpegNPP.o
$(NVCC) $(CUDAFLAGS) $(CC) $(CXXFLAGS) -o jpegNPP jpegNPP.o $(LIBDIRS) $(LIBS)
clean:
rm -rf jpegNPP *.o *.jpg
I would like to use ms vs code, in Ubuntu. The make file build can have multiple steps, which are compile, link, and execute. How do I make the c_cpp_properties.json and tasks.json to automate the nvcc / gcc (for cpp files) compiling and nvcc linking. The current properties json file is
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/cuda-10.2/samples/7_CUDALibraries/common/UtilNPP/",
"/usr/local/cuda-10.2/samples/common/inc/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm64"
}
],
"version": 4
}
and tasks json file
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++-7 build active file",
"command": "nvcc -ccbin g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.o"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger and modified for nvcc"
}
],
"version": "2.0.0"
}