Cuda-memcheck can't report the invalid write

I set a simple example in my code that writting in the invalid location to test cuda-memcheck. But it doesn’t seem to work. Is there any mistake in my approach?

__global__ void write_out_of_bound(int *dev_array, const int len) {
    int tid = threadIdx.x;
    if(tid < len) {
         dev_array[tid] = tid;

int main(int argc, char **argv)
    int *dev_array;
    cudaMalloc((void**)&dev_array, sizeof(int) * 64);
    write_out_of_bound<<<1, 128>>>(dev_array, 128);

The command line:
nvcc -g -G -o test
cuda-memcheck ./test

My device information is as follows:

Compute Sanitizer has replaced cuda-memcheck for memory checking. Can you try using compute sanitizer with a command like " compute-sanitizer --tool memcheck ./test"

1 Like

Thanks a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.