Author Topic: Sailfish OpenCL fluid simulation  (Read 14807 times)

0 Members and 1 Guest are viewing this topic.


  • NewsPosters
  • Jr. Member
  • *
  • Posts: 92
Sailfish OpenCL fluid simulation
« on: January 22, 2010, 11:23:05 AM »
Hi JeGX,

Have you looked at the OpenCL fluid simulation Sailfish before?

It uses pyopencl!

I have been hacking away to get this running under Windows. I have installed Python all the required modules, including compiling pyopencl against the ATI Stream 2.0 SDK.

I had to make a few modifications to Sailfish as it was designed for Linux. This included removing a hardcoded path, and adding support for the OpenCL ICD (selecting an OpenCL platform...).

I have had mixed results.
The example scripts compile fine, and run with no exceptions, yet I get black pixels, and the frames simulated per second is impossibly fast. I have the feeling the kernel is not running, but no error seems to be generated...
Also the ATI compiler always returns warnings that  the -cl-single-precision-constant and -cl-fast-relaxed-math compiler options are not supported despite being in the OpenCL specification...

But I can get the simulation to work perfectly and produce the red pixels if I run it via clprofile.exe! It probably runs slower though thanks to all the logging to stdout and the CSV file...
Why does profiling make it work?!?

Also the 3D simulations always fail with the following error:
Code: [Select]
Traceback (most recent call last):
  File "c:\sailfish\examples\", line 54, in <module>
  File "C:\python26\lib\site-packages\sailfish\", line 715, in run
  File "C:\python26\lib\site-packages\sailfish\", line 312, in main
  File "C:\python26\lib\site-packages\sailfish\", line 532, in sim_step
    self.backend.run_kernel(kerns[1], self.kern_grid_size)
  File "C:\python26\lib\site-packages\sailfish\", line 54, in r
    cl.enqueue_nd_range_kernel(self.queue, kernel, global_size, kernel.block)
pyopencl.LogicError: enqueue_nd_range_kernel failed: invalid value - global/work
 work sizes have differing dimensions

I have traced this back possibly being to line 517 in
Code: [Select]
self.kern_grid_size = (self.options.lat_nx/self.block_size * self.options.lat_ny, self.options.lat_nz)but if I change this to:
Code: [Select]
self.kern_grid_size = (self.options.lat_nx/self.block_size, self.options.lat_ny, self.options.lat_nz)the script runs but I get black pixels (even when inside the profiler).

Could you try this out on your setup and see what you get?
I have attached the modified python files.

In case it is any help I have attached a GPU Caps Viewer XML file.

Latest 32bit 2.6 python, and latest version of all required modules.
Compiled pyopencl with Visual Studio 2008 Professional SP1.
I am only running OpenCL on CPU as I have not got a graphics card for my new system yet.



  • NewsPosters
  • Jr. Member
  • *
  • Posts: 92
Re: Sailfish OpenCL fluid simulation
« Reply #1 on: January 22, 2010, 11:39:39 AM »
Since I can't attach files, here is a zip file:


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2149
Re: Sailfish OpenCL fluid simulation
« Reply #2 on: January 22, 2010, 02:57:00 PM »
In GPU Caps OpenCL demos I don't use compiler options with AMD because AMD's CL doesn't support them yet. Only  NV supports them (like -cl-fast-relaxed-math).

But I'm really busy and currently I don't have time to look at this cool python lib.

Have you tried this lib with GeeXLab ? I guess some functionalities will be missing in GeeXLab, but try to have a look (and it will be easier for me to play with a GeeXLab project).