Skip to content

Commit 97acf35

Browse files
committed
OpenCL: Drop old race-condition debug stuff
1 parent ea98aae commit 97acf35

File tree

1 file changed

+5
-84
lines changed

1 file changed

+5
-84
lines changed

src/opencl_common.c

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
#include "john_mpi.h"
5757
#include "timer.h"
5858

59-
/* Set this to eg. 3 for some added debug and retry stuff */
60-
#define RACE_CONDITION_DEBUG 0
61-
6259
#define LOG_SIZE 1024*16
6360

6461
/* Only output OpenCL build log if there was a fatal error
@@ -341,11 +338,6 @@ static char *opencl_driver_info(int sequential_id)
341338
if (recommendation && strstr(recommendation, "N"))
342339
if (conf_major <= major && conf_minor <= minor)
343340
break;
344-
345-
#ifdef OCL_DEBUG
346-
fprintf(stderr, "Driver: %i, %i -> %s , %s\n",
347-
conf_major, conf_minor, name, recommendation);
348-
#endif
349341
} while ((line = line->next));
350342

351343
if (gpu_amd(device_info[sequential_id]) &&
@@ -456,19 +448,6 @@ static void load_opencl_environment()
456448

457449
// Point to the end of the list
458450
device_pos += num_devices;
459-
460-
#ifdef OCL_DEBUG
461-
{
462-
char opencl_data[LOG_SIZE];
463-
464-
SOFT_CLERROR(clGetPlatformInfo(platform_list[i],
465-
CL_PLATFORM_NAME, sizeof(opencl_data), opencl_data, NULL),
466-
"clGetPlatformInfo for CL_PLATFORM_NAME");
467-
468-
fprintf(stderr, "%u: OpenCL platform %d: %s, %d device(s).\n",
469-
NODE, i, opencl_data, num_devices);
470-
}
471-
#endif
472451
}
473452

474453
// Set NULL to the final buffer position.
@@ -535,7 +514,6 @@ static int start_opencl_device(int sequential_id, int *err_type)
535514
{
536515
cl_context_properties properties[3];
537516
char opencl_data[LOG_SIZE];
538-
int retry = 0;
539517

540518
// Get the detailed information about the device
541519
// (populate device_info[d] bitfield).
@@ -585,38 +563,25 @@ static int start_opencl_device(int sequential_id, int *err_type)
585563

586564
if (ret_code != CL_SUCCESS) {
587565
fprintf(stderr, "%u: Error creating context for device %d "
588-
"(%d:%d): %s, %s\n",
566+
"(%d:%d): %s\n",
589567
NODE, sequential_id + 1,
590568
get_platform_id(sequential_id),
591-
get_device_id(sequential_id), get_error_name(ret_code),
592-
retry < RACE_CONDITION_DEBUG ? "retrying" : "giving up");
593-
if (++retry > RACE_CONDITION_DEBUG)
594-
error();
595-
usleep((retry + NODE) * 100);
569+
get_device_id(sequential_id), get_error_name(ret_code));
596570
}
597571
} while (ret_code != CL_SUCCESS);
598572

599-
retry = 0;
600573
do {
601574
queue[sequential_id] = clCreateCommandQueue(context[sequential_id],
602575
devices[sequential_id], 0, &ret_code);
603576

604577
if (ret_code != CL_SUCCESS) {
605578
fprintf(stderr, "%u: Error creating command queue for "
606-
"device %d (%d:%d): %s, %s\n", NODE,
579+
"device %d (%d:%d): %s\n", NODE,
607580
sequential_id + 1, get_platform_id(sequential_id),
608-
get_device_id(sequential_id), get_error_name(ret_code),
609-
retry < RACE_CONDITION_DEBUG ? "retrying" : "giving up");
610-
if (++retry > RACE_CONDITION_DEBUG)
611-
error();
612-
usleep((retry + NODE) * 100);
581+
get_device_id(sequential_id), get_error_name(ret_code));
613582
}
614583
} while (ret_code != CL_SUCCESS);
615584

616-
#ifdef OCL_DEBUG
617-
fprintf(stderr, " Device %d: %s\n", sequential_id + 1, opencl_data);
618-
#endif
619-
620585
// Success.
621586
return 1;
622587
}
@@ -1242,20 +1207,10 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
12421207
int kludge_file = 0;
12431208

12441209
if (mpi_p > 1) {
1245-
#if RACE_CONDITION_DEBUG
1246-
if (options.verbosity == VERB_DEBUG)
1247-
fprintf(stderr, "Node %d %s kludge locking %s...\n",
1248-
NODE, __FUNCTION__, kernel_source_file);
1249-
#endif
12501210
if ((kludge_file = open(kernel_source_file, O_RDWR | O_APPEND)) < 0)
12511211
pexit("Error opening %s", kernel_source_file);
12521212
else
12531213
jtr_lock(kludge_file, F_SETLKW, F_WRLCK, kernel_source_file);
1254-
1255-
#if RACE_CONDITION_DEBUG
1256-
if (options.verbosity == VERB_DEBUG)
1257-
fprintf(stderr, "Node %d got a kludge lock\n", NODE);
1258-
#endif
12591214
}
12601215
#endif /* HAVE_MPI */
12611216

@@ -1375,32 +1330,16 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
13751330
if (file == NULL)
13761331
perror("Error creating binary cache file");
13771332
else {
1378-
#if RACE_CONDITION_DEBUG
1379-
if (options.verbosity == VERB_DEBUG)
1380-
fprintf(stderr, "Node %d %s locking %s...\n", NODE, __FUNCTION__, file_name);
1381-
#endif
13821333
jtr_lock(fileno(file), F_SETLKW, F_WRLCK, file_name);
13831334

1384-
#if RACE_CONDITION_DEBUG
1385-
if (options.verbosity == VERB_DEBUG)
1386-
fprintf(stderr, "Node %d got a lock on %s\n", NODE, file_name);
1387-
#endif
13881335
if (fwrite(source, source_size, 1, file) != 1)
13891336
perror("Error caching kernel binary");
1390-
#if RACE_CONDITION_DEBUG
1391-
if (options.verbosity == VERB_DEBUG)
1392-
fprintf(stderr, "Node %d closing %s\n", NODE, file_name);
1393-
#endif
13941337
fclose(file);
13951338
}
13961339
MEM_FREE(source);
13971340
}
13981341

13991342
#if HAVE_MPI
1400-
#if RACE_CONDITION_DEBUG
1401-
if (mpi_p > 1 && options.verbosity == VERB_DEBUG)
1402-
fprintf(stderr, "Node %d releasing kludge lock\n", NODE);
1403-
#endif
14041343
if (mpi_p > 1)
14051344
close(kludge_file);
14061345
#endif /* HAVE_MPI */
@@ -2236,18 +2175,8 @@ size_t opencl_read_source(const char *kernel_filename, char **kernel_source)
22362175
if (!fp)
22372176
pexit("Can't read source kernel");
22382177

2239-
#if RACE_CONDITION_DEBUG
2240-
if (options.verbosity == VERB_DEBUG)
2241-
fprintf(stderr, "Node %d %s() locking (shared) %s...\n", NODE, __FUNCTION__, kernel_filename);
2242-
#endif
2243-
22442178
jtr_lock(fileno(fp), F_SETLKW, F_RDLCK, kernel_filename);
22452179

2246-
#if RACE_CONDITION_DEBUG
2247-
if (options.verbosity == VERB_DEBUG)
2248-
fprintf(stderr, "Node %d got a shared lock on %s\n", NODE, kernel_filename);
2249-
#endif
2250-
22512180
fseek(fp, 0, SEEK_END);
22522181
source_size = ftell(fp);
22532182
fseek(fp, 0, SEEK_SET);
@@ -2259,10 +2188,6 @@ size_t opencl_read_source(const char *kernel_filename, char **kernel_source)
22592188
"Error reading source: expected "Zu", got "Zu" bytes (%s).\n",
22602189
source_size, read_size,
22612190
feof(fp) ? "EOF" : strerror(errno));
2262-
#if RACE_CONDITION_DEBUG
2263-
if (options.verbosity == VERB_DEBUG)
2264-
fprintf(stderr, "Node %d closing %s\n", NODE, kernel_filename);
2265-
#endif
22662191
fclose(fp);
22672192
return source_size;
22682193
}
@@ -2401,10 +2326,6 @@ void opencl_build_kernel(const char *kernel_filename, int sequential_id, const c
24012326

24022327
#if HAVE_MPI
24032328
if (mpi_p > 1 && !once++) {
2404-
#if RACE_CONDITION_DEBUG || MPI_DEBUG
2405-
if (options.verbosity == VERB_DEBUG)
2406-
fprintf(stderr, "Node %d reached %s() MPI build barrier\n", NODE, __FUNCTION__);
2407-
#endif
24082329
MPI_Barrier(MPI_COMM_WORLD);
24092330
if (mpi_id == 0 && options.verbosity >= VERB_DEFAULT)
24102331
fprintf(stderr, "All nodes done OpenCL build\n");
@@ -2433,7 +2354,7 @@ int opencl_prepare_dev(int sequential_id)
24332354
#if HAVE_MPI
24342355
if (mpi_p > 1 && !once++) {
24352356
// Avoid silly race conditions seen with nvidia
2436-
#if RACE_CONDITION_DEBUG || MPI_DEBUG
2357+
#if MPI_DEBUG
24372358
if (options.verbosity == VERB_DEBUG)
24382359
fprintf(stderr, "Node %d reached MPI prep barrier\n", NODE);
24392360
#endif

0 commit comments

Comments
 (0)