- Joined
- Feb 5, 2011
- Messages
- 174
- Motherboard
- Gigabyte GA-Z77M-D3H
- CPU
- i7-3770
- Graphics
- GTX 780
- Mac
- Mobile Phone
So...
You're probably here because you have a GK110B based GPU which crashes with all OpenCL apps. I managed to stop the crashes and here's a guide for y'all.
THIS WILL STOP THE CRASHES, DOES NOT ADD THE PROPER SUPPORT!
AFTER UPDATING THE OS, RE-CREATE YOUR OPENCL BACKUP!
First of all:
What I did:
What you need:
Creating a backup:
There are multiple ways of doing this, but this is what I usually do.
Now you will have the original version as "OpenCL.bkp" next to the modded version
Caution: after updating the OS re-create the backup because it will be the backup of the older version, and you don’t really want to revert to that.
The Guide:
How to revert:
This applies when the backup method was the one mentioned above.
Why I won't share the binary:
Because I codesigned it sorry
Caution:
Tested with:
Preview (jpg, png), Xcode (assistant view), LuxMark, Safari, Premiere Pro CC (trial) and others
Fast walkthrough on what I modified:
When an app is using the OpenCL library nothing special happens until the library gets the first call. When this happens, OpenCL initialises itself.
This is in the /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL file at offset <0x21734> (in 10.9.0 and 10.9.1). (If you wan’t to tag along, then you probably need a disassembler)
This initialisation block contains three pthread_once calls for three different functions.
If we don’t want it to call pthread_once, we only need to change the condition to this:
There is no way it will call it now
If you look at the patch, this is exactly what I did, the only real difference in the search hex and the replace hex is a 5->0 change.
Updates:
- Added 32 & 64-bit patches for 10.9.5
- Added 32 & 64-bit patches for 10.9.4
- Added 32 & 64-bit patches for 10.9.3, thanks to @MyAss
- Added 32 & 64-bit patches for 10.9.2, guide is more verbose
- Added 32-bit patch for 10.9.0 and 10.9.1
You're probably here because you have a GK110B based GPU which crashes with all OpenCL apps. I managed to stop the crashes and here's a guide for y'all.
THIS WILL STOP THE CRASHES, DOES NOT ADD THE PROPER SUPPORT!
AFTER UPDATING THE OS, RE-CREATE YOUR OPENCL BACKUP!
First of all:
- USE AT OWN RISK, I AM NOT RESPONSIBLE FOR DAMAGE, BLABLABLA (you know the deal...)
- TESTED ON 10.9.0, 10.9.1, 10.9.2, 10.9.3, 10.9.4, 10.9.5
- DON'T FORGET TO BACKUP THE FRAMEWORK BEFORE MODIFYING
What I did:
- Disabled GPU OpenCL support (FOR ALL GPUs).
- CPU OpenCL is still supported (NOT IGPU)
- CUDA is still supported
What you need:
- Xcode (for codesigning)
- A hex editor (I'll be using Hex Fiend)
Creating a backup:
There are multiple ways of doing this, but this is what I usually do.
- Open Terminal
Code:
sudo -s
<enter password>
cd /System/Library/Frameworks/OpenCL.framework/Versions/A/
cp OpenCL OpenCL.bkp
Caution: after updating the OS re-create the backup because it will be the backup of the older version, and you don’t really want to revert to that.
The Guide:
- Create a Certificate for codesigning (if you don't have one already)
- Open Keychain Access
- Go to Keychain Access > Certificate Assistant > Create a Certificate...
- Give it a name like "OpenCLFWKCS" (I will use this name later)
- Identity Type: Self Signed Root
- Certificate Type: Code Signing
- Create
- Copy the file somewhere where you can edit it (for example to your desktop with Terminal)
Code:cp /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL ~/Desktop/OpenCL
- Open the editable copy of your OpenCL file in a hex editor
- For 10.9.0 and 10.9.1
WARNING: THERE SHOULD ONLY BE ONE MATCH
Code:64-bit Replace: E83DE10100F6C3057413 With: E83DE10100F6C3007413 32-bit Replace: E81EF901008B4508A8057418 With: E81EF901008B4508A8007418
- For 10.9.2
WARNING: THERE SHOULD ONLY BE ONE MATCH
Code:64-bit Replace: E831E30100F6C3057413 With: E831E30100F6C3007413 32-bit Replace: 8B4508A80574188D8638010000 With: 8B4508A80074188D8638010000
- For 10.9.3 and 10.9.4
WARNING: THERE SHOULD ONLY BE ONE MATCH
Code:64-bit Replace: E8DFE30100F6C3057413 With: E8DFE30100F6C3007413 32-bit Replace: 8B4508A80574188D8638010000 With: 8B4508A80074188D8638010000
- For 10.9.5
WARNING: THERE SHOULD ONLY BE ONE MATCH
Code:64-bit Replace: E8CBE30100F6C3057413 With: E8CBE30100F6C3007413 32-bit Replace: E892FB01008B4508A8057418 With: E892FB01008B4508A8007418
- For 10.9.0 and 10.9.1
- Copy back the edited version of the OpenCL file to the framework (with Terminal)
Code:sudo cp ~/Desktop/OpenCL /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
- Resign the OpenCL framework
Code:sudo codesign -fs "OpenCLFWKCS" [u]/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL[/u]
- Restart
How to revert:
This applies when the backup method was the one mentioned above.
- Boot chameleon with -s
Code:
/sbin/mount -uw /
cd /System/Library/Frameworks/OpenCL.framework/Versions/A/
cp OpenCL.bkp OpenCL
Why I won't share the binary:
Because I codesigned it sorry
Caution:
- Do not share the modified executable
- Do not share the created certificate
Tested with:
Preview (jpg, png), Xcode (assistant view), LuxMark, Safari, Premiere Pro CC (trial) and others
Fast walkthrough on what I modified:
When an app is using the OpenCL library nothing special happens until the library gets the first call. When this happens, OpenCL initialises itself.
This is in the /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL file at offset <0x21734> (in 10.9.0 and 10.9.1). (If you wan’t to tag along, then you probably need a disassembler)
This initialisation block contains three pthread_once calls for three different functions.
- The first probably does some basic initialisation
- The second initialises CPU support
- The third initialises GPU support - this is what we don’t want
Code:
if (x & 5) { pthread_once(...); }
For non-programmers x & 5 is a bitwise AND operation (http://en.wikipedia.org/wiki/Bitwise_operation#AND)
If you bitwise AND any value with zero, the result will be zero.
If you bitwise AND any value with zero, the result will be zero.
If we don’t want it to call pthread_once, we only need to change the condition to this:
Code:
if (x & 0) { pthread_once(...); }
If you look at the patch, this is exactly what I did, the only real difference in the search hex and the replace hex is a 5->0 change.
Updates:
- Added 32 & 64-bit patches for 10.9.5
- Added 32 & 64-bit patches for 10.9.4
- Added 32 & 64-bit patches for 10.9.3, thanks to @MyAss
- Added 32 & 64-bit patches for 10.9.2, guide is more verbose
- Added 32-bit patch for 10.9.0 and 10.9.1