[GH-ISSUE #899] DEScrypt-opencl "goto" tweaks #503

Closed
opened 2026-10-14 03:10:33 +07:00 by bsakaguchi · 37 comments
Owner

Originally created by @magnumripper on GitHub (Dec 17, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/899

Originally assigned to: @sayan1an on GitHub.

I am temporarily dropping DEScrypt-opencl from its "hidden" state, disabled in john.conf (it works but is excluded from format enumeration and eg --test) so we do not miss it while testing things.

If we can't get recent AMD drivers to accept the goto spaghetti, we have to disable it again for the J1 release. It would be very nice not to.

I'm assaigning this to @Sayantan2048 but I will do some testing/experiments on my own too.

Originally created by @magnumripper on GitHub (Dec 17, 2014). Original GitHub issue: https://github.com/openwall/john/issues/899 Originally assigned to: @sayan1an on GitHub. I am temporarily dropping DEScrypt-opencl from its "hidden" state, disabled in john.conf (it works but is excluded from format enumeration and eg --test) so we do not miss it while testing things. If we can't get recent AMD drivers to accept the goto spaghetti, we have to disable it again for the J1 release. It would be very nice not to. I'm assaigning this to @Sayantan2048 but I will do some testing/experiments on my own too.
bsakaguchi 2026-10-14 03:10:33 +07:00
Author
Owner

@sayan1an commented on GitHub (Dec 17, 2014):

The goto s are used to avoid some extra instructions for performance improvement. Since the latest drivers can't digest goto, I'll write a separate compile time path for such devices. On the other hand, my 7970 seems to work fine with 14.9 driver. So, it would be nice if we can isolate devices that can't handle goto; a compile time macro would be helpful.

I'll post a patch by this weekend.

<!-- gh-comment-id:67315386 --> @sayan1an commented on GitHub (Dec 17, 2014): The goto s are used to avoid some extra instructions for performance improvement. Since the latest drivers can't digest goto, I'll write a separate compile time path for such devices. On the other hand, my 7970 seems to work fine with 14.9 driver. So, it would be nice if we can isolate devices that can't handle goto; a compile time macro would be helpful. I'll post a patch by this weekend.
Author
Owner

@magnumripper commented on GitHub (Dec 17, 2014):

I think any nvidia I've tried can run it as-is. I've seen problems with R9 290X on 14.6 and 14.9 iirc.

<!-- gh-comment-id:67384873 --> @magnumripper commented on GitHub (Dec 17, 2014): I think any nvidia I've tried can run it as-is. I've seen problems with R9 290X on 14.6 and 14.9 iirc.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't tried it at all yet but Atom doesn't seem to love it...

I wonder if there is some macros (documented or not) for telling the exact version of AMD driver at run-time build of kernel. That would be reallly nice.

<!-- gh-comment-id:67424740 --> @magnumripper commented on GitHub (Dec 18, 2014): Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't tried it at all yet but Atom doesn't seem to love it... I wonder if there is some macros (documented or not) for telling the exact version of AMD driver at run-time build of kernel. That would be reallly nice.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

This is slightly OT but in http://developer.amd.com/wordpress/media/2013/07/AMD_Accelerated_Parallel_Processing_OCL_Programming_Guide-2013-06-21.pdf section A.8.12, I found this:

The following macros are predefined when compiling OpenCLTM C kernels. These macros are defined automatically based on the device for which the code is being compiled.

GPU devices:
__WinterPark__
__BeaverCreek__
__Turks__
__Caicos__
__Tahiti__
__Pitcairn__
__Capeverde__
__Cayman__
__Barts__
__Cypress__
__Juniper__
__Redwood__
__Cedar__
__ATI_RV770__
__ATI_RV730__
__ATI_RV710__
__Loveland__
__GPU__

CPU devices:
__CPU__
__X86__
__X86_64__

Note that __GPU__ or __CPU__ are predefined whenever a GPU or CPU device is the compilation target.

<!-- gh-comment-id:67425395 --> @magnumripper commented on GitHub (Dec 18, 2014): This is slightly OT but in http://developer.amd.com/wordpress/media/2013/07/AMD_Accelerated_Parallel_Processing_OCL_Programming_Guide-2013-06-21.pdf section A.8.12, I found this: _The following macros are predefined when compiling OpenCLTM C kernels. These macros are defined automatically based on the device for which the code is being compiled._ ``` GPU devices: __WinterPark__ __BeaverCreek__ __Turks__ __Caicos__ __Tahiti__ __Pitcairn__ __Capeverde__ __Cayman__ __Barts__ __Cypress__ __Juniper__ __Redwood__ __Cedar__ __ATI_RV770__ __ATI_RV730__ __ATI_RV710__ __Loveland__ __GPU__ CPU devices: __CPU__ __X86__ __X86_64__ ``` _Note that `__GPU__` or `__CPU__` are predefined whenever a GPU or CPU device is the compilation target._
Author
Owner

@frank-dittrich commented on GitHub (Dec 18, 2014):

On 12/18/2014 01:48 AM, magnum wrote:

Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't
tried it at all yet but Atom doesn't seem to love it...

Just read http://techreport.com/forums/viewtopic.php?f=3&t=99272

| The Catalyst Omega special edition driver is the biggest and the best
software upgrade AMD has released this year. It’s our way of saying
‘Thank you’ for providing your feedback by using our Issue Reporting
Form all along…very helpful.

May be they like bug reports so much that they provided their user base
new opportunities for bug reports.

But may be OpenCL 2.0 with "Shared Virtual Memory" and "Dynamic
Parallelism" really help for performance.

http://support.amd.com/en-us/kb-articles/Pages/OpenCL2-Driver.aspx

Compatible Operating Systems

The AMD OpenCL 2.0 driveris designed to support the following platforms:

Microsoft Windows:
    Windows 8.1 (64-bit version)
Linux Distributions:
    Red Hat Enterprise 6.5 (64-bit version)
    Ubuntu 14.04 (64-bit version)
<!-- gh-comment-id:67426689 --> @frank-dittrich commented on GitHub (Dec 18, 2014): On 12/18/2014 01:48 AM, magnum wrote: > Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't > tried it at all yet but Atom doesn't seem to love it... Just read http://techreport.com/forums/viewtopic.php?f=3&t=99272 | The Catalyst Omega special edition driver is the biggest and the best software upgrade AMD has released this year. It’s our way of saying ‘Thank you’ for providing your feedback by using our Issue Reporting Form all along…very helpful. May be they like bug reports so much that they provided their user base new opportunities for bug reports. But may be OpenCL 2.0 with "Shared Virtual Memory" and "Dynamic Parallelism" really help for performance. http://support.amd.com/en-us/kb-articles/Pages/OpenCL2-Driver.aspx Compatible Operating Systems The AMD OpenCL 2.0 driveris designed to support the following platforms: ``` Microsoft Windows: Windows 8.1 (64-bit version) Linux Distributions: Red Hat Enterprise 6.5 (64-bit version) Ubuntu 14.04 (64-bit version) ```
Author
Owner

@sayan1an commented on GitHub (Dec 18, 2014):

Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't tried it at all yet but Atom doesn't seem to love it...

I just installed the omega driver on desktop and it doesn't seem to produce the 'goto: irreducible control flow' warning produced by previous drivers.

<!-- gh-comment-id:67438070 --> @sayan1an commented on GitHub (Dec 18, 2014): > Also, there is now a (released) Catalyst 14.12 "Omega" driver. I haven't tried it at all yet but Atom doesn't seem to love it... I just installed the omega driver on desktop and it doesn't seem to produce the 'goto: irreducible control flow' warning produced by previous drivers.
Author
Owner

@sayan1an commented on GitHub (Dec 18, 2014):

Will it be possible to give me remote access to devices which fails specifically due to goto ? Most likely goto at line number 329 is causing problem. All other goto/s should be harmless.

<!-- gh-comment-id:67472427 --> @sayan1an commented on GitHub (Dec 18, 2014): Will it be possible to give me remote access to devices which fails specifically due to goto ? Most likely goto at line number 329 is causing problem. All other goto/s should be harmless.
Author
Owner

@sayan1an commented on GitHub (Dec 18, 2014):

Will it be possible to give me remote access to devices which fails specifically due to goto ? Most likely goto at line number 329 is causing problem. All other goto/s should be harmless.

Please test the two latest commits on branch 'descrypt-test-amd' on amd devices that don't support goto.

<!-- gh-comment-id:67478153 --> @sayan1an commented on GitHub (Dec 18, 2014): > Will it be possible to give me remote access to devices which fails specifically due to goto ? Most likely goto at line number 329 is causing problem. All other goto/s should be harmless. Please test the two latest commits on branch 'descrypt-test-amd' on amd devices that don't support goto.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

I can test on 290X with 14.9 tomorrow.

<!-- gh-comment-id:67481049 --> @magnumripper commented on GitHub (Dec 18, 2014): I can test on 290X with 14.9 tomorrow.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

FWIW I see one difference on my Macbook's HD Graphics 4000 device: It failed building the kernel prior to these patches. With first patch applied (9e42ad9) it does build and works fine (no great speed but this device is very weak). But with second patch (709df4f) applied too, it again fails building.

The nvidia GT 650M can build all three versions with no warnings. Original speed (one salt) 2259K, first patch 2131K, second patch 2496K. The relative speeds are probably representative for stronger Kepler cards too.

The CPU device can build all three versions with no warnings and speed did not change (maybe it uses another kernel that was not changed?).

<!-- gh-comment-id:67482585 --> @magnumripper commented on GitHub (Dec 18, 2014): FWIW I see one difference on my Macbook's HD Graphics 4000 device: It failed building the kernel prior to these patches. With first patch applied (9e42ad9) it does build and works fine (no great speed but this device is very weak). But with second patch (709df4f) applied too, it again fails building. The nvidia GT 650M can build all three versions with no warnings. Original speed (one salt) 2259K, first patch 2131K, second patch 2496K. The relative speeds are probably representative for stronger Kepler cards too. The CPU device can build all three versions with no warnings and speed did not change (maybe it uses another kernel that was not changed?).
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

I probably can't test this patch on serious hardware until next week. @claudioandre could you try these patches on your Juniper with 14.12? Either with just first one applied, or both. BTW does 14.12 just complain about control flow, or does it bail out building?

<!-- gh-comment-id:67629019 --> @magnumripper commented on GitHub (Dec 19, 2014): I probably can't test this patch on serious hardware until next week. @claudioandre could you try these patches on your Juniper with 14.12? Either with just first one applied, or both. BTW does 14.12 just complain about control flow, or does it bail out building?
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

@Sayantan2048 perhaps you should make a patch with all three versions in there at once, and we could select them with some -DDEFINE from host code depending on driver version and/or other criteria.

Theoretically we could even try to build the fastest version, and instead of crashing when build fails we could revert to a safer code and try building again.

<!-- gh-comment-id:67629561 --> @magnumripper commented on GitHub (Dec 19, 2014): @Sayantan2048 perhaps you should make a patch with all three versions in there at once, and we could select them with some -DDEFINE from host code depending on driver version and/or other criteria. Theoretically we could even try to build the fastest version, and instead of crashing when build fails we could revert to a safer code and try building again.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

perhaps you should make a patch with all three versions in there at once,

Obviously it would suffice with just the two newer versions, not the original.

<!-- gh-comment-id:67630383 --> @magnumripper commented on GitHub (Dec 19, 2014): > perhaps you should make a patch with all three versions in there at once, Obviously it would suffice with just the two newer versions, not the original.
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

On Fri, Dec 19, 2014 at 5:32 PM, magnum notifications@github.com wrote:

Obviously it would suffice with just the two newer versions, not the
original.

Okay, will do. For now I'll be forcing 290X(ifdef Hawaii, if it is even
defined) and intel to follow patch1. Rest will follow patch2.

Regards,
Sayantan

<!-- gh-comment-id:67631165 --> @sayan1an commented on GitHub (Dec 19, 2014): On Fri, Dec 19, 2014 at 5:32 PM, magnum notifications@github.com wrote: > Obviously it would suffice with just the two newer versions, not the > original. Okay, will do. For now I'll be forcing 290X(ifdef _Hawaii_, if it is even defined) and intel to follow patch1. Rest will follow patch2. Regards, Sayantan
Author
Owner

@ghost commented on GitHub (Dec 19, 2014):

1st patch (https://raw.githubusercontent.com/magnumripper/JohnTheRipper/9e42ad9fb4dc27a724ea8b82f6159c59c9600c8c/src/opencl/DES_bs_kernel.cl)


$ ../run/john -te:5 -form=descrypt-opencl -verb=5
initUnicode(UNICODE, ASCII/ASCII)
ASCII -> ASCII -> ASCII
Device 0: Juniper (AMD Radeon HD 6700 Series)
Options used: -I ../run/kernels -cl-mad-enable -DDEVICE_INFO=522 -D_OPENCL_COMPILER 
Build log: "/tmp/OCL6613T5.cl", line 1129: warning: variable "rounds_and_swapped" was set
          but never used
        int iterations, rounds_and_swapped;
                        ^


binary size 156396
Local worksize (LWS) 64, Global worksize (GWS) 16384
Benchmarking: descrypt-opencl, traditional crypt(3) [DES OpenCL]... FAILED (get_hash[0](0))

2nd patch
(https://raw.githubusercontent.com/magnumripper/JohnTheRipper/709df4f0bd03e05932632f6faa83e0d136a4465e/src/opencl/DES_bs_kernel.cl)

$ ../run/john -te:5 -form=descrypt-opencl -verb=5
initUnicode(UNICODE, ASCII/ASCII)
ASCII -> ASCII -> ASCII
Device 0: Juniper (AMD Radeon HD 6700 Series)
Options used: -I ../run/kernels -cl-mad-enable -DDEVICE_INFO=522 -D_OPENCL_COMPILER 
Build log: "/tmp/OCL6831T5.cl", line 1160: warning: goto statement may cause irreducible
          control flow
        loop_body();
        ^

"/tmp/OCL6831T5.cl", line 1162: warning: goto statement may cause irreducible
          control flow
        if (rounds_and_swapped > 0) goto start;
                                    ^

"/tmp/OCL6831T5.cl", line 1165: warning: goto statement may cause irreducible
          control flow
        if (--iterations) goto swap;
                          ^

"/tmp/OCL6831T5.cl", line 1183: warning: goto statement may cause irreducible
          control flow
        if (--rounds_and_swapped) goto start;
                                  ^

"/tmp/OCL6831T5.cl", line 1188: warning: goto statement may cause irreducible
          control flow
        goto start;
        ^

Error:E010:Irreducible ControlFlow Detected

Error -11 building kernel $JOHN/kernels/DES_bs_kernel.cl. DEVICE_INFO=522
OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (879) - (clBuildProgram failed.)
<!-- gh-comment-id:67632267 --> @ghost commented on GitHub (Dec 19, 2014): 1st patch (https://raw.githubusercontent.com/magnumripper/JohnTheRipper/9e42ad9fb4dc27a724ea8b82f6159c59c9600c8c/src/opencl/DES_bs_kernel.cl) ``` $ ../run/john -te:5 -form=descrypt-opencl -verb=5 initUnicode(UNICODE, ASCII/ASCII) ASCII -> ASCII -> ASCII Device 0: Juniper (AMD Radeon HD 6700 Series) Options used: -I ../run/kernels -cl-mad-enable -DDEVICE_INFO=522 -D_OPENCL_COMPILER Build log: "/tmp/OCL6613T5.cl", line 1129: warning: variable "rounds_and_swapped" was set but never used int iterations, rounds_and_swapped; ^ binary size 156396 Local worksize (LWS) 64, Global worksize (GWS) 16384 Benchmarking: descrypt-opencl, traditional crypt(3) [DES OpenCL]... FAILED (get_hash[0](0)) ``` 2nd patch (https://raw.githubusercontent.com/magnumripper/JohnTheRipper/709df4f0bd03e05932632f6faa83e0d136a4465e/src/opencl/DES_bs_kernel.cl) ``` $ ../run/john -te:5 -form=descrypt-opencl -verb=5 initUnicode(UNICODE, ASCII/ASCII) ASCII -> ASCII -> ASCII Device 0: Juniper (AMD Radeon HD 6700 Series) Options used: -I ../run/kernels -cl-mad-enable -DDEVICE_INFO=522 -D_OPENCL_COMPILER Build log: "/tmp/OCL6831T5.cl", line 1160: warning: goto statement may cause irreducible control flow loop_body(); ^ "/tmp/OCL6831T5.cl", line 1162: warning: goto statement may cause irreducible control flow if (rounds_and_swapped > 0) goto start; ^ "/tmp/OCL6831T5.cl", line 1165: warning: goto statement may cause irreducible control flow if (--iterations) goto swap; ^ "/tmp/OCL6831T5.cl", line 1183: warning: goto statement may cause irreducible control flow if (--rounds_and_swapped) goto start; ^ "/tmp/OCL6831T5.cl", line 1188: warning: goto statement may cause irreducible control flow goto start; ^ Error:E010:Irreducible ControlFlow Detected Error -11 building kernel $JOHN/kernels/DES_bs_kernel.cl. DEVICE_INFO=522 OpenCL error (CL_BUILD_PROGRAM_FAILURE) in file (common-opencl.c) at line (879) - (clBuildProgram failed.) ```
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

Here is a patch for the kernel (I could create it semi automagically from the two versions)

diff --git a/src/opencl/DES_bs_kernel.cl b/src/opencl/DES_bs_kernel.cl
index 657c245..880e42e 100644
--- a/src/opencl/DES_bs_kernel.cl
+++ b/src/opencl/DES_bs_kernel.cl
@@ -58,6 +58,7 @@
 #include "opencl_DES_WGS.h"
 #include "opencl_device_info.h"

+//#define FAST_GOTO
 #define ARCH_WORD              int
 #define DES_BS_DEPTH                    32
 #define DES_bs_vector                   ARCH_WORD
@@ -308,10 +309,8 @@ inline void cmp( __private unsigned DES_bs_vector *B,
      volatile __global uint *output,
      int section) {

-
    int value[2] , mask, i, bit;

-
    for(i = 0; i < num_loaded_hash; i++) {

        value[0] = binary[i];
@@ -326,14 +325,12 @@ inline void cmp( __private unsigned DES_bs_vector *B,
            mask |= B[bit] ^ -((value[1] >> (bit & 0x1F)) & 1);
            mask |= B[bit + 1] ^ -((value[1] >> ((bit + 1) & 0x1F)) & 1);

-           if (mask == ~(int)0) goto next_hash;
+           //if (mask == ~(int)0) break;
        }

-       atomic_max( &output[i],section + 1) ;
-
-   next_hash: ;
+       if (mask != ~(int)0)
+           atomic_max(&output[i], section + 1);
    }
-
 }
 #undef GET_BIT

@@ -1130,13 +1127,17 @@ __kernel void DES_bs_25_b( constant uint *index768
 #ifndef RV7xx
        __local ushort _local_index768[768] ;
 #endif
-       int iterations, rounds_and_swapped;
+       int iterations;
+#ifdef FAST_GOTO
+       int rounds_and_swapped;
+#endif
+       long int k = 0, i;

-       long int k=0, i;
+       if (DES_bs_all[section].keys_changed) {
+           DES_bs_all[section].keys_changed = 0;
+           DES_bs_finalize_keys(section, DES_bs_all, local_offset_K, _local_K);
+       }

-       if (DES_bs_all[section].keys_changed)
-           goto finalize_keys;
-body:
        {
            vtype zero = vzero;
            DES_bs_clear_block
@@ -1147,7 +1148,9 @@ body:
                output[i] = 0;

        k=0;
+#ifdef FAST_GOTO
        rounds_and_swapped = 8;
+#endif
        iterations = 25;

 #ifndef RV7xx
@@ -1157,43 +1160,53 @@ body:

        barrier(CLK_LOCAL_MEM_FENCE);
 #endif
-
+#ifdef FAST_GOTO
 start:
        loop_body();

        if (rounds_and_swapped > 0) goto start;
        k -= (0x300 + 48);
        rounds_and_swapped = 0x108;
+
        if (--iterations) goto swap;
+#else
+   for (iterations = 24; iterations >= 0; iterations--) {
+       for (k = 0; k < 768; k += 96) {
+           H1();
+           H2();
+       }
+       for (i = 0; i < 32 && iterations; i++) {
+           tmp = B[i];
+           B[i] = B[i + 32];
+           B[i + 32] = tmp;
+       }
+   }
+
+#endif

        cmp(B, binary, num_loaded_hash, output, section);

-       tmp = 0 ;
+       tmp = 0;
        for (i = 0; i < num_loaded_hash; i++) {
-               tmp = tmp | output[i];
-           if(tmp) break ;
+           tmp = tmp | output[i];
+           if (tmp) break;
        }

-       if(tmp || (!num_loaded_hash))
+       if (tmp || (!num_loaded_hash))
+
        for (i = 0; i < 64; i++)
            B_global[global_offset_B + i] = (DES_bs_vector)B[i] ;
-
        return;
-
+#ifdef FAST_GOTO
 swap:
        H2();
        k += 96;
        if (--rounds_and_swapped) goto start;
-
 next:
        k -= (0x300 - 48);
        rounds_and_swapped = 8;
        iterations--;
        goto start;
-
-finalize_keys:
-       DES_bs_all[section].keys_changed = 0;
-           DES_bs_finalize_keys(section, DES_bs_all, local_offset_K, _local_K);
-       goto body;
+#endif
 }
 #endif
<!-- gh-comment-id:67633522 --> @magnumripper commented on GitHub (Dec 19, 2014): Here is a patch for the kernel (I could create it semi automagically from the two versions) ``` diff --git a/src/opencl/DES_bs_kernel.cl b/src/opencl/DES_bs_kernel.cl index 657c245..880e42e 100644 --- a/src/opencl/DES_bs_kernel.cl +++ b/src/opencl/DES_bs_kernel.cl @@ -58,6 +58,7 @@ #include "opencl_DES_WGS.h" #include "opencl_device_info.h" +//#define FAST_GOTO #define ARCH_WORD int #define DES_BS_DEPTH 32 #define DES_bs_vector ARCH_WORD @@ -308,10 +309,8 @@ inline void cmp( __private unsigned DES_bs_vector *B, volatile __global uint *output, int section) { - int value[2] , mask, i, bit; - for(i = 0; i < num_loaded_hash; i++) { value[0] = binary[i]; @@ -326,14 +325,12 @@ inline void cmp( __private unsigned DES_bs_vector *B, mask |= B[bit] ^ -((value[1] >> (bit & 0x1F)) & 1); mask |= B[bit + 1] ^ -((value[1] >> ((bit + 1) & 0x1F)) & 1); - if (mask == ~(int)0) goto next_hash; + //if (mask == ~(int)0) break; } - atomic_max( &output[i],section + 1) ; - - next_hash: ; + if (mask != ~(int)0) + atomic_max(&output[i], section + 1); } - } #undef GET_BIT @@ -1130,13 +1127,17 @@ __kernel void DES_bs_25_b( constant uint *index768 #ifndef RV7xx __local ushort _local_index768[768] ; #endif - int iterations, rounds_and_swapped; + int iterations; +#ifdef FAST_GOTO + int rounds_and_swapped; +#endif + long int k = 0, i; - long int k=0, i; + if (DES_bs_all[section].keys_changed) { + DES_bs_all[section].keys_changed = 0; + DES_bs_finalize_keys(section, DES_bs_all, local_offset_K, _local_K); + } - if (DES_bs_all[section].keys_changed) - goto finalize_keys; -body: { vtype zero = vzero; DES_bs_clear_block @@ -1147,7 +1148,9 @@ body: output[i] = 0; k=0; +#ifdef FAST_GOTO rounds_and_swapped = 8; +#endif iterations = 25; #ifndef RV7xx @@ -1157,43 +1160,53 @@ body: barrier(CLK_LOCAL_MEM_FENCE); #endif - +#ifdef FAST_GOTO start: loop_body(); if (rounds_and_swapped > 0) goto start; k -= (0x300 + 48); rounds_and_swapped = 0x108; + if (--iterations) goto swap; +#else + for (iterations = 24; iterations >= 0; iterations--) { + for (k = 0; k < 768; k += 96) { + H1(); + H2(); + } + for (i = 0; i < 32 && iterations; i++) { + tmp = B[i]; + B[i] = B[i + 32]; + B[i + 32] = tmp; + } + } + +#endif cmp(B, binary, num_loaded_hash, output, section); - tmp = 0 ; + tmp = 0; for (i = 0; i < num_loaded_hash; i++) { - tmp = tmp | output[i]; - if(tmp) break ; + tmp = tmp | output[i]; + if (tmp) break; } - if(tmp || (!num_loaded_hash)) + if (tmp || (!num_loaded_hash)) + for (i = 0; i < 64; i++) B_global[global_offset_B + i] = (DES_bs_vector)B[i] ; - return; - +#ifdef FAST_GOTO swap: H2(); k += 96; if (--rounds_and_swapped) goto start; - next: k -= (0x300 - 48); rounds_and_swapped = 8; iterations--; goto start; - -finalize_keys: - DES_bs_all[section].keys_changed = 0; - DES_bs_finalize_keys(section, DES_bs_all, local_offset_K, _local_K); - goto body; +#endif } #endif ```
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

(that patch is for bleeding-jumbo, it's patch1 plus optionally patch2 in one.)

<!-- gh-comment-id:67633585 --> @magnumripper commented on GitHub (Dec 19, 2014): (that patch is for bleeding-jumbo, it's patch1 plus optionally patch2 in one.)
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

So instead of

//#define FAST_GOTO

We'd just put

#if !(gpu_intel(DEVICE_INFO) || defined(__HAWAII__) || defined(__JUNIPER__))
#define FAST_GOTO
#endif
<!-- gh-comment-id:67633818 --> @magnumripper commented on GitHub (Dec 19, 2014): So instead of ``` //#define FAST_GOTO ``` We'd just put ``` #if !(gpu_intel(DEVICE_INFO) || defined(__HAWAII__) || defined(__JUNIPER__)) #define FAST_GOTO #endif ```
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

That if should be negated. Edited the above.

<!-- gh-comment-id:67633890 --> @magnumripper commented on GitHub (Dec 19, 2014): That if should be negated. Edited the above.
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

Cool. Please go ahead.

On Fri, Dec 19, 2014 at 6:16 PM, magnum notifications@github.com wrote:

That if should be negated. Edited the above.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67633890
.

<!-- gh-comment-id:67634130 --> @sayan1an commented on GitHub (Dec 19, 2014): Cool. Please go ahead. On Fri, Dec 19, 2014 at 6:16 PM, magnum notifications@github.com wrote: > That if should be negated. Edited the above. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67633890 > .
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

OK, committed to bleeding as a9006a8, in your name of course.

<!-- gh-comment-id:67634407 --> @magnumripper commented on GitHub (Dec 19, 2014): OK, committed to bleeding as a9006a8, in your name of course.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

For some (other) reason, the Juniper on Super Well fails with or without this patch :-(. The other two devices got slightly faster now.

<!-- gh-comment-id:67635251 --> @magnumripper commented on GitHub (Dec 19, 2014): For some (other) reason, the Juniper on ~~Super~~ Well fails with or without this patch :-(. The other two devices got slightly faster now.
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

I'm looking into it.

On Fri, Dec 19, 2014 at 6:32 PM, magnum notifications@github.com wrote:

For some (other) reason, the Juniper on Super fails with or without this
patch :-(. The other two devices got slightly faster now.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635251
.

<!-- gh-comment-id:67635495 --> @sayan1an commented on GitHub (Dec 19, 2014): I'm looking into it. On Fri, Dec 19, 2014 at 6:32 PM, magnum notifications@github.com wrote: > For some (other) reason, the Juniper on Super fails with or without this > patch :-(. The other two devices got slightly faster now. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635251 > .
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

I'm also logged in to super. I'll be only testing juniper though!

On Fri, Dec 19, 2014 at 6:35 PM, Sayantan Datta std2048@gmail.com wrote:

I'm looking into it.

On Fri, Dec 19, 2014 at 6:32 PM, magnum notifications@github.com wrote:

For some (other) reason, the Juniper on Super fails with or without this
patch :-(. The other two devices got slightly faster now.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635251
.

<!-- gh-comment-id:67635655 --> @sayan1an commented on GitHub (Dec 19, 2014): I'm also logged in to super. I'll be only testing juniper though! On Fri, Dec 19, 2014 at 6:35 PM, Sayantan Datta std2048@gmail.com wrote: > I'm looking into it. > > On Fri, Dec 19, 2014 at 6:32 PM, magnum notifications@github.com wrote: > > > For some (other) reason, the Juniper on Super fails with or without this > > patch :-(. The other two devices got slightly faster now. > > > > — > > Reply to this email directly or view it on GitHub > > https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635251 > > .
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

I wrote Super but I meant Well. Super only has Tahitis

<!-- gh-comment-id:67635834 --> @magnumripper commented on GitHub (Dec 19, 2014): I wrote Super but I meant Well. Super only has Tahitis
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

This patch works fine on Bull. Slightly faster on the GTX570. For some reason it did not show any speed difference on the Tahiti

<!-- gh-comment-id:67635898 --> @magnumripper commented on GitHub (Dec 19, 2014): This patch works fine on Bull. Slightly faster on the GTX570. For some reason it did not show any speed difference on the Tahiti
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

Oops! Now logged into right machine!

On Fri, Dec 19, 2014 at 6:40 PM, magnum notifications@github.com wrote:

This patch works fine on Bull. Slightly faster on the GTX570. For some
reason it did not show any speed difference on the Tahiti

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635898
.

<!-- gh-comment-id:67636110 --> @sayan1an commented on GitHub (Dec 19, 2014): Oops! Now logged into right machine! On Fri, Dec 19, 2014 at 6:40 PM, magnum notifications@github.com wrote: > This patch works fine on Bull. Slightly faster on the GTX570. For some > reason it did not show any speed difference on the Tahiti > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/899#issuecomment-67635898 > .
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

On Super though, both the Tahiti and the Titan got 2-5% faster

<!-- gh-comment-id:67636567 --> @magnumripper commented on GitHub (Dec 19, 2014): On Super though, both the Tahiti and the Titan got 2-5% faster
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

Once we fix #909 we can do a much better choice, depending on driver version and not just device. I will look into that logic.

<!-- gh-comment-id:67636786 --> @magnumripper commented on GitHub (Dec 19, 2014): Once we fix #909 we can do a much better choice, depending on driver version and not just device. I will look into that logic.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

OK #909 is fixed. Now we can use DEV_VER_MAJOR and DEV_VER_MINOR for selecting. For Catalyst 14.9 the driver version is 1573.4 so DEV_VER_MAJOR is 1573 and DEV_VER_MINOR is 4 but we can probably ignore the minor.

<!-- gh-comment-id:67640092 --> @magnumripper commented on GitHub (Dec 19, 2014): OK #909 is fixed. Now we can use DEV_VER_MAJOR and DEV_VER_MINOR for selecting. For Catalyst 14.9 the driver version is 1573.4 so DEV_VER_MAJOR is 1573 and DEV_VER_MINOR is 4 but we can probably ignore the minor.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

So we need to establish which device/version combinations do fail with "fast goto". I think Hawaii fails with 14.9 but I will double check that first. Claudio reported that it failed building with Juniper and (I think) 14.12.

<!-- gh-comment-id:67640503 --> @magnumripper commented on GitHub (Dec 19, 2014): So we need to establish which device/version combinations do fail with "fast goto". I think Hawaii fails with 14.9 but I will double check that first. Claudio reported that it failed building with Juniper and (I think) 14.12.
Author
Owner

@sayan1an commented on GitHub (Dec 19, 2014):

So we need to establish which device/version combinations do fail with "fast goto". I think Hawaii fails with 14.9 but I will double check that first. Claudio reported that it failed building with Juniper and (I think) 14.12.

I have been juggling around the code for a while but couldn't get it running on Juniper. I tried to eliminate some of the peculiarities and other potential sources of errors but nothing!! I don't think we should spend any more time on this.

<!-- gh-comment-id:67647821 --> @sayan1an commented on GitHub (Dec 19, 2014): > So we need to establish which device/version combinations do fail with "fast goto". I think Hawaii fails with 14.9 but I will double check that first. Claudio reported that it failed building with Juniper and (I think) 14.12. I have been juggling around the code for a while but couldn't get it running on Juniper. I tried to eliminate some of the peculiarities and other potential sources of errors but nothing!! I don't think we should spend any more time on this.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

How very very stupid: __HAWAII__ is not defined on 290X. At least not with 14.9. Why am I not surprised?
It's __Hawaii__, not __HAWAII__!!

GTX 980 on 343.22 works fine with either of the three versions.
"safe goto": Used 159 registers, 15876 bytes smem, 348 bytes cmem[0]
"fast goto": Used 72 registers, 15876 bytes smem, 348 bytes cmem[0]
Despite (or because of?) the more register use, the "safe goto" version is definitely faster. 7% for one salt and 16% for many salts. So 72240d7f picks the "safe" kernel for nvidia.

290X on 14.9 (1573.4) needs the "safer" kernel (67482K/28835K c/s) or crashes while building. It is very strange that your Tahiti is different, they are essentially the same except for number of cores.

<!-- gh-comment-id:67673168 --> @magnumripper commented on GitHub (Dec 19, 2014): ~~How very very stupid: `__HAWAII__` is not defined on 290X. At least not with 14.9. Why am I not surprised?~~ It's `__Hawaii__`, not `__HAWAII__`!! GTX 980 on 343.22 works fine with either of the three versions. "safe goto": Used 159 registers, 15876 bytes smem, 348 bytes cmem[0] "fast goto": Used 72 registers, 15876 bytes smem, 348 bytes cmem[0] Despite (or because of?) the more register use, the "safe goto" version is definitely faster. 7% for one salt and 16% for many salts. So 72240d7f picks the "safe" kernel for nvidia. 290X on 14.9 (1573.4) needs the "safer" kernel (67482K/28835K c/s) or crashes while building. It is very strange that your Tahiti is different, they are essentially the same except for number of cores.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

It may be that only nvidia's GM204 likes the "safe" kernel. My Kepler and Super's Titan is a bit faster using the "fast" kernel.

<!-- gh-comment-id:67674031 --> @magnumripper commented on GitHub (Dec 19, 2014): It may be that only nvidia's GM204 likes the "safe" kernel. My Kepler and Super's Titan is a bit faster using the "fast" kernel.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

How very very stupid: __HAWAII__ is not defined on 290X

It may be that I tried __HAWAII__ but not __Hawaii__, so I will have to re-check that later.

<!-- gh-comment-id:67680191 --> @magnumripper commented on GitHub (Dec 19, 2014): > How very very stupid: `__HAWAII__` is not defined on 290X It may be that I tried `__HAWAII__` but not `__Hawaii__`, so I will have to re-check that later.
Author
Owner

@magnumripper commented on GitHub (Dec 21, 2014):

707325a tweaks it a little. I had it as __TAHITI__ but it should be __Tahiti__. And only Maxwell is faster with the "safe" kernel, not Kepler or Fermi.

<!-- gh-comment-id:67755873 --> @magnumripper commented on GitHub (Dec 21, 2014): 707325a tweaks it a little. I had it as `__TAHITI__` but it should be `__Tahiti__`. And only Maxwell is faster with the "safe" kernel, not Kepler or Fermi.
Author
Owner

@magnumripper commented on GitHub (Dec 29, 2014):

How very very stupid: __HAWAII__ is not defined on 290X

It may be that I tried __HAWAII__ but not __Hawaii__, so I will have to re-check that later.

That was it. PEBCAK. All those device name macros are capitalized lowercase as in __Juniper__

<!-- gh-comment-id:68314649 --> @magnumripper commented on GitHub (Dec 29, 2014): > > How very very stupid: `__HAWAII__` is not defined on 290X > > It may be that I tried `__HAWAII__` but not `__Hawaii__`, so I will have to re-check that later. That was it. PEBCAK. All those device name macros are capitalized lowercase as in `__Juniper__`
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#503
No description provided.