Save config options for GPUs only if there are GPU devices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/main.c b/main.c
index da3145a..c8ec5c0 100644
--- a/main.c
+++ b/main.c
@@ -3099,37 +3099,39 @@ static void write_config(FILE *fcfg)
}
fputs("\n],\n\n", fcfg);
- /* Write GPU device values */
- fputs("\"intensity\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, gpus[i].dynamic ? "%sd" : "%s%d", i > 0 ? "," : "", gpus[i].intensity);
+ if (nDevs) {
+ /* Write GPU device values */
+ fputs("\"intensity\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, gpus[i].dynamic ? "%sd" : "%s%d", i > 0 ? "," : "", gpus[i].intensity);
#ifdef HAVE_ADL
- fputs("\",\n\"gpu-engine\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_engine, gpus[i].gpu_engine);
- fputs("\",\n\"gpu-fan\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_fan, gpus[i].gpu_fan);
- fputs("\",\n\"gpu-memclock\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_memclock);
- fputs("\",\n\"gpu-powertune\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_powertune);
- fputs("\",\n\"gpu-vddc\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%1.3f", i > 0 ? "," : "", gpus[i].gpu_vddc);
- fputs("\",\n\"temp-cutoff\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.cutofftemp);
- fputs("\",\n\"temp-overheat\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.overtemp);
- fputs("\",\n\"temp-target\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.targettemp);
+ fputs("\",\n\"gpu-engine\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_engine, gpus[i].gpu_engine);
+ fputs("\",\n\"gpu-fan\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_fan, gpus[i].gpu_fan);
+ fputs("\",\n\"gpu-memclock\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_memclock);
+ fputs("\",\n\"gpu-powertune\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_powertune);
+ fputs("\",\n\"gpu-vddc\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%1.3f", i > 0 ? "," : "", gpus[i].gpu_vddc);
+ fputs("\",\n\"temp-cutoff\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.cutofftemp);
+ fputs("\",\n\"temp-overheat\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.overtemp);
+ fputs("\",\n\"temp-target\" : \"", fcfg);
+ for(i = 0; i < nDevs; i++)
+ fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.targettemp);
#endif
- fputs("\",\n", fcfg);
+ fputs("\",\n", fcfg);
+ }
fprintf(fcfg, "\n\"algo\" : \"%s\"", algo_names[opt_algo]);
/* Simple bool and int options */