[GH-ISSUE #410] mscash2-opencl still don't handle weak devices properly. #139

Closed
opened 2026-10-14 02:53:59 +07:00 by bsakaguchi · 13 comments
Owner

Originally created by @magnumripper on GitHub (Oct 24, 2013).
Original GitHub issue: https://github.com/openwall/john/issues/410

Originally assigned to: @sayan1an on GitHub.

Here's an example on 9600GT

$ ../run/john -t -form:mscash2-opencl -dev=gpu
Device 0: GeForce 9600 GT
OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (459) - (Sync FAILED)

If you look at line 459 and above, you can see that your error-handling is too early, at least for nvidia. Note that it's the auto-tune that fails - the format works fine on this device given specific LWS/GWS figures:

$ LWS=64 GWS=16384 ../run/john -t -form:mscash2-opencl -dev=gpu
Device 0: GeForce 9600 GT
Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE
Raw:    3126 c/s real, 3126 c/s virtual
Originally created by @magnumripper on GitHub (Oct 24, 2013). Original GitHub issue: https://github.com/openwall/john/issues/410 Originally assigned to: @sayan1an on GitHub. Here's an example on 9600GT ``` $ ../run/john -t -form:mscash2-opencl -dev=gpu Device 0: GeForce 9600 GT OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (459) - (Sync FAILED) ``` If you look at line 459 and above, you can see that your error-handling is too early, at least for nvidia. Note that it's the _auto-tune_ that fails - the format works fine on this device given specific LWS/GWS figures: ``` $ LWS=64 GWS=16384 ../run/john -t -form:mscash2-opencl -dev=gpu Device 0: GeForce 9600 GT Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE Raw: 3126 c/s real, 3126 c/s virtual ```
bsakaguchi 2026-10-14 02:53:59 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sayan1an commented on GitHub (Oct 25, 2013):

Hi magnum,

On Thu, Oct 24, 2013 at 11:50 PM, magnum notifications@github.com wrote:

Here's an example on 9600GT

$ ../run/john -t -form:mscash2-opencl -dev=gpu
Device 0: GeForce 9600 GT
OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (459) - (Sync FAILED)

Note that it's the auto-tune that fails - the format works fine on this
device given specific LWS/GWS figures:

$ LWS=64 GWS=16384 ../run/john -t -form:mscash2-opencl -dev=gpu
Device 0: GeForce 9600 GT
Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE
Raw: 3126 c/s real, 3126 c/s virtual

—
Reply to this email directly or view it on GitHubhttps://github.com/magnumripper/JohnTheRipper/issues/410
.

Please test this experimental patch.

Regards,
Sayantan

<!-- gh-comment-id:27110963 --> @sayan1an commented on GitHub (Oct 25, 2013): Hi magnum, On Thu, Oct 24, 2013 at 11:50 PM, magnum notifications@github.com wrote: > Here's an example on 9600GT > > $ ../run/john -t -form:mscash2-opencl -dev=gpu > Device 0: GeForce 9600 GT > OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (459) - (Sync FAILED) > > Note that it's the _auto-tune_ that fails - the format works fine on this > device given specific LWS/GWS figures: > > $ LWS=64 GWS=16384 ../run/john -t -form:mscash2-opencl -dev=gpu > Device 0: GeForce 9600 GT > Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE > Raw: 3126 c/s real, 3126 c/s virtual > > — > Reply to this email directly or view it on GitHubhttps://github.com/magnumripper/JohnTheRipper/issues/410 > . Please test this experimental patch. Regards, Sayantan
Author
Owner

@magnumripper commented on GitHub (Oct 25, 2013):

Which? Where?

<!-- gh-comment-id:27116433 --> @magnumripper commented on GitHub (Oct 25, 2013): Which? Where?
Author
Owner

@sayan1an commented on GitHub (Oct 25, 2013):

Sorry, github doesn't show attached files. Please check your mail.

<!-- gh-comment-id:27117605 --> @sayan1an commented on GitHub (Oct 25, 2013): Sorry, github doesn't show attached files. Please check your mail.
Author
Owner

@magnumripper commented on GitHub (Oct 25, 2013):

diff --git a/src/common_opencl_pbkdf2.c b/src/common_opencl_pbkdf2.c
index 16dd220..60141b6 100644
--- a/src/common_opencl_pbkdf2.c
+++ b/src/common_opencl_pbkdf2.c
@@ -96,8 +96,8 @@ static void find_best_workgroup(int jtrUniqDevNo) {
                        globalObj[jtrUniqDevNo].exec_time_inv = globalObj[jtrUniqDevNo].exec_time_inv / 16;
                }
                else {
-                       exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536), jtrUniqDevNo, cmdq, hmac_sha1_out);
-                       globalObj[jtrUniqDevNo].exec_time_inv *= ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536) / 65536;
+                       exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, ((MAX_KEYS_PER_CRYPT < 16384) ? MAX_KEYS_PER_CRYPT : 16384), jtrUniqDevNo, cmdq, hmac_sha1_out);
+                       globalObj[jtrUniqDevNo].exec_time_inv *= ((MAX_KEYS_PER_CRYPT < 16384) ? MAX_KEYS_PER_CRYPT : 16384) / 16384;
                }

                if (globalObj[jtrUniqDevNo].lws <= _lws) break;

OK, I do not think this is the right solution. First, we should handle weak devices but not let them spoil performance on powerful devices. Second, we should actually query devices and tune to them. I do have an experimental patch (from just hours ago) that does handle 9600GT but I need to regression test it. I think it might be half of the answer. I'll keep in touch.

<!-- gh-comment-id:27119376 --> @magnumripper commented on GitHub (Oct 25, 2013): ``` diff --git a/src/common_opencl_pbkdf2.c b/src/common_opencl_pbkdf2.c index 16dd220..60141b6 100644 --- a/src/common_opencl_pbkdf2.c +++ b/src/common_opencl_pbkdf2.c @@ -96,8 +96,8 @@ static void find_best_workgroup(int jtrUniqDevNo) { globalObj[jtrUniqDevNo].exec_time_inv = globalObj[jtrUniqDevNo].exec_time_inv / 16; } else { - exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536), jtrUniqDevNo, cmdq, hmac_sha1_out); - globalObj[jtrUniqDevNo].exec_time_inv *= ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536) / 65536; + exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, ((MAX_KEYS_PER_CRYPT < 16384) ? MAX_KEYS_PER_CRYPT : 16384), jtrUniqDevNo, cmdq, hmac_sha1_out); + globalObj[jtrUniqDevNo].exec_time_inv *= ((MAX_KEYS_PER_CRYPT < 16384) ? MAX_KEYS_PER_CRYPT : 16384) / 16384; } if (globalObj[jtrUniqDevNo].lws <= _lws) break; ``` OK, I do not think this is the right solution. First, we should handle weak devices but not let them spoil performance on powerful devices. Second, we should actually _query_ devices and _tune_ to them. I do have an experimental patch (from just hours ago) that does handle 9600GT but I need to regression test it. I think it might be half of the answer. I'll keep in touch.
Author
Owner

@magnumripper commented on GitHub (Oct 25, 2013):

OK, I do not think this is the right solution.

Don't get me wrong, I will try this out too.

<!-- gh-comment-id:27126841 --> @magnumripper commented on GitHub (Oct 25, 2013): > OK, I do not think this is the right solution. Don't get me wrong, I will try this out too.
Author
Owner

@sayan1an commented on GitHub (Oct 26, 2013):

On Sat, Oct 26, 2013 at 2:50 AM, magnum notifications@github.com wrote:

OK, I do not think this is the right solution.

Don't get me wrong, I will try this out too.

—
Reply to this email directly or view it on GitHubhttps://github.com/magnumripper/JohnTheRipper/issues/410#issuecomment-27126841
.

Yes of course this isn't a proper solution. This was just a patch to locate
the problem. I think we should have a method that broadly classify a gpu
in three categories: low, mid and high end. We might use the gpus
listed in tomshardware
gpu hierarchyhttp://www.tomshardware.com/reviews/gaming-graphics-card-review,3107-7.htmlchart
for that. It would be easier to modify auto-tune to fit all three gpu
categories.

Regards,
Sayantan

<!-- gh-comment-id:27137221 --> @sayan1an commented on GitHub (Oct 26, 2013): On Sat, Oct 26, 2013 at 2:50 AM, magnum notifications@github.com wrote: > OK, I do not think this is the right solution. > > Don't get me wrong, I will try this out too. > > — > Reply to this email directly or view it on GitHubhttps://github.com/magnumripper/JohnTheRipper/issues/410#issuecomment-27126841 > . > > Yes of course this isn't a proper solution. This was just a patch to locate > the problem. I think we should have a method that broadly classify a gpu > in three categories: low, mid and high end. We might use the gpus > listed in tomshardware > gpu hierarchyhttp://www.tomshardware.com/reviews/gaming-graphics-card-review,3107-7.htmlchart > for that. It would be easier to modify auto-tune to fit all three gpu > categories. Regards, Sayantan
Author
Owner

@magnumripper commented on GitHub (Oct 26, 2013):

I think the exact problem is it hits the five second watchdog during LWS tune, so your patch probably solves it - but maybe not for some other even weaker card.

I had some idea of writing a benchmark kernel that common-opencl.c can launch just to give a "horse power figure" for any card. So we could call a shared function and get a "factor" to use in situations like this. The problem is that it depends a lot on what you are doing. The GTX 570 is faster than HD7970 in some cases and a lot slower in other.

<!-- gh-comment-id:27150122 --> @magnumripper commented on GitHub (Oct 26, 2013): I think the exact problem is it hits the five second watchdog during LWS tune, so your patch probably solves it - but maybe not for some other even weaker card. I had some idea of writing a benchmark kernel that common-opencl.c can launch just to give a "horse power figure" for any card. So we could call a shared function and get a "factor" to use in situations like this. The problem is that it depends a lot on what you are doing. The GTX 570 is faster than HD7970 in some cases and a lot slower in other.
Author
Owner

@magnumripper commented on GitHub (Oct 26, 2013):

BTW most other formats starts with a low figure and double it each time. If a kernel duration hits 200ms or total duration (for split/looped kernels) hits 10s, we don't test higher figures. This is pretty safe while it quickly finds good figures even for flagship GPUs.

<!-- gh-comment-id:27150203 --> @magnumripper commented on GitHub (Oct 26, 2013): BTW most other formats starts with a low figure and double it each time. If a kernel duration hits 200ms or total duration (for split/looped kernels) hits 10s, we don't test higher figures. This is pretty safe while it quickly finds good figures even for flagship GPUs.
Author
Owner

@magnumripper commented on GitHub (Oct 28, 2013):

I tried your patch. It now survives lws enumeration but fails (watchdog timer) during benchmark run or self-test:

Device 0: GeForce 9600 GT
Optimal Work Group Size:128
Kernel Execution Speed (Higher is better):0.191387
Optimal Global Work Size:32768
Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (336) - (Error in Get Event Info)
<!-- gh-comment-id:27235568 --> @magnumripper commented on GitHub (Oct 28, 2013): I tried your patch. It now survives lws enumeration but fails (watchdog timer) during benchmark run or self-test: ``` Device 0: GeForce 9600 GT Optimal Work Group Size:128 Kernel Execution Speed (Higher is better):0.191387 Optimal Global Work Size:32768 Benchmarking: mscash2-opencl, M$ Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... OpenCL error (CL_OUT_OF_RESOURCES) in file (common_opencl_pbkdf2.c) at line (336) - (Error in Get Event Info) ```
Author
Owner

@sayan1an commented on GitHub (Oct 31, 2013):

Please test 26055

<!-- gh-comment-id:27511450 --> @sayan1an commented on GitHub (Oct 31, 2013): Please test 26055
Author
Owner

@magnumripper commented on GitHub (Nov 6, 2013):

Seems fine now on the 9600GT. But the enumeration takes 45 seconds compared to 3 seconds for wpapsk-opencl.

<!-- gh-comment-id:27847416 --> @magnumripper commented on GitHub (Nov 6, 2013): Seems fine now on the 9600GT. But the enumeration takes 45 seconds compared to 3 seconds for wpapsk-opencl.
Author
Owner

@magnumripper commented on GitHub (Jun 24, 2015):

When toying with CryptoHaze I noticed the current OSX drivers are capable of running the GT650M and the HD Graphics 4000 simultaneously. This did not work at all last time I tried (probably with Maverick). So I tried this with mscash-opencl:

$ ../run/john -test -form:mscash2-opencl -dev=1
Device 1: HD Graphics 4000
Optimal Work Group Size:32
Kernel Execution Speed (Higher is better):0.040092
Optimal Global Work Size:8192
Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE
Raw:    2600 c/s real, 819200 c/s virtual

$ ../run/john -test -form:mscash2-opencl -dev=2
Device 2: GeForce GT 650M
Optimal Work Group Size:128
Kernel Execution Speed (Higher is better):0.076275
Optimal Global Work Size:16384
Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE
Raw:    4979 c/s real, 4979 c/s virtual

$ ../run/john -test -form:mscash2-opencl -dev=1,2
Device 1: HD Graphics 4000
Optimal Work Group Size:32
Kernel Execution Speed (Higher is better):0.040088
Optimal Global Work Size:8192
Device 2: GeForce GT 650M
Optimal Work Group Size:1024
Kernel Execution Speed (Higher is better):0.078537
Optimal Global Work Size:24576
Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE
Raw:    6922 c/s real, 6922 c/s virtual

Works just fine 👍

This is not very interesting for actual cracking on these toy devices, but it's excellent for development!

<!-- gh-comment-id:115017417 --> @magnumripper commented on GitHub (Jun 24, 2015): When toying with CryptoHaze I noticed the current OSX drivers are capable of running the GT650M and the HD Graphics 4000 simultaneously. This did not work at all last time I tried (probably with Maverick). So I tried this with mscash-opencl: ``` $ ../run/john -test -form:mscash2-opencl -dev=1 Device 1: HD Graphics 4000 Optimal Work Group Size:32 Kernel Execution Speed (Higher is better):0.040092 Optimal Global Work Size:8192 Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE Raw: 2600 c/s real, 819200 c/s virtual $ ../run/john -test -form:mscash2-opencl -dev=2 Device 2: GeForce GT 650M Optimal Work Group Size:128 Kernel Execution Speed (Higher is better):0.076275 Optimal Global Work Size:16384 Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE Raw: 4979 c/s real, 4979 c/s virtual $ ../run/john -test -form:mscash2-opencl -dev=1,2 Device 1: HD Graphics 4000 Optimal Work Group Size:32 Kernel Execution Speed (Higher is better):0.040088 Optimal Global Work Size:8192 Device 2: GeForce GT 650M Optimal Work Group Size:1024 Kernel Execution Speed (Higher is better):0.078537 Optimal Global Work Size:24576 Benchmarking: mscash2-opencl, MS Cache Hash 2 (DCC2) [PBKDF2-SHA1 OpenCL]... DONE Raw: 6922 c/s real, 6922 c/s virtual ``` Works just fine :+1: This is not very interesting for actual cracking on these toy devices, but it's **excellent** for development!
Author
Owner

@magnumripper commented on GitHub (Jun 24, 2015):

Works like a champ using --fork too, for other formats.

<!-- gh-comment-id:115018756 --> @magnumripper commented on GitHub (Jun 24, 2015): Works like a champ using --fork too, for other formats.
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#139
No description provided.