Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kronsteen

macrumors member
Original poster
Nov 18, 2019
48
34
I am asking this more in hope than expectation, but would greatly appreciate any help or suggestions (with apologies for a rather lengthy post). The problem I have with my existing OpenCL code is, quite simply, that I am unable to get it to build in Xcode (I have always used Xcode without problems in the past). So my question, quite simply, is:

Can anyone advise how to configure and use Xcode in order to successfully build OpenCL code for Apple Silicon?

Background:

Having just received a shiny new M3 MacBook Pro, I would really like to try out one or two of my GPU programs. They were all written several years using OpenCL, before Apple decided to give up on it in favour of Metal. (In fact, I have since converted one of them to use CUDA, but that is not useful here.) Now, I appreciate that the right thing to do is to convert them to use Metal directly, and will do this when I have time, but that will take several days, if not weeks (I have never had reason to use Metal until now, so I will also have to learn how to do so). Meanwhile, I would very much like to try them out right now, using OpenCL, simply to find out how they run on Apple Silicon (I have previously only used them on older, Intel Macs with AMD GPUs). It would be great to see my code running on the M3’s GPU.

The reasons I think this must still be possible are (a) there are plenty of Geekbench OpenCL results for the M3 chips; and (b) I have managed to compile and run a *really* trivial OpenCL program (just using clang from the command line, with the Kernel being compiled at runtime).

The problem I am getting is that, having cloned one of my sets of programs into Xcode on my new M3 Mac, I am unable to get any of the OpenCL kernels even to build. The failure I’m getting is that, as part of the build process that has always worked in the past, Xcode is trying to run a version of openclc in the directory /System/Library/Frameworks/OpenCL.framework/Libraries/, which gives the error condition Bad CPU type in executable). It seems that this is an x86_64 version of openclc. There is a universal binary version in /System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/Libraries/, but I have been unable to find a way to configure (or force ….) Xcode to use that one (and I have no way of knowing whether it would produce the correct output for Apple Silicon).

It may well be, of course, that if I manage to get past this problem, another one will present itself. Nonetheless, if any of you can suggest anything that I might try, I would be most grateful.

Thanks ….
Andrew

Edit: I have also posted this question on the Apple Developer forum, but haven’t received any responses there either.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.