I tried to create empty surface and write some data to it, but failed with CUDA_ERROR_ILLEGAL_ADDRESS on cuCtxSynchronize() call
Here is the code (it works perfectly on C++)
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(8*Sizeof.BYTE, 0, 0, 0, cudaChannelFormatKind.cudaChannelFormatKindUnsigned);
_cuArray = new cudaArray();
checkResult(cudaMallocArray(_cuArray, channelDesc, width, height));
checkResult(cudaMemcpyToArray(_cuArray, 0, 0, Pointer.to(pixels), Sizeof.BYTE*_width*_height, cudaMemcpyKind.cudaMemcpyHostToDevice));
cudaResourceDesc resDesc = new cudaResourceDesc();
resDesc.resType = cudaResourceType.cudaResourceTypeArray;
resDesc.array_array = _cuArray;
_surfOutput = new cudaSurfaceObject();
checkResult(cudaCreateSurfaceObject(_surfOutput, resDesc));```
All calls above return SUCCESS
kernel
```extern "C"
__global__ void kernel(cudaSurfaceObject_t surface)
{
const int2 pos = make_int2(blockIdx.x * blockDim.x + threadIdx.x, blockIdx.y * blockDim.y + threadIdx.y);
unsigned char data= 7;
surf2Dwrite(data, surface, pos.x*sizeof(data), pos.y);
}```
Simple as that,
But after calling
```cuLaunchKernel
cuCtxSynchronize```
it returns CUDA_ERROR_ILLEGAL_ADDRESS, and I can't figure out why :(
If surf2Dwrite is commented then it works.