Skip to content

Commit 34364ba

Browse files
authored
Merge pull request #6996 from BOINC/dpa_gpu_flops
client: show GPU flops as TFLOPS/GFLOPS/MFLOPS depending on value
2 parents b636abd + 7ce1f5e commit 34364ba

7 files changed

Lines changed: 52 additions & 13 deletions

File tree

client/gpu_opencl.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,15 +741,37 @@ void COPROCS::get_opencl(
741741
// TODO: is there a better way to estimate peak_flops?
742742
//
743743
prop.peak_flops = 0;
744-
if (prop.max_compute_units) {
745-
double freq = ((double)prop.max_clock_frequency) * MEGA;
746-
prop.peak_flops = ((double)prop.max_compute_units) * freq;
744+
745+
double freq;
746+
if (prop.max_clock_frequency == 1) {
747+
// Adreno reports 1MHz, which is not correct.
748+
// Actual rate could be 155 MHz to 1.5 GHz;
749+
// split the difference.
750+
freq = 1e9;
751+
} else {
752+
freq = ((double)prop.max_clock_frequency) * 1e6;
753+
}
754+
755+
// OpenCL doesn't tell us this critical parameter;
756+
// it varies between manufacturer and model.
757+
// For recent Intel GPUs it's 8; we'll use this as a default
758+
//
759+
int alus_per_compute_unit = 8;
760+
761+
// other manufacturers
762+
//
763+
if (strcasestr(prop.vendor, "QUALCOMM")) {
764+
// can be 32 to 256; most are 128
765+
alus_per_compute_unit = 128;
747766
}
767+
768+
prop.peak_flops = freq * prop.max_compute_units * alus_per_compute_unit;
748769
if (prop.peak_flops <= 0 || prop.peak_flops > GPU_MAX_PEAK_FLOPS) {
749770
char buf2[256];
750771
snprintf(buf2, sizeof(buf2),
751-
"OpenCL generic: bad peak FLOPS; Max units %u, max freq %u MHz",
752-
prop.max_compute_units, prop.max_clock_frequency
772+
"OpenCL generic: bad peak FLOPS; Max units %u, max freq %u MHz ALUs per CU %d",
773+
prop.max_compute_units, prop.max_clock_frequency,
774+
alus_per_compute_unit
753775
);
754776
gpu_warning(warnings, buf2);
755777
prop.peak_flops = GPU_DEFAULT_PEAK_FLOPS;

client/hostinfo_unix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ bool get_idle_time_from_daemon(long &idle_time) {
23122312
close(fd);
23132313
return false;
23142314
}
2315-
if (st.st_size < 2*sizeof(int64_t)) {
2315+
if ((size_t)st.st_size < 2*sizeof(int64_t)) {
23162316
close(fd);
23172317
return false;
23182318
}

lib/coproc.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,10 @@ void COPROC_NVIDIA::description(char* buf, int buflen) {
363363
safe_strcpy(cuda_vers, "unknown");
364364
}
365365
snprintf(buf, buflen,
366-
"%s (driver version %s, CUDA version %s, compute capability %d.%d, %.2fGB, %.2fGB available, %.0f GFLOPS peak)",
366+
"%s (driver version %s, CUDA version %s, compute capability %d.%d, %.2fGB, %.2fGB available, %s peak)",
367367
prop.name, vers, cuda_vers, prop.major, prop.minor,
368-
prop.totalGlobalMem/GIGA, available_ram/GIGA, peak_flops/1e9
368+
prop.totalGlobalMem/GIGA, available_ram/GIGA,
369+
flops_to_string(peak_flops).c_str()
369370
);
370371
}
371372

@@ -879,9 +880,9 @@ int COPROC_ATI::parse(XML_PARSER& xp) {
879880

880881
void COPROC_ATI::description(char* buf, int buflen) {
881882
snprintf(buf, buflen,
882-
"%s (CAL version %s, %.2fGB, %.2fGB available, %.0f GFLOPS peak)",
883+
"%s (CAL version %s, %.2fGB, %.2fGB available, %s peak)",
883884
name, version, attribs.localRAM/1024.,
884-
available_ram/GIGA, peak_flops/1.e9
885+
available_ram/GIGA, flops_to_string(peak_flops).c_str()
885886
);
886887
}
887888

lib/gui_rpc_client_print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void APP_VERSION::print() {
126126
printf(" coprocessor type: %s\n", proc_type_name(gpu_type));
127127
printf(" coprocessor usage: %.3f\n", gpu_usage);
128128
}
129-
printf(" estimated GFLOPS: %.2f\n", flops/1e9);
129+
printf(" estimated speed: %s\n", flops_to_string(flops).c_str());
130130
printf(" filename: %s\n", exec_filename);
131131
}
132132

lib/opencl_boinc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,11 @@ void OPENCL_DEVICE_PROP::description(char* buf, int buflen, const char* type) {
263263
n = (int)strlen(s1) - 1;
264264
if ((n > 0) && (s1[n] == ' ')) s1[n] = '\0';
265265
snprintf(s2, sizeof(s2),
266-
"%.64s (driver version %.64s, device version %.64s, %.2fGB, %.2fGB available, %.0f GFLOPS peak)",
266+
"%.64s (driver version %.64s, device version %.64s, %.2fGB, %.2fGB available, %s peak)",
267267
name, opencl_driver_version,
268268
s1, (double)global_mem_size/GIGA,
269-
opencl_available_ram/GIGA, peak_flops/1.e9
269+
opencl_available_ram/GIGA,
270+
flops_to_string(peak_flops).c_str()
270271
);
271272

272273
switch(is_used) {

lib/str_util.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,20 @@ void secs_to_hmsf(double secs, char* buf) {
192192
sprintf(buf, "%uh%02um%02us%02u", h, m, s, f);
193193
}
194194

195+
// return e.g. '12.23 GFLOPS'
196+
//
197+
string flops_to_string(double flops) {
198+
char buf[256];
199+
if (flops >= 1e12) {
200+
snprintf(buf, 256, "%0.2f TFLOPS", flops/1e12);
201+
} else if (flops >= 1e9) {
202+
snprintf(buf, 256, "%0.2f GFLOPS", flops/1e9);
203+
} else {
204+
snprintf(buf, 256, "%0.2f MFLOPS", flops/1e6);
205+
}
206+
return string(buf);
207+
}
208+
195209
// Convert nbytes into a string. If total_bytes is non-zero,
196210
// convert the two into a fractional display (i.e. 4/16 KB)
197211
//

lib/str_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
extern void strcpy_overlap(char*, const char*);
2929
extern int ndays_to_string(double x, int smallest_timescale, char *buf);
3030
extern void nbytes_to_string(double nbytes, double total_bytes, char* str, int len);
31+
extern std::string flops_to_string(double flops);
3132
extern int parse_command_line(char*, char**);
3233
extern void strip_whitespace(char *str);
3334
extern void strip_whitespace(std::string&);

0 commit comments

Comments
 (0)