Dmitry
Dmitry

Reputation: 41

How to get kernel information

I want to get following information about compiled OpenCL kernels - list of types, params order (if possible - with memory and access classifiers). Kernels are build from the sources during run time of app.

Actually, in OpenCL 1.2 already exists appropriate functions for such query - clGetKernelArgInfo, but due to project restrictions I have to find way to achieve such functionality using pure OpenCL 1.0 without any extensions.

At present, I am thinking about three approaches:

  1. write simple Ansi C parser to get info about kernel's signature directly from OpenCL kernel's source
  2. using macros in OpenCL code to mark kernel's arguments for simple in-app parsing (by extending this idea)
  3. define list of the most possible combination of kernel's arguments using macros and class-helpers (due to my project's constrains it is possible to operate under 3-5 common arg-types)

My question: is there any other ways to get info about compiled kernel?

I want to use this info to decrease amount of OpenCL routine in client code by encapsulate calls to clCreateBuffer, clEnqueueWrite/Read, clSetKernelArg in small wrapper, which should check provided params, allocate device side ptrs, copy data from/to hosts and so on.

Upvotes: 4

Views: 1413

Answers (1)

Tomi Aarnio
Tomi Aarnio

Reputation: 2527

The Khronos WebCL Validator gives you the equivalent of clGetKernelArgInfo, including all qualifiers.

The necessary downside is that it's a complete parser, based on Clang/LLVM. It takes roughly the same amount of time to run as a typical OpenCL compiler (not a coincidence), and adds around 10 megabytes to your executable size.

Upvotes: 1

Related Questions