Skip to content

Commit 5e02c6b

Browse files
committed
DEScrypt-opencl: Drop support for parallel kernel build
It was disabled by default but always lead to problems when I experimented with it. Closes #1618
1 parent 82ec652 commit 5e02c6b

File tree

4 files changed

+8
-36
lines changed

4 files changed

+8
-36
lines changed

run/opencl/opencl_DES_hst_dev_shared.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define OVERRIDE_AUTO_CONFIG 0
1919
#define HARDCODE_SALT 0
2020
#define FULL_UNROLL 0
21-
#define PARALLEL_BUILD 0
2221

2322
#define WORD int
2423
#define DES_bs_vector WORD

src/opencl_DES_bs_f_plug.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include <string.h>
1111
#include <sys/time.h>
1212

13-
#if _OPENMP
14-
#include <omp.h>
15-
#endif
16-
1713
#include "options.h"
1814
#include "opencl_DES_bs.h"
1915
#include "../run/opencl/opencl_DES_hst_dev_shared.h"
@@ -701,18 +697,11 @@ static void reset(struct db_main *db)
701697
if (num_salts > 10 && !ocl_any_test_running && john_main_process)
702698
fprintf(stderr, "Building %d per-salt kernels, one dot per three salts done: ", num_salts);
703699

704-
#if _OPENMP && PARALLEL_BUILD
705-
#pragma omp parallel for
706-
#endif
707700
for (i = 0; i < num_salts; i++) {
708701
init_kernel(salt_list[i], gpu_id, 1, 0, forced_global_keys ? 0 :local_work_size);
709702

710-
#if _OPENMP && PARALLEL_BUILD
711-
if (omp_get_thread_num() == 0)
712-
#endif
713-
{
714-
opencl_process_event();
715-
}
703+
opencl_process_event();
704+
716705
if (num_salts > 10 && (i % 3) == 2 && !ocl_any_test_running && john_main_process)
717706
fprintf(stderr, ".");
718707
}

src/opencl_DES_bs_h_plug.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include <string.h>
1111
#include <sys/time.h>
1212

13-
#if _OPENMP
14-
#include <omp.h>
15-
#endif
16-
1713
#include "options.h"
1814
#include "opencl_DES_bs.h"
1915
#include "../run/opencl/opencl_DES_hst_dev_shared.h"
@@ -253,12 +249,7 @@ static void init_kernel(WORD salt_val, int id_gpu, int save_binary, int force_bu
253249

254250
kernels[id_gpu][salt_val] = clCreateKernel(program, "DES_bs_25", &err_code);
255251
HANDLE_CLERROR(err_code, "Create Kernel DES_bs_25 failed.\n");
256-
#if _OPENMP
257-
#pragma omp critical
258-
#endif
259-
{
260252
HANDLE_CLERROR(clSetKernelArg(kernels[id_gpu][salt_val], 0, sizeof(cl_mem), &buffer_map), "Failed setting kernel argument buffer_map, kernel DES_bs_25.\n");
261-
}
262253
marked_salts[salt_val] = salt_val;
263254

264255
HANDLE_CLERROR(clReleaseProgram(program), "Error releasing Program");
@@ -715,18 +706,11 @@ static void reset(struct db_main *db)
715706
if (num_salts > 10 && !ocl_any_test_running && john_main_process)
716707
fprintf(stderr, "Building %d per-salt kernels, one dot per three salts done: ", num_salts);
717708

718-
#if _OPENMP && PARALLEL_BUILD
719-
#pragma omp parallel for
720-
#endif
721709
for (i = 0; i < num_salts; i++) {
722710
init_kernel(salt_list[i], gpu_id, 1, 0, forced_global_keys ? 0 :local_work_size);
723711

724-
#if _OPENMP && PARALLEL_BUILD
725-
if (omp_get_thread_num() == 0)
726-
#endif
727-
{
728-
opencl_process_event();
729-
}
712+
opencl_process_event();
713+
730714
if (num_salts > 10 && (i % 3) == 2 && !ocl_any_test_running && john_main_process)
731715
fprintf(stderr, ".");
732716
}

src/opencl_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,10 +1268,10 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
12681268
* pathnames differently than the OpenCL backend would for the includes).
12691269
*
12701270
* Saving and restoring of the current directory here is incompatible with
1271-
* concurrent kernel builds by multiple threads, like we'd do with the
1272-
* PARALLEL_BUILD setting in descrypt-opencl (currently disabled and considered
1273-
* unsupported). We'd probably need to save and restore the directory
1274-
* before/after all kernel builds, not before/after each.
1271+
* concurrent kernel builds by multiple threads, like we did for a while with
1272+
* the PARALLEL_BUILD setting in descrypt-opencl (which was first disabled and
1273+
* later removed altogether). We'd probably need to save and restore the
1274+
* directory before/after all kernel builds, not before/after each.
12751275
*
12761276
* We primarily use open()/fchdir(), falling back to getcwd()/chdir() when
12771277
* open() or/and fchdir() fails.

0 commit comments

Comments
 (0)