Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valgrind equivalent for OpenCL

To check memory access violations on the CPU, there's Valgrind/memcheck; for CUDA code on the GPU, there's CUDA memcheck. Is there an equivalent to these tools for OpenCL?

like image 543
1'' Avatar asked Sep 02 '25 09:09

1''


1 Answers

There is now an OpenCL device simulator called Oclgrind that works in a similar manner to Valgrind to provide a 'memcheck' feature (among other things).

It's open-source, and there are binary builds for various platform available. Like Valgrind it's not fast, but using it is very straightforward:

$ oclgrind ./myapp

Invalid write of size 4 at global memory address 0x3000000000010
    Kernel: write_out_of_bounds
    Entity: Global(4,0,0) Local(4,0,0) Group(0,0,0)
     store i32 %tmp15, i32 addrspace(1)* %tmp19, align 4, !dbg !24
    At line 4 of input.cl:
        c[i] = a[i] + b[i]
like image 157
jprice Avatar answered Sep 05 '25 00:09

jprice