Page MenuHomec4science

cuda_memory.cu
No OneTemporary

File Metadata

Created
Wed, Nov 13, 04:57

cuda_memory.cu

#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
extern "C" void *allocate_cuda_memory(int *n){
double *a;
int N=*n;
//a = (float *)malloc(*n*sizeof(float));
cudaMallocManaged( (void **)&a, sizeof(double) * N );
cudaDeviceSynchronize();
return (void *) a;
}
extern "C" void deallocate_cuda(double *a){
cudaFree(a);
}

Event Timeline