Skip to content

Commit c27eb8d

Browse files
on my computer, cuMemGetInfo_v2() always return 201 (no context)
even though we just successfully created a context. cuMemGetInfo() doesn't get this error. So use it. Note: I'm not sure if GetInfo() works for > 4GB; my GPU is a bit less than 4GB OpenCL: for generic devices, write FLOPS info to log file
1 parent 6861268 commit c27eb8d

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

client/gpu_detect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void COPROCS::bound_counts() {
833833
}
834834

835835
void gpu_warning(vector<string> &warnings, const char* msg) {
836-
fprintf(stderr, "[%s] %s\n", time_to_str(dtime()), msg);
836+
fprintf(stderr, "[%s] %s\n", time_to_string(dtime()), msg);
837837
warnings.push_back(msg);
838838
}
839839

client/gpu_nvidia.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -584,30 +584,31 @@ static void get_available_nvidia_ram(COPROC_NVIDIA &cc, vector<string>& warnings
584584
retval = (*p_cuDeviceGet)(&device, cc.device_num);
585585
if (retval) {
586586
snprintf(buf, sizeof(buf),
587-
"[coproc] cuDeviceGet(%d) returned %d", cc.device_num, retval
587+
"cuDeviceGet(%d) returned %d", cc.device_num, retval
588588
);
589589
gpu_warning(warnings, buf);
590590
return;
591591
}
592592
retval = (*p_cuCtxCreate)(&ctx, 0, device);
593593
if (retval) {
594594
snprintf(buf, sizeof(buf),
595-
"[coproc] cuCtxCreate(%d) returned %d", cc.device_num, retval
595+
"cuCtxCreate(%d) returned %d", cc.device_num, retval
596596
);
597597
gpu_warning(warnings, buf);
598598
return;
599599
}
600-
if (p_cuMemGetInfo_v2) {
600+
// cuMemGetInfo_v2() always returns 201 (no context)
601+
if (false && p_cuMemGetInfo_v2) {
601602
retval = (*p_cuMemGetInfo_v2)(&memfree, &memtotal);
602-
}
603-
else {
603+
} else {
604604
retval = (*p_cuMemGetInfo)(&memfree, &memtotal);
605605
}
606+
snprintf(buf, sizeof(buf),
607+
"cuMemGetInfo() returned %d; dev %d free %zu total %zu",
608+
retval, cc.device_num, memfree, memtotal
609+
);
610+
gpu_warning(warnings, buf);
606611
if (retval) {
607-
snprintf(buf, sizeof(buf),
608-
"[coproc] cuMemGetInfo(%d) returned %d", cc.device_num, retval
609-
);
610-
gpu_warning(warnings, buf);
611612
(*p_cuCtxDestroy)(ctx);
612613
return;
613614
}

client/gpu_opencl.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,13 +745,15 @@ void COPROCS::get_opencl(
745745
double freq = ((double)prop.max_clock_frequency) * MEGA;
746746
prop.peak_flops = ((double)prop.max_compute_units) * freq;
747747
}
748+
char buf2[256];
749+
snprintf(buf2, sizeof(buf2),
750+
"OpenCL generic: peak FLOPS %f; Max units %u, max freq %u MHz",
751+
prop.peak_flops,
752+
prop.max_compute_units, prop.max_clock_frequency
753+
);
754+
gpu_warning(warnings, buf2);
748755
if (prop.peak_flops <= 0 || prop.peak_flops > GPU_MAX_PEAK_FLOPS) {
749-
char buf2[256];
750-
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
753-
);
754-
gpu_warning(warnings, buf2);
756+
gpu_warning(warnings, "bad peak flops value; using default");
755757
prop.peak_flops = GPU_DEFAULT_PEAK_FLOPS;
756758
}
757759

0 commit comments

Comments
 (0)