Commit 0f5fead6 authored by D'azevedo, Ed's avatar D'azevedo, Ed
Browse files

add assert for NULL and allocate at least 1 byte for GPU

parent 61a2cba9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ void *ptr = NULL;
#ifdef USE_MAGMA
   {
   const unsigned int flags = cudaMemAttachGlobal;
   cudaError_t ierr = cudaMallocManaged(  &ptr, alloc_size, flags );
   const size_t nbytes = (alloc_size > 0) ? alloc_size : 1;
   cudaError_t ierr = cudaMallocManaged(  &ptr, nbytes, flags );
   int isok = (ierr == cudaSuccess );
   if (!isok) {
      fprintf(stderr,"dmrg_malloc: CUDA ERROR %s\n", cudaGetErrorString(ierr) );
@@ -61,6 +62,7 @@ void *ptr = NULL;
#else
   ptr = (void *) malloc( alloc_size );
#endif
  assert( ptr != 0 );
  return (ptr);
}