OpenCL in Jitter, part one: jit.cl.noise

nesa's icon

Dear friends, foes and others,

Here's my first jitter external made while experimenting how to integrate OpenCL into Jitter.

I've used the noise-generating OpenCL example from apple's dev site, and tried to integrate it into an Jitter external. It seems that it works fairly well and since it is useful on its own I thought I'd share it.

It comes with three files: external, help file and .cl kernel file.
The kernel file source code is compiled on the object instantiation, so you can tweak it to generate completely different output instead of the noise. Only caveat is that you can't change function names and parameters as these are hardcoded into external.

Many thanks to all the people posting in dev forums,
Tim for posting the new max sdk/manual which is understandable even to n00bs like me and
Jean-Marc Pelletier for making his library open-source, I learned a lot from looking at his code.

The external is mac, 10.6.2, intel only.
Source available on request.

Download at:

nenad.popov.interfaculty.nl/jitter/clnoise.zip

best wishes,
nesa

efe's icon

WOW

generalh's icon

This is a great news, Nesa. Thanks for sharing...
So this will only work under 10.6.2?
And do we need recent graphics card?
cheers
hubert

nesa's icon

Hi Hubert,

It's compiled with 10.6 sdk, and I never tested it on anything else, so I can't tell.

I use 2008 macbook pro with a nvidia 8600M GT, and it works nice.

What are your specs?

@efe: did it work for you?

efe's icon

It worked like a charm. As far as i know openCL only works with snow leopard and with certain video cards
specs: 10.6.2 nvidia GeForce 9600 GT

@nesa: are u planning to make the source code available?

congrats, amazing stuff!

Emmanuel

nesa's icon

Hi Emmanuel,

Glad to hear that it works fine on your setup.

Yes, I plan to release the source code, I'd just like to figure out one more thing - how to avoid reading back to cpu and output the compute result as a jit.gl.texture.

Joshua Kit Clayton's icon

Hi Nesa,

Thanks for sharing! Here's some info on how to grab a texture id from a jit_gl_texture as used in jit.gl.imageunit for rendering to that texture as a destination and sending onwards. It may be helpful to you. Otherwise if you come across any problems or need additional information, just let us know.

-Joshua

Ad.'s icon

I cofirm, it doesn't work under 10.5;
Ad.

nesa's icon

@Ad. I'm sorry that it doesn't work for you. I still don't know if OpenCL is supported on non-snow leopard at all, but after we get this one working I'll try to do a research on compatibility.

Joshua Kit Clayton's icon

Yep. AFAIK, Apple has no plans to support OpenCL pre-snowleopard, though there might be some third party working on OpenCL compilers that wouldn't use the standard drivers to do the compilation (compiling down to assembly or translating to glsl, CUDA, or whatever). I don't know any offhand, however.

efe's icon

Hello guys:
super nice post!
I was taking a look into the openCL documentation, it seems that a 'direct' usage of openCL is not supported as Joshua says, to the pre-snowy thing. However, i ran into this 'NVIDIA OpenCL JumpStart Guide' which literally says:
Leveraging the massively parallel processing power of NVIDIA GPUs, OpenCL running on the CUDA architecture extends NVIDIA’s world-renowned graphics processor technology into the realm of parallel computing. Applications that run on the CUDA architecture can take advantage of an installed base of over one hundred million CUDA-enabled GPUs in desktop and notebook computers, professional workstations, and supercomputer clusters. NVIDIA GPUs enable this unprecedented performance via standard APIs such as OpenCL and DirectX Compute, and high level programming languages such as C/C++, Fortran, Java, Python, and .NET.
So it might be possible to use openCL within CUDA architecture. Correct me if i am wrong, but this might help to port openCL externals into old osx version or windows
Emmanuel

diatom's icon

Can I ask on this topic - From what I've read, openCL allows access to processing centres (CPU/GPU/DSP) for specifically directed processing tasks (eg. nonMedia app processing on the GPU).

OK nesa, so you created an external which generates presumably white noise (audio) but you're getting your GPU to generate it? I'm interested in openCL's potential uses for me, but currently, because my machine has dedicated processors for audio and video, whom I want to work on what they're dedicated to, I cannot see a use for openCL in this context.

My only thought was using openCL to direct processing of certain graphical tasks to one GPU and others to a second.

mattyo's icon

FWIW, I get "error -10 on recompute" while attempting to run it in Mountain Lion...

M

dtr's icon

@diatom: the white noise here refers to a texture/matrix, not audio. But the point is it's just data. It doesn't care how it's interpreted later on (so it could be turned into audio). My basic understanding is that OpenCL and CUDA are good for large numbers of parallel processes, like particle systems.

ctrlzjones's icon

making some noise ...

here is

A. at open the patch:
- Error: Failed to built program executable
- Failed to setup compute kernel! Error -11

B. running the help patch
- Error -10 from Recompute

flying on MBP & ATI RAdeon HD 6750M

diatom's icon

@dtr: I see yes, just data. i think i'll start with openGL first though, until I find a system I wanna model which would benefit from gpu-processing which would otherwise be cpu-based.
cheers