ztellman / calx

not under active development - idiomatic opencl bindings for clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not clear how to do 2 or 3D problems.

LudoTheHUN opened this issue · comments

Hello.
Your example in the readme states:
(enqueue-kernel :square 3 a b)
where the 3 refers to the global size of the problem, as in the gid in:
int gid = get_global_id(0)

I would like to write a kernel with 2 (or 3) dimensions, say with
int col = get_global_id(0);
int row = get_global_id(1);

Problem is, I do not see how to state the sizes of each of these(col, row), as you did for gid.
I guess the function enqueue-kernel would need to extend or have a Ndimentional version of it?
Also, the function enqueue-kernel does not seem to be in the doc file you point to in the read me.

How would you approach a 2 problem with calx?
I'm thinking of a 1D data buffer, which, via it's layout, encodes a 2D data, then I'd apply mod(gid,rowWidth) for work on rows and floor(gid/colHight) for columns?

Many thanks!

Ludo

The OpenCL spec includes "images", which are 2 and 3D data formats, but Calx doesn't currently expose them. But if you want to just emulate nD with a 1D buffer, then the approach you describe is exactly right (adjusted for whatever dimensionality you want to use). The width and height can just be parameters passed into the kernel.

Hope that helps. Let me know if you have any other questions.

Many thanks, that sounds good. I will have more questions... will raise them as github issues if that's ok.