[GH-ISSUE #1583] OSX(?) OpenCL bugs w/ latest AMD device driver #1037

Closed
opened 2026-10-14 03:32:41 +07:00 by bsakaguchi · 13 comments
Owner

Originally created by @magnumripper on GitHub (Jul 27, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1583

Originally assigned to: @magnumripper on GitHub.

I presume these are driver bugs but we should try working around them (might even be a single issue causing all problems).

http://www.openwall.com/lists/john-users/2015/07/27/1 (ATI Radeon HD 6970M)
http://www.openwall.com/lists/john-users/2015/07/27/2 (AMD Radeon HD - FirePro D300 Compute Engine)

Originally created by @magnumripper on GitHub (Jul 27, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1583 Originally assigned to: @magnumripper on GitHub. I presume these are driver bugs but we should try working around them (might even be a single issue causing all problems). http://www.openwall.com/lists/john-users/2015/07/27/1 (ATI Radeon HD 6970M) http://www.openwall.com/lists/john-users/2015/07/27/2 (AMD Radeon HD - FirePro D300 Compute Engine)
bsakaguchi 2026-10-14 03:32:41 +07:00
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

Albert's log (working ones deleted)

Device 1: ATI Radeon HD 6970M
Benchmarking: sha1crypt-opencl, (NetBSD) [PBKDF1-SHA1 OpenCL 4x]... FAILED (cmp_all(1))

Benchmarking: oldoffice-opencl, MS Office <= 2003 [MD5/SHA1 RC4 OpenCL]... FAILED (cmp_all(4))

Benchmarking: PBKDF2-HMAC-SHA1-opencl [PBKDF2-SHA1 OpenCL 4x]... FAILED (cmp_all(1))

Benchmarking: sha256crypt-opencl, crypt(3) $5$ (rounds=5000) [SHA256 OpenCL]... FAILED (cmp_all(1))

Building the kernel, this could take a while
Options used: -I ./kernels -cl-mad-enable -D__OS_X__ -D__GPU__ -DDEVICE_INFO=10 -DDEV_VER_MAJOR=1 -DDEV_VER_MINOR=2 -D_OPENCL_COMPILER
Build log: <program source>:132:16: error: call to 'bitselect' is ambiguous
    w_vector = SWAP64_V(w_vector);
           ^~~~~~~~~~~~~~~~~~
/Users/albert/Downloads/magnumripper-JohnTheRipper-5431fd3/run/./kernels/opencl_sha512.h:32:26: note: expanded from macro 'SWAP64_V'
    #define SWAP64_V(n) SWAP64(n)
             ^~~~~~~~~
/Users/albert/Downloads/magnumripper-JohnTheRipper-5431fd3/run/./kernels/opencl_sha512.h:26:9: note: expanded from macro 'SWAP64'
                    bitselect(rotate(n, 24UL),              \
    ^~~~~~~~~
/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5254:22: note: candidate function
ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, long16 m);
             ^
/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function
ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m);
             ^

Error -11 building kernel $JOHN/kernels/cryptsha512_kernel_GPU.cl. DEVICE_INFO=10
OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (976) - (clBuildProgram failed.)
<!-- gh-comment-id:125307040 --> @magnumripper commented on GitHub (Jul 27, 2015): Albert's log (working ones deleted) ``` Device 1: ATI Radeon HD 6970M Benchmarking: sha1crypt-opencl, (NetBSD) [PBKDF1-SHA1 OpenCL 4x]... FAILED (cmp_all(1)) Benchmarking: oldoffice-opencl, MS Office <= 2003 [MD5/SHA1 RC4 OpenCL]... FAILED (cmp_all(4)) Benchmarking: PBKDF2-HMAC-SHA1-opencl [PBKDF2-SHA1 OpenCL 4x]... FAILED (cmp_all(1)) Benchmarking: sha256crypt-opencl, crypt(3) $5$ (rounds=5000) [SHA256 OpenCL]... FAILED (cmp_all(1)) Building the kernel, this could take a while Options used: -I ./kernels -cl-mad-enable -D__OS_X__ -D__GPU__ -DDEVICE_INFO=10 -DDEV_VER_MAJOR=1 -DDEV_VER_MINOR=2 -D_OPENCL_COMPILER Build log: <program source>:132:16: error: call to 'bitselect' is ambiguous w_vector = SWAP64_V(w_vector); ^~~~~~~~~~~~~~~~~~ /Users/albert/Downloads/magnumripper-JohnTheRipper-5431fd3/run/./kernels/opencl_sha512.h:32:26: note: expanded from macro 'SWAP64_V' #define SWAP64_V(n) SWAP64(n) ^~~~~~~~~ /Users/albert/Downloads/magnumripper-JohnTheRipper-5431fd3/run/./kernels/opencl_sha512.h:26:9: note: expanded from macro 'SWAP64' bitselect(rotate(n, 24UL), \ ^~~~~~~~~ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5254:22: note: candidate function ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, long16 m); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m); ^ Error -11 building kernel $JOHN/kernels/cryptsha512_kernel_GPU.cl. DEVICE_INFO=10 OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (976) - (clBuildProgram failed.) ```
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

Philip's log (working ones deleted)

Benchmarking: oldoffice-opencl, MS Office <= 2003 [MD5/SHA1 RC4 OpenCL]... FAILED (cmp_all(1))

Benchmarking: agilekeychain-opencl, 1Password Agile Keychain [PBKDF2-SHA1 OpenCL AES]... FAILED (cmp_all(1))

Benchmarking: blockchain-opencl, blockchain My Wallet [PBKDF2-SHA1 OpenCL AES]... FAILED (cmp_all(1))

Building the kernel, this could take a while
Options used: -I ../run/kernels -cl-mad-enable -D__OS_X__ -D__GPU__ -DDEVICE_INFO=10 -DDEV_VER_MAJOR=1 -DDEV_VER_MINOR=2 -D_OPENCL_COMPILER 
Build log: <program source>:132:16: error: call to 'bitselect' is ambiguous
    w_vector = SWAP64_V(w_vector);
               ^~~~~~~~~~~~~~~~~~
../run/kernels/opencl_sha512.h:32:26: note: expanded from macro 'SWAP64_V'
        #define SWAP64_V(n)     SWAP64(n)
                         ^~~~~~~~~
../run/kernels/opencl_sha512.h:26:9: note: expanded from macro 'SWAP64'
                                    bitselect(rotate(n, 24UL),                      \
        ^~~~~~~~~
/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5254:22: note: candidate function
ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, long16 m);
                     ^
/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function
ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m);
                     ^

Error -11 building kernel $JOHN/kernels/cryptsha512_kernel_GPU.cl. DEVICE_INFO=10
OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (976) - (clBuildProgram failed.)
<!-- gh-comment-id:125308815 --> @magnumripper commented on GitHub (Jul 27, 2015): Philip's log (working ones deleted) ``` Benchmarking: oldoffice-opencl, MS Office <= 2003 [MD5/SHA1 RC4 OpenCL]... FAILED (cmp_all(1)) Benchmarking: agilekeychain-opencl, 1Password Agile Keychain [PBKDF2-SHA1 OpenCL AES]... FAILED (cmp_all(1)) Benchmarking: blockchain-opencl, blockchain My Wallet [PBKDF2-SHA1 OpenCL AES]... FAILED (cmp_all(1)) Building the kernel, this could take a while Options used: -I ../run/kernels -cl-mad-enable -D__OS_X__ -D__GPU__ -DDEVICE_INFO=10 -DDEV_VER_MAJOR=1 -DDEV_VER_MINOR=2 -D_OPENCL_COMPILER Build log: <program source>:132:16: error: call to 'bitselect' is ambiguous w_vector = SWAP64_V(w_vector); ^~~~~~~~~~~~~~~~~~ ../run/kernels/opencl_sha512.h:32:26: note: expanded from macro 'SWAP64_V' #define SWAP64_V(n) SWAP64(n) ^~~~~~~~~ ../run/kernels/opencl_sha512.h:26:9: note: expanded from macro 'SWAP64' bitselect(rotate(n, 24UL), \ ^~~~~~~~~ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5254:22: note: candidate function ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, long16 m); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m); ^ Error -11 building kernel $JOHN/kernels/cryptsha512_kernel_GPU.cl. DEVICE_INFO=10 OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (976) - (clBuildProgram failed.) ```
Author
Owner

@ghost commented on GitHub (Jul 27, 2015):

For sha512crypt it is something different. A strange include.

/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function
ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m);
<!-- gh-comment-id:125313294 --> @ghost commented on GitHub (Jul 27, 2015): For sha512crypt it is something different. A strange include. ``` /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:5302:22: note: candidate function ulong16 __OVERLOAD__ bitselect( ulong16 x, ulong16 y, ulong16 m); ```
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

You can ignore the strange library path, OSX use to look like that.

I've seen such errors before. Adding some no-op typecast within the macros use to help.

<!-- gh-comment-id:125315241 --> @magnumripper commented on GitHub (Jul 27, 2015): You can ignore the strange library path, OSX use to look like that. I've seen such errors before. Adding some no-op typecast within the macros use to help.
Author
Owner

@ghost commented on GitHub (Jul 27, 2015):

I guess it will fail anyway, but an easy fix is to avoid AMD bitselect() on OSX.

Or a type cast, as you said.

<!-- gh-comment-id:125317974 --> @ghost commented on GitHub (Jul 27, 2015): I guess it will fail anyway, but an easy fix is to avoid AMD bitselect() on OSX. Or a type cast, as you said.
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

I think it's this line (despite wrong line number from error)

    ulong16  w_vector;
    (...)
    w_vector = SWAP64_V(w_vector);

SWAP64_V is this

    #define SWAP64(n)   bitselect(                      \
                    bitselect(rotate(n, 24UL),              \
                    rotate(n, 8UL), 0x000000FF000000FFUL),      \
                    bitselect(rotate(n, 56UL),              \
                    rotate(n, 40UL), 0x00FF000000FF0000UL),     \
                    0xFFFF0000FFFF0000UL)

    #define SWAP64_V(n)     SWAP64(n)

No typecast should be needed but I've seen it before with AMD.

<!-- gh-comment-id:125319421 --> @magnumripper commented on GitHub (Jul 27, 2015): I think it's this line (despite wrong line number from error) ``` ulong16 w_vector; (...) w_vector = SWAP64_V(w_vector); ``` SWAP64_V is this ``` #define SWAP64(n) bitselect( \ bitselect(rotate(n, 24UL), \ rotate(n, 8UL), 0x000000FF000000FFUL), \ bitselect(rotate(n, 56UL), \ rotate(n, 40UL), 0x00FF000000FF0000UL), \ 0xFFFF0000FFFF0000UL) #define SWAP64_V(n) SWAP64(n) ``` No typecast **should** be needed but I've seen it before with AMD.
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

Disabling bitselect totally would be a bit harsh. Maybe just for the SWAP64 macro though.

<!-- gh-comment-id:125319864 --> @magnumripper commented on GitHub (Jul 27, 2015): Disabling bitselect totally would be a bit harsh. Maybe just for the SWAP64 macro though.
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

@Sayantan2048 or @zzlei do any of you have some Mac with AMD device?

<!-- gh-comment-id:125320613 --> @magnumripper commented on GitHub (Jul 27, 2015): @Sayantan2048 or @zzlei do any of you have some Mac with AMD device?
Author
Owner

@ghost commented on GitHub (Jul 27, 2015):

I have to take a look at home. Anyway, it is possible to create something like this inside the kernel.

If AMD and OSX

  • do something different for macro SWAP64, keep the others.

Else

  • do what we are doing now
<!-- gh-comment-id:125320682 --> @ghost commented on GitHub (Jul 27, 2015): I have to take a look at home. Anyway, it is possible to create something like this inside the kernel. If AMD and OSX - do something different for macro SWAP64, keep the others. Else - do what we are doing now
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

This should do

diff --git a/src/opencl_sha512.h b/src/opencl_sha512.h
index c36459a..9205bd6 100644
--- a/src/opencl_sha512.h
+++ b/src/opencl_sha512.h
@@ -18,7 +18,7 @@
 #define MAX_KEYS_PER_CRYPT      1

 //Macros.
-#ifdef USE_BITSELECT
+#if defined(USE_BITSELECT) && !defined(__OS_X__)
        #define Ch(x,y,z)       bitselect(z, y, x)
        #define Maj(x,y,z)      bitselect(x, y, z ^ x)
        #define ror(x, n)       ((x >> n) | (x << (64UL-n)))

But it's no use committing it yet. We need a coder with Mac+AMD gear.

<!-- gh-comment-id:125322332 --> @magnumripper commented on GitHub (Jul 27, 2015): This should do ``` diff diff --git a/src/opencl_sha512.h b/src/opencl_sha512.h index c36459a..9205bd6 100644 --- a/src/opencl_sha512.h +++ b/src/opencl_sha512.h @@ -18,7 +18,7 @@ #define MAX_KEYS_PER_CRYPT 1 //Macros. -#ifdef USE_BITSELECT +#if defined(USE_BITSELECT) && !defined(__OS_X__) #define Ch(x,y,z) bitselect(z, y, x) #define Maj(x,y,z) bitselect(x, y, z ^ x) #define ror(x, n) ((x >> n) | (x << (64UL-n))) ``` But it's no use committing it yet. We need a coder with Mac+AMD gear.
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

Hey, I can reproduce it just by forcing USE_BITSELECT on my nvidia macbook. I will take care of that problem (later).

<!-- gh-comment-id:125323454 --> @magnumripper commented on GitHub (Jul 27, 2015): Hey, I can reproduce it just by forcing USE_BITSELECT on my nvidia macbook. I will take care of that problem (later).
Author
Owner

@magnumripper commented on GitHub (Jul 27, 2015):

Damn compilers. There's absolutely nothing ambiguous in those macros.

<!-- gh-comment-id:125325357 --> @magnumripper commented on GitHub (Jul 27, 2015): Damn compilers. There's absolutely nothing ambiguous in those macros.
Author
Owner

@lei-april commented on GitHub (Jul 28, 2015):

@magnumripper Sorry, I don't have one.

<!-- gh-comment-id:125396317 --> @lei-april commented on GitHub (Jul 28, 2015): @magnumripper Sorry, I don't have one.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1037
No description provided.