@@ -423,7 +423,7 @@ static void load_opencl_environment()
423423 num_platforms = 0 ;
424424
425425 if (num_platforms < 1 && options .verbosity > VERB_LEGACY )
426- fprintf ( stderr , "%u: No OpenCL platforms were found: %s\n" ,
426+ fprintf_color ( color_warning , stderr , "%u: OpenCL: No platforms were found: %s\n" ,
427427 NODE , get_error_name (ret ));
428428
429429 for (i = 0 ; i < num_platforms ; i ++ ) {
@@ -439,7 +439,7 @@ static void load_opencl_environment()
439439
440440 if (num_devices < 1 && options .verbosity > VERB_LEGACY )
441441 fprintf (stderr ,
442- "%u: No OpenCL devices were found on platform #%d: %s\n" ,
442+ "%u: OpenCL: No devices were found on platform #%d: %s\n" ,
443443 NODE , i , get_error_name (ret ));
444444
445445 // Save platform and devices information
@@ -562,7 +562,7 @@ static int start_opencl_device(int sequential_id, int *err_type)
562562 & devices [sequential_id ], NULL , NULL , & ret_code );
563563
564564 if (ret_code != CL_SUCCESS ) {
565- fprintf ( stderr , "%u: Error creating context for device %d "
565+ fprintf_color ( color_warning , stderr , "%u: Error creating OpenCL context for device %d "
566566 "(%d:%d): %s\n" ,
567567 NODE , sequential_id + 1 ,
568568 get_platform_id (sequential_id ),
@@ -575,7 +575,7 @@ static int start_opencl_device(int sequential_id, int *err_type)
575575 devices [sequential_id ], 0 , & ret_code );
576576
577577 if (ret_code != CL_SUCCESS ) {
578- fprintf ( stderr , "%u: Error creating command queue for "
578+ fprintf_color ( color_warning , stderr , "%u: Error creating OpenCL command queue for "
579579 "device %d (%d:%d): %s\n" , NODE ,
580580 sequential_id + 1 , get_platform_id (sequential_id ),
581581 get_device_id (sequential_id ), get_error_name (ret_code ));
@@ -599,12 +599,12 @@ static void add_device_to_list(int sequential_id)
599599 if (found < 0 ) {
600600#if HAVE_MPI
601601 if (mpi_p > 1 )
602- fprintf ( stderr , "%u@%s: " , mpi_id + 1 , mpi_name );
602+ fprintf_color ( color_warning , stderr , "%u@%s: " , mpi_id + 1 , mpi_name );
603603#elif OS_FORK
604604 if (options .fork )
605- fprintf ( stderr , "%u: " , options .node_min );
605+ fprintf_color ( color_warning , stderr , "%u: " , options .node_min );
606606#endif
607- fprintf ( stderr , "Error: --device must be between 1 and %d "
607+ fprintf_color ( color_error , stderr , "Error: --device must be between 1 and %d "
608608 "(the number of devices available).\n" ,
609609 get_number_of_available_devices ());
610610 error ();
@@ -615,12 +615,12 @@ static void add_device_to_list(int sequential_id)
615615 if (! start_opencl_device (sequential_id , & i )) {
616616#if HAVE_MPI
617617 if (mpi_p > 1 )
618- fprintf ( stderr , "%u@%s: " , mpi_id + 1 , mpi_name );
618+ fprintf_color ( color_warning , stderr , "%u@%s: " , mpi_id + 1 , mpi_name );
619619#elif OS_FORK
620620 if (options .fork )
621- fprintf ( stderr , "%u: " , options .node_min );
621+ fprintf_color ( color_warning , stderr , "%u: " , options .node_min );
622622#endif
623- fprintf ( stderr , "Device id %d not working correctly,"
623+ fprintf_color ( color_warning , stderr , "OpenCL device id %d not working correctly,"
624624 " skipping.\n" , sequential_id + 1 );
625625 return ;
626626 }
@@ -736,12 +736,12 @@ static void build_device_list(const char *device_list[MAX_GPU_DEVICES])
736736 trial_list [i ] != CL_DEVICE_TYPE_DEFAULT );
737737 }
738738 else if (!isdigit (ARCH_INDEX (device_list [n ][0 ]))) {
739- fprintf ( stderr , "Error: --device must be numerical, "
739+ fprintf_color ( color_error , stderr , "Error: --device must be numerical, "
740740 "or one of \"all\", \"cpu\", \"gpu\" and\n"
741741 "\"acc[elerator]\".\n" );
742742 error ();
743743 } else if (device_list [n ][0 ] == '0' ) {
744- fprintf ( stderr , "Error: --device must be between 1 and %d "
744+ fprintf_color ( color_error , stderr , "Error: --device must be between 1 and %d "
745745 "(the number of devices available).\n" ,
746746 get_number_of_available_devices ());
747747 error ();
@@ -813,7 +813,7 @@ void opencl_load_environment(void)
813813
814814 // Ensure that there is at least one OpenCL device available
815815 if (get_number_of_available_devices () == 0 ) {
816- fprintf ( stderr , "No OpenCL devices found\n" );
816+ fprintf_color ( color_error , stderr , "No OpenCL devices found\n" );
817817 if (benchmark_running ) {
818818 opencl_initialized = 1 ;
819819 opencl_unavailable = 1 ;
@@ -859,7 +859,7 @@ void opencl_load_environment(void)
859859
860860 // No working OpenCL device was found
861861 if (get_number_of_devices_in_use () == 0 ) {
862- fprintf ( stderr , "No OpenCL devices found\n" );
862+ fprintf_color ( color_error , stderr , "No OpenCL devices found\n" );
863863 error ();
864864 }
865865#if OS_FORK
@@ -961,7 +961,7 @@ unsigned int opencl_get_vector_width(int sequential_id, int size)
961961 "clGetDeviceInfo for long vector width" );
962962 break ;
963963 default :
964- fprintf ( stderr , "%s() called with unknown type\n" , __FUNCTION__ );
964+ fprintf_color ( color_error , stderr , "%s() called with unknown type\n" , __FUNCTION__ );
965965 error ();
966966 }
967967 ocl_v_width = v_width ;
@@ -1123,7 +1123,7 @@ static void print_device_info(int sequential_id)
11231123 "" , "" ,
11241124#endif
11251125 device_name , board_name );
1126- log_event ("Device %d: %s%s" , sequential_id + 1 , device_name , board_name );
1126+ log_event ("OpenCL: Device %d: %s%s" , sequential_id + 1 , device_name , board_name );
11271127}
11281128
11291129static char * get_build_opts (int sequential_id , const char * opts )
@@ -1240,7 +1240,7 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
12401240 if (!getcwd (old_cwd , sizeof (old_cwd ))) {
12411241 old_cwd [0 ] = 0 ;
12421242 if (old_cwd_fd < 0 )
1243- fprintf ( stderr , "Warning: Cannot save current directory: %s\n" , strerror (errno ));
1243+ fprintf_color ( color_warning , stderr , "Warning: Cannot save current directory: %s\n" , strerror (errno ));
12441244 }
12451245 if (chdir (john_home ))
12461246 pexit ("chdir: %s" , john_home );
@@ -1249,7 +1249,7 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
12491249 build_code = clBuildProgram (* program , 0 , NULL , build_opts , NULL , NULL );
12501250 if ((old_cwd_fd >= 0 || old_cwd [0 ]) && /* We'll only have errno when we attempt a *chdir() here */
12511251 (old_cwd_fd < 0 || fchdir (old_cwd_fd )) && (!old_cwd [0 ] || chdir (old_cwd )))
1252- fprintf ( stderr , "Warning: Cannot restore current directory: %s\n" , strerror (errno ));
1252+ fprintf_color ( color_warning , stderr , "Warning: Cannot restore current directory: %s\n" , strerror (errno ));
12531253 if (old_cwd_fd >= 0 )
12541254 close (old_cwd_fd );
12551255
@@ -1267,7 +1267,7 @@ void opencl_build(int sequential_id, const char *opts, int save, const char *fil
12671267 "clGetProgramBuildInfo II" );
12681268
12691269 uint64_t end = john_get_nano ();
1270- log_event ("- build time: %ss" , ns2string (end - start ));
1270+ log_event ("OpenCL: Kernel build time: %ss" , ns2string (end - start ));
12711271
12721272 char * cleaned_log = build_log ;
12731273 if (cfg_get_bool (SECTION_OPTIONS , SUBSECTION_OPENCL , "MuteBogusWarnings" , 1 ) &&
@@ -1380,9 +1380,9 @@ cl_int opencl_build_from_binary(int sequential_id, cl_program *program, const ch
13801380 }
13811381 // Nvidia may return a single '\n' that we ignore
13821382 else if (options .verbosity >= LOG_VERB && strlen (build_log ) > 1 )
1383- fprintf (stderr , "Binary Build log: %s\n" , build_log );
1383+ fprintf (stderr , "Binary build log: %s\n" , build_log );
13841384
1385- log_event ("- build time: %ss" , ns2string (end - start ));
1385+ log_event ("OpenCL: Kernel build time: %ss" , ns2string (end - start ));
13861386 if (options .verbosity >= VERB_MAX )
13871387 fprintf (stderr , "Build time: %ss\n" , ns2string (end - start ));
13881388 MEM_FREE (build_log );
@@ -2185,7 +2185,7 @@ size_t opencl_read_source(const char *kernel_filename, char **kernel_source)
21852185 read_size = fread (* kernel_source , sizeof (char ), source_size , fp );
21862186 if (read_size != source_size )
21872187 fprintf (stderr ,
2188- "Error reading source: expected " Zu ", got " Zu " bytes (%s).\n" ,
2188+ "OpenCL error reading kernel source: expected " Zu ", got " Zu " bytes (%s).\n" ,
21892189 source_size , read_size ,
21902190 feof (fp ) ? "EOF" : strerror (errno ));
21912191 fclose (fp );
@@ -2285,38 +2285,38 @@ void opencl_build_kernel(const char *kernel_filename, int sequential_id, const c
22852285 */
22862286 if (gpu_nvidia (device_info [sequential_id ]) && !platform_apple (get_platform_id (sequential_id ))) {
22872287 if (john_main_process || !cfg_get_bool (SECTION_OPTIONS , SUBSECTION_MPI , "MPIAllGPUsSame" , 0 ))
2288- log_event ( "- Kernel binary caching disabled for this platform/device" );
2288+ LOG_ONCE ( "OpenCL: Kernel binary caching disabled for this platform/device" );
22892289 use_cache = 0 ;
22902290 } else
22912291#endif
22922292 if (getenv ("DUMP_BINARY" )) {
2293- log_event ( "- DUMP_BINARY is set, ignoring cached kernel" );
2293+ LOG_ONCE ( "OpenCL: DUMP_BINARY is set, ignoring cached kernel" );
22942294 use_cache = 0 ;
22952295 } else {
22962296 use_cache = !stat (path_expand (bin_name ), & bin_stat );
22972297
22982298 if (use_cache && !stat (path_expand (kernel_filename ), & source_stat ) &&
22992299 source_stat .st_mtime > bin_stat .st_mtime ) {
23002300 use_cache = 0 ;
2301- log_event ("- cached kernel may be stale, ignoring" );
2301+ log_event ("OpenCL: Cached kernel may be stale, ignoring" );
23022302 }
23032303 }
23042304
23052305 // Select the kernel to run.
23062306 if (use_cache ) {
23072307 size_t program_size = opencl_read_source (bin_name , & kernel_source );
23082308
2309- log_event ("- Building kernel from cached binary" );
2309+ log_event ("OpenCL: Building kernel from cached binary" );
23102310 ret_code = opencl_build_from_binary (sequential_id , & program [sequential_id ], kernel_source , program_size );
23112311 if (ret_code != CL_SUCCESS )
2312- log_event ("- Build from cached binary failed" );
2312+ log_event ("OpenCL: Build from cached binary failed" );
23132313 }
23142314
23152315 if (!use_cache || ret_code != CL_SUCCESS ) {
2316- log_event ("- Building kernel from source and caching binary" );
2316+ log_event ("OpenCL: Building kernel from source and caching binary" );
23172317 if (warn && options .verbosity > VERB_DEFAULT ) {
23182318 fflush (stdout );
2319- fprintf (stderr , "Building the kernel, this could take a while\n" );
2319+ fprintf (stderr , "Building the OpenCL kernel, this could take a while\n" );
23202320 }
23212321 opencl_read_source (kernel_filename , & kernel_source );
23222322 opencl_build (sequential_id , opts , 1 , bin_name , & program [sequential_id ], kernel_filename , kernel_source );
@@ -2374,14 +2374,9 @@ int opencl_prepare_dev(int sequential_id)
23742374 if (gpu_nvidia (device_info [sequential_id ])) {
23752375 opencl_avoid_busy_wait [sequential_id ] = cfg_get_bool (SECTION_OPTIONS , SUBSECTION_GPU ,
23762376 "AvoidBusyWait" , 1 );
2377- static int warned ;
2378-
23792377 /* Remove next line once (nearly) all formats has got the macros */
23802378 if (!opencl_avoid_busy_wait [sequential_id ])
2381- if (!warned ) {
2382- warned = 1 ;
2383- log_event ("- Busy-wait reduction %sabled" , opencl_avoid_busy_wait [sequential_id ] ? "en" : "dis" );
2384- }
2379+ LOG_ONCE ("OpenCL: Busy-wait reduction %sabled" , opencl_avoid_busy_wait [sequential_id ] ? "en" : "dis" );
23852380 }
23862381#endif
23872382
@@ -2900,11 +2895,10 @@ void opencl_list_devices(void)
29002895 ret = clGetPlatformIDs (MAX_PLATFORMS , platform_list , & num_platforms );
29012896
29022897 if (!num_platforms )
2903- fprintf (stderr , "Error: No OpenCL-capable platforms were detected"
2904- " by the installed OpenCL driver.\n" );
2898+ fprintf_color (color_error , stderr , "Error: No platforms were detected by the installed OpenCL driver.\n" );
29052899
29062900 if (ret != CL_SUCCESS && options .verbosity > VERB_LEGACY )
2907- fprintf ( stderr , "Throw clError: clGetPlatformIDs() = %s\n" ,
2901+ fprintf_color ( color_warning , stderr , "Throw clError: clGetPlatformIDs() = %s\n" ,
29082902 get_error_name (ret ));
29092903
29102904 for (i = 0 ; i < num_platforms ; i ++ ) {
@@ -2915,7 +2909,7 @@ void opencl_list_devices(void)
29152909
29162910 if ((ret != CL_SUCCESS || num_devices < 1 ) &&
29172911 options .verbosity > VERB_LEGACY )
2918- fprintf ( stderr , "No OpenCL devices was found on platform #%d"
2912+ fprintf_color ( color_warning , stderr , "No OpenCL devices was found on platform #%d"
29192913 ", clGetDeviceIDs() = %s\n" ,
29202914 i , get_error_name (ret ));
29212915
@@ -2940,8 +2934,7 @@ void opencl_list_devices(void)
29402934 printf (" Platform extensions: %s\n" , dname );
29412935 }
29422936 }
2943- fprintf (stderr , "Error: No OpenCL-capable devices were detected"
2944- " by the installed OpenCL driver.\n\n" );
2937+ fprintf_color (color_error , stderr , "Error: No devices were detected by the installed OpenCL driver.\n\n" );
29452938 return ;
29462939 }
29472940 /* Initialize OpenCL environment */
0 commit comments