Displaying 1 result from an estimated 1 matches for "cudacall".
2016 May 14
2
R external pointer and GPU memory leak problem
...,?
output is a R external pointer
pointing to GPU vector(device)
*/
SEXP createGPU(SEXP input, SEXP n)
{ ?
int *lenth = INTEGER(n);
? ? ? ?PROTECT (input = AS_NUMERIC (input));
? ? ? ?double * temp;?
? ? ? ?temp = REAL(input);
double *x; ? ? ? ? ? ? ? ##here is the step which causes the memory leak
cudacall(cudaMalloc((void**)&x, *lenth * sizeof(double)));
//protect the R external pointer from finalizer
SEXP ext = PROTECT(R_MakeExternalPtr(x, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ext, _finalizer, TRUE);
?
//copying CPU to GPU
cublascall(cublasSetVector(*lenth, sizeof(double), temp, 1,?...