sctincman / freeocl

OpenCL 1.2 implementation targeting CPUs, utilizing an external C++ compiler
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Support OSX #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I find that FreeOCL (revision 313) does not work on OSX out of the box. I had 
to make some changes (see patch) to make it build and run. In some cases, I 
tried to find a generic solution that is likely to work on other systems as 
well, in other, more complex cases I only made it work for OSX, and one still 
needs to integrate this with other platforms.

The patches do the following:

Configuring FreeOCL: cmake's CMAKE_THREAD_LIBS_INIT is not defined.

Compiling OpenCL code: The option -cl-strict-aliasing was not supported.

Startup: OSX uses a slightly different sysctl. I also added hiding errors 
(2>/dev/null). In general, I recommend hwloc to find out about 
memory/cache/cores etc.; this is a high-quality, very portable library from the 
OpenMPI developers.

src/kernel.cpp: Did not compile for me. Presumably, some "cl_" type prefixes 
were missing.

atomic operstions: I don't have atomic_ops.h. I'm using gcc builtins instead. 
The current code works for gcc 4.8.

clock: OSX doesn't have clock_gettime. Instead, there is a routine 
mach_absolute_time that one can call. The result is probably in cycles and 
needs to be converted to nanoseconds.

Original issue reported on code.google.com by schnetter on 5 May 2013 at 3:30

Attachments:

GoogleCodeExporter commented 9 years ago
I have integrated your patch in r315. This requires testing (I don't have 
access to OSX for testing). I tried not to duplicate code however, the clock 
stuffs still need some work : µs, ms, and seconds are computed from a 
nanosecond timer with a possible loss of useful information depending on the 
platform. The freeocl.icd file is generated by cmake now, it avoids the need 
for several instances of it.

You'll likely face issues with atomics at runtime when compiling kernels since 
the same library is used for several OpenCL built-in atomics.

hwloc definitely looks interesting, I am going to test it.

Original comment by zuzu...@gmail.com on 8 May 2013 at 12:21