Dear R SIG HPC:

I have a CUDA question, please:  I have a small subroutine (stolen from the Extensions manual) and fixed for CUDA

#include <R.h>
#include <Rinternals.h>

__global__ void conv1(double *a, int *na, double *b, int *nb, double *ab)
{
R_len_t i, j, nab = *na + *nb - 1;
for(i = 0; i < nab; i++)
ab[i] = 0.0;
for(i = 0; i < *na; i++)
for(j = 0; j < *nb; j++)
ab[i + j] += a[i] * b[j];
}

and its name is conv1.cu

I then have a Makefile:
EXT := cu 

OBJS := conv1.o

#compiler/preprocessor options
INCS := -I/usr/local/cuda/include
PARAMS := -Xcompiler "-I/usr/share/R/include -fpic"

#linker options
LD_PARAMS := -Xlinker "-L/usr/lib/R/lib -lR -Wl,-rpath,/usr/local/cuda/lib64"
LIBS :=  -L/usr/local/cuda/lib64 -lcublas -L/usr/lib/nvidia-current/-lcuda

TARGETS := conv1.so

CC := /usr/local/cuda/bin/nvcc

all: $(TARGETS) 

$(TARGETS): $(OBJS)
	$(CC) -shared $(LD_PARAMS) $(LIBS) $(OBJS) -o $@

$(OBJS): %.o: %.$(EXT)
	$(CC) -c $(INCS) $(PARAMS) $^ -o $@

clean:
	rm -rf *o

.PHONY: all clean

And when I run make, all is well:
erin@ubuntu:~$ make
/usr/local/cuda/bin/nvcc -shared -Xlinker "-L/usr/lib/R/lib -lR -Wl,-rpath,/usr/local/cuda/lib64" -L/usr/local/cuda/lib64 -lcublas -L/usr/lib/nvidia-current/-lcuda conv1.o -o conv1.so
erin@ubuntu:~$ 


then I go to R
> dyn.load("conv1.so")
> is.loaded("conv1")
[1] FALSE
>

Do you have any idea what I'm doing wrong, please?

Thanks for any help!
Sincerely,
Erin


Erin M. Hodgess, PhD
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgesse@uhd.edu


	[[alternative HTML version deleted]]

