1''
1''

Reputation: 27095

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?

Upvotes: 4

Views: 1910

Answers (2)

jprice
jprice

Reputation: 9925

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]

Upvotes: 6

Tomi Aarnio
Tomi Aarnio

Reputation: 2517

Have you looked at http://github.com/KhronosGroup/webcl-validator? It takes your OpenCL kernel source and instruments it with bounds checking code. OOB reads/writes are currently discarded, but you could modify the instrumented kernel (or the tool itself) to make it report the access violation.

Upvotes: 3

Related Questions