FAQ
I'm developing packages with CUDA, and I'm running into a problem with
memory allocation. Since CUDA involves memory on the GPU device it
requires that the program handle memory allocation and deallocation
separately from R.

The simplest case of allocating a char and then deallocating causes a
segmentation fault when R closes. Not on garbage collection but only
on exit. Is there anything in the R internals that explain why this
is happening?

The relevant C++ code is
---
void gpualloctest(){
char * _a;
cudaMalloc(&_a,sizeof(char));
cudaFree(_a);
_a=NULL;
}
--- from gpu.cu
gputest<-function(){
cat("testing allocation on gpu\n")
Module('test','gputest')$gpualloctest()
cat("Test successful\n")
cat("Collecting Garbage\n")
gc()
cat("done.\n")
}
--- from gputest.R

As you can see Rcpp is used to interface with the C++ code, but the
Rcpp is not the problem, but happened to be convenient to use to get
the configure scripts right for the CUDA cu files.

The results from running "valgrind Rscript testgpu.R" are linked to in
testgpu.log but do not show anything interesting.

Can anyone give any insight?

Thanks,
Andrew Redd

Links to files:
http://andrewredd.us/gputest/testgpu.R
http://andrewredd.us/gputest/testgpu.Rout
http://andrewredd.us/gputest/gputest_1.0.tar.gz
http://andrewredd.us/gputest/testgpu.log

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupr-devel @
categoriesr
postedNov 8, '10 at 9:02p
activeNov 8, '10 at 9:02p
posts1
users1
websiter-project.org
irc#r

1 user in discussion

Andrew Redd: 1 post

People

Translate

site design / logo © 2022 Grokbase