uncomplicate / clojurecl

ClojureCL is a Clojure library for parallel computations with OpenCL.
Eclipse Public License 1.0
276 stars 18 forks source link

Problem running on Mac OS X #8

Closed amherag closed 8 years ago

amherag commented 8 years ago

I can already run some functions like (platforms). But running (map info (first (platforms))) throws an error:

({:profile "FULL_PROFILE",
  :version "OpenCL 1.2 (Dec  8 2015 17:02:20)",
  :name "Apple",
  :vendor "Apple",
  :extensions
  #{"cl_APPLE_SetMemObjectDestructor" "cl_APPLE_query_kernel_names" "cl_APPLE_gl_sharing" "cl_APPLE_clut"
    "cl_khr_gl_event" "cl_APPLE_ContextLoggingFunctions"},
  :icd-suffix-khr #error {
 :cause "OpenCL error: CL_INVALID_VALUE."
 :data {:name "CL_INVALID_VALUE", :code -30, :type :opencl-error, :details nil}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "OpenCL error: CL_INVALID_VALUE."
   :data {:name "CL_INVALID_VALUE", :code -30, :type :opencl-error, :details nil}
   :at [clojure.core$ex_info invokeStatic "core.clj" 4617]}]

I've been researching and trying several things for the past 2 days but I've been unsuccessful. I've already compiled JOCL 0.2.0 for my Mac, I've tried ClojureCL 0.5.0, 0.2.0, 0.1.2, and 0.1.1, and it's always the same. I've also set ClojureCL's open-cl-2 variable to false by using the following code:

(alter-var-root
   (var uncomplicate.clojurecl.core/*opencl-2*)
   (fn [f]  false))

I've also tried to use Java's Anaparapi on Clojure, but apparently it doesn't work on dynamically binded languages. My final goal is to do matrices operations on the GPU, so the idea of using Neanderthal was awesome, but I can't even run ClojureCL (and actually, I already dropped the idea of using Neanderthal because it seems it requires OpenCL 2.0 and Apple doesn't seem to care about upgrading). I feel so trapped on Clojure that I'm considering changing to another language. I hope I can find a solution to this problem :D

blueberry commented 8 years ago

Good news: It is not an error. Your code works!

info tries to gather all information, even those that OpenCL does not recognize, but then catches eventual errors and displays error info instead of these particular bits. The existing info is, as you can see, displayed properly.

Of course, in your application, you typically should not use this all-around info, but specific info-XXX functions from the info package - thus simply use the functions that you know exist on your platform (OSX).

The second issue that you have (Neanderthal and OpenCL 2.0): I am already working on the engine that supports OpenCL 1.2! I've even refactored the existing engine a lot 2 days ago to prepare Neanderthal for the new engine. That one will work on OSX!

This was not a priority for me, but the expiriments were OK, so I hope that I'll implement it soon, maybe even very soon. The only thing is that my MacBook Air does not support any OpenCL, so I'll need help in testing this. The first step would be to test ClojureCL on Mac, and help in compiling JOCL and JOCLBlast for OSX.

In recent versions of ClojureCL, support for pre-2.0 OpenCL is through the legacy package, not `opencl-2.

amherag commented 8 years ago

What a relief! Then I'm staying with Clojure and ClojureCL. And apparently, I'm moving to Neanderthal.

I want to test my Clojure code on my MacBook Pro and then move that code to a server with a Tesla K-80 we just bought for our laboratory. We'll be working on Big Data projects for the next 3 years, so I'm very interested on your library.

If you need any help testing on Macs, just give me a call. We got a bunch of MacBook Pros and MacPros.

EDIT: When is that OpenCL 1.2 version of Neanderthal getting released?

blueberry commented 8 years ago

Release:

I estimate that the implementation is not more than a couple days work, if everything goes well. I do not expect some big problems, since I can plug in to the existing code. Now, I have some other obligations, so I am not sure whether that couple of days could be this week, or the next.

Release into clojars depends also on when JOCL and JOCLBlast are released into maven central or some other public repository. Recently, I've built those and have them on my machine. I reported a few issues to the author, and these are solved, so this could be soon. The author would like to solve a few aesthetic issues before he releases RC versions, so I am not sure when exactly that could be. There, a contributor for OSX is needed, since the author uses Windows. Especially the contributor for JOCLBlast builds.

Thanks for the offer for Mac builds and testing. Where should I contact you? Github issues, or somewhere else?

amherag commented 8 years ago

I understand. I'll be playing with ClojureCL until then.

You can contact me on amherag at gmail.com.

blueberry commented 8 years ago

@amherag Hello,

I implemented the new GPU engine based on JOCLBlast and CLBlast. ClojureCL and Neanderthal will be released as soon as JOCL and JOCLBlast are released.

There are a couple of things that you could do to speed this up and to get the libraries that are optimized for the hardware you have:

  1. go to https://github.com/CNugteren/CLBlast, use the development branch, follow the instructions to build the library AND run the tuners on the different configurations of macs that you have available AND that Tesla K80 that you have. Send the results to the author to include them in the official tuning database. He plans the next release in about a week or even faster. That way, you'll get optimal performance. Otherwise, you'll get the defaults, which might be far from optimal.
  2. go to https://github.com/gpu/, clone and build these three projects: JOCLCommons, JOCL, JOCLBlast, following the guide that you can find in the JOCL project. Coordinate with the author for the inclusion of OSX binaries in the official maven central release of JOCL and JOCLBlast which should happen soon after the next CLBlast preview release.

Regards, Dragan

blueberry commented 7 years ago

FYI, in new version, 0.7.0, info output just returns the name of the exception instead of the whole exception object, in cases when the specific info is not supported. Now this is slightly less informative, but much less confusing, especially for novice users.