MSAOpenCL, Windows, codeblocks, particle example not working (static particles)

Hi everyone.

I am new at this, but I finally managed to compile MSAOpenCL particle example without errors on Windows and codeblocks.

To configure codeblocks with opencl see this page:http://oscarbg.blogspot.com/2009/12/opencl-with-mingw.html
Do not forget to link at project->build options->linker settings->path to libopencl.a.
And also include project->build options->search directories->path to opencl header files directories, were there must exist the folders OpenCL and CL with the files that are in the #include declarations of the MSAOpenCL code.

For those who does not know what code has to be changed to compile correctly on windows go to this page:
https://github.com/memo/msalibs/pull/4/files

You have to change in MSAOpenCL.cpp and MSAOpenCL.h some lines of code, especially the cl_context_properties and in the header files also.

But there is some problem occurring, when I run the compiled program, all the particles appear static on the screen and do not move at all. Is the kernel not being updated and this code in testApp.cpp is not working?

  
opencl.loadProgramFromFile("MSAOpenCL/Particle.cl");  
kernelUpdate = opencl.loadKernel("updateParticle");  

Is this a windows related problem and I have to change some code in order to make it work?

Anybody compiled this successfully on windows?

Help please.

please don’t double-post your messages. if you think your thread is in the wrong forum, contact a moderator to get it moved. posting your messages in multiple forums will not get you more answers (people tend to read this forum using the “unread posts” function). I merged your two topics into advanced…

What graphics card are you on? I know of some techniques for debugging openCL kernels. For Nvidia there’s http://developer.nvidia.com/nvidia-parallel-nsight and I know there’s something for ATI cards too. You can also check out gDebugger (http://www.gremedy.com/), which is free for a year. That’s a really powerful tool that allows you to see what’s going on inside your kernel. You can also just add global memory parameters in your kernel:

  
  
__kernel void updateParticle(__global Particle* particles, __global float2* posBuffer, __global int *works const float2 mousePos, const float2 dimensions){  
	int id = get_global_id(0);  
// rest unchanged  
	works = 1;  
}  

that’ll just tell you if it’s running.

My graphics card is a nvidia GTX 460.

Cannot install gDebugger it gives me an error at least in my computer with the GTX 460:

  
An error ocurred during the intalation of assembly component  
{844EFBA7-1C24-93B2-A01F-C8B3B9A1E18E}.  
HRESULT:0x80073715.  

Iv searched for a solution but there is no solution available, If I reinstall the system Ill try it again.

nsight is only for visual studio and Im using codeblocks.

When I use your code in the kernel it gives errors that appear on the console as seen on the first attachment.

As I said I am new at this and I don´t understand your code, what should it do?

See the second attachment-> the console when I use the default kernel and particles appear static on screen, everything seems fine, no?

It’s a typo:

  
__kernel void updateParticle(__global Particle* particles, __global float2* posBuffer, __global int *works, const float2 mousePos, const float2 dimensions)  

This is just a way to know how far the kernel gets in execution. If it’s not updating then most likely the kernel isn’t executing all the way through. Is there a reason that you’re trying to do this in openCL rather than just on the CPU? Particle systems on the CPU are quite easy and there are lots of examples that you can follow that will be easier to debug and modify.

I noticed that before but I did not added the extra argument to the kernel in testApp.cpp, I have done it now and also added in testApp::draw():

  
string info = "fps: " + ofToString(ofGetFrameRate()) + "\nnumber of particles: " + ofToString(NUM_PARTICLES) + "\nworks=" + ofToString(works);  

and it returned 0 so I assume that the kernel is not being updated.

I would like to know why. Any thoughts?
In the console everything seems fine.

The reason I am using opencl is because I want to learn it. And the particle example is a good start.

I want to start using all the resources of my computer.

I finally got it to work!!! :slight_smile:

I have not noticed what gameover said in this thread http://forum.openframeworks.cc/t/ofxopencl/2728/37.

I had to put two extra lines of code in testApp:update() in order to work with windows:

  
void testApp::update(){  
	mousePos.x = mouseX;  
	mousePos.y = mouseY;  
	dimensions.x = ofGetWidth();  
	dimensions.y = ofGetHeight();  
  
  
  
	kernelUpdate->setArg(2, mousePos);  
	kernelUpdate->setArg(3, dimensions);  
  
	clEnqueueAcquireGLObjects(opencl.getQueue(), 1, &clMemPosVBO.getCLMem(), 0,0,0); // added by gameover (matt gingold)  
  
	kernelUpdate->run1D(NUM_PARTICLES);  
  
	clEnqueueReleaseGLObjects(opencl.getQueue(), 1, &clMemPosVBO.getCLMem(), 0,0,0); // added by gameover (matt gingold)  
  
}  

Now I got 10 milion particles at minimum 25 fps!

Thanks matt.

Thank you guys very much, you saved me from another hours of debugging