Skip to content

Commit 9ba1e87

Browse files
magnumrippersolardiz
authored andcommitted
OpenCL: Fix a bug in BENCH_CLERROR, it could return -1 during test
Now returns 0 (fail, don't abort) during self-test/benchmark, but only after printing the error. Also document the behavior with negative return during autotune.
1 parent 2748957 commit 9ba1e87

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/formats.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ struct fmt_methods {
384384
* computes other than the requested count (such as if it generates additional
385385
* candidate passwords on its own). The updated count is used for c/s rate
386386
* calculation. The return value is thus in the 0 to updated *count range.
387-
* As an exception, a -1 return is used on error during OpenCL auto-tune. */
387+
* A special case is that during autotune (only), it may return -1 to signal
388+
* to the autotune logic that there was an OpenCL failure, so it can silently
389+
* back down. */
388390
int (*crypt_all)(int *count, struct db_salt *salt);
389391

390392
/* These functions calculate a hash out of a ciphertext that has just been

src/opencl_common.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ void opencl_process_event(void);
254254
NODE, get_error_name(__err), __FILE__, __LINE__, message); \
255255
else if (options.verbosity > VERB_LEGACY) \
256256
fprintf(stderr, " %u: %s\n", NODE, get_error_name(__err)); \
257-
if (!(ocl_autotune_running || bench_or_test_running)) \
258-
error(); \
259-
else \
257+
if (ocl_autotune_running) \
260258
return -1; \
259+
else if (bench_or_test_running) \
260+
return 0; \
261+
else \
262+
error(); \
261263
} \
262264
} while (0)
263265

0 commit comments

Comments
 (0)