Access Violation when copying a bool array to device

Nov 4, 2012 at 9:33 PM
Edited Nov 4, 2012 at 9:35 PM

I'm getting this error intermittently when copying a 1d bool array to the GPU using CopyToDevice. My program copies arrays to the device (including this bool array) and runs on the GPU successfully 100s of times, but eventually throws this error.

Is there any reason I shouldn't copy arrays of bools?

Is it possible there's an error in this method for bools?

I am using Cudafy v1.11

thanks

Full error message:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.   
at GASS.CUDA.CUDADriver.cuMemcpyHtoD(CUdeviceptr dstDevice, IntPtr srcHost, SizeT ByteCount)   
at GASS.CUDA.CUDA.CopyHostToDevice(CUdeviceptr devPtr, IntPtr buffer, UInt32 size)   
at Cudafy.Host.CudaGPU.DoCopyToDevice[T](Array hostArray, Int32 hostOffset, Array devArray, Int32 devOffset, Int32 count)   
at Cudafy.Host.CudaGPU.CopyToDevice[T](T[] hostArray)

Nov 4, 2012 at 11:16 PM

My first thought would be a memory over-run, or memory leak. Are you dynamically allocating memory on successive kernel launches? Be sure to deallocate memory as soon as you can, as memory, particularly Shared memory, runs out quickly whe being allcated by thousands of threads.

Also, have you checked out NVidia's Occupancy Calculator spreadsheet?

Pieter

Nov 4, 2012 at 11:33 PM

I'm not dynamically allocating any memory within the kernel (as a side point, I didn't realize that was allowed).

It does sound like a memory over-run of some sort, but I'm only using managed arrays never anything more low-level, and always happens when I copy the bool array using CopyToDevice, hence my thought that there may be a problem here specifically for bools. I copy lots of other arrays (of arrays of ints and floats) and the error never occurs at that point.

Nov 5, 2012 at 1:28 AM

I'm out of ideas at this point. Perhaps Nick can think of something.

Kernels can (I'm tol, I haven't tried it yet) even launch new child kernels.

Coordinator
Nov 5, 2012 at 10:52 AM

Boolean is not a blittable type therefore not suitable for copying between CPU and GPU.  

Nov 5, 2012 at 6:20 PM

great, thanks I will not use bool.

Other types throw a runtime error if they are not blittable, should this too?