Ask.Cyberinfrastructure

How can I compile my cuda code so I could call it from my R script

cuda
r
gpu

#1

I have an R script, part of which can be easily converted to run on GPUs. I wrote a C-wrapper script that calls a cuda kernel, but I wonder how I should compile these files in such a way that I can load the resulting shared library into my R script and call my wrapper C function.


#2
#compile cuda code

nvcc -g -G -O2 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_35,code=sm_35 -I$R_HOME/include -Xcompiler -fpic -c tfbs_cuda.cu -o tfbs_cuda.o

 

#compile wrapper code

gcc -std=gnu99 -I$R_HOME/include -fpic -g -O2 -c tfbs_wrapper.c -o tfbs_wrapper.o

 

#create shared library

nvcc -shared -Xlinker -L$R_HOME/lib -lR -L$SCC_CUDA_LIB  -o  tfbs_wrapper.so tfbs_wrapper.o tfbs_cuda.o