Skip to content

Commit 39aaaf5

Browse files
authored
Merge pull request #7046 from BOINC/dpa_opencl2
client: code cleanup in GPU detection
2 parents 6ca5db8 + 5694c59 commit 39aaaf5

10 files changed

Lines changed: 246 additions & 575 deletions

File tree

client/cs_apps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void cleanup_docker(DOCKER_JOB_INFO &info, DOCKER_CONN &dc) {
407407

408408
// first containers
409409
//
410-
retval = dc.command("ps --all", out, true);
410+
retval = dc.command("ps --all", out, false);
411411
if (retval) {
412412
fprintf(stderr, "Docker command failed: ps --all\n");
413413
} else {
@@ -430,7 +430,7 @@ void cleanup_docker(DOCKER_JOB_INFO &info, DOCKER_CONN &dc) {
430430

431431
// then images
432432
//
433-
retval = dc.command("images", out, true);
433+
retval = dc.command("images", out, false);
434434
if (retval) {
435435
fprintf(stderr, "Docker command failed: images\n");
436436
} else {

client/gpu_detect.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,6 @@ void COPROCS::detect_gpus(vector<string> &warnings) {
198198
catch (...) {
199199
gpu_warning(warnings, "Caught SIGSEGV in ATI GPU detection");
200200
}
201-
try {
202-
intel_gpu.get(warnings);
203-
}
204-
catch (...) {
205-
gpu_warning(warnings, "Caught SIGSEGV in INTEL GPU detection");
206-
}
207201
try {
208202
// OpenCL detection must come last
209203
get_opencl(warnings);
@@ -230,11 +224,6 @@ void COPROCS::detect_gpus(vector<string> &warnings) {
230224
#else
231225
apple_gpu.get(warnings);
232226
#endif
233-
if (setjmp(resume)) {
234-
gpu_warning(warnings, "Caught SIGSEGV in INTEL GPU detection");
235-
} else {
236-
intel_gpu.get(warnings);
237-
}
238227
if (setjmp(resume)) {
239228
gpu_warning(warnings, "Caught SIGSEGV in OpenCL detection");
240229
} else {
@@ -264,7 +253,6 @@ void COPROCS::correlate_gpus(
264253
nvidia.correlate(use_all, ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU]);
265254
#endif
266255
ati.correlate(use_all, ignore_gpu_instance[PROC_TYPE_AMD_GPU]);
267-
intel_gpu.correlate(use_all, ignore_gpu_instance[PROC_TYPE_INTEL_GPU]);
268256
#ifdef __APPLE__
269257
apple_gpu.correlate(use_all, ignore_gpu_instance[PROC_TYPE_APPLE_GPU]);
270258
#endif
@@ -301,10 +289,11 @@ void COPROCS::correlate_gpus(
301289

302290
#ifdef __APPLE__
303291
if ((nvidia_gpus[i].cuda_version >= 6050) &&
304-
nvidia_gpus[i].prop.major < 2) {
292+
nvidia_gpus[i].cuda_prop.major < 2
293+
) {
305294
// This will be called only if CUDA recognized and reported the GPU
306295
msg_printf(NULL, MSG_USER_ALERT, "NVIDIA GPU %d: %s %s",
307-
nvidia_gpus[i].device_num, nvidia_gpus[i].prop.name,
296+
nvidia_gpus[i].device_num, nvidia_gpus[i].cuda_prop.name,
308297
_("cannot be used for CUDA or OpenCL computation with CUDA driver 6.5 or later")
309298
);
310299
}

client/gpu_nvidia.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ static int nvidia_driver_version() {
145145
// If "loose", ignore FLOPS and tolerate small memory diff
146146
//
147147
int nvidia_compare(COPROC_NVIDIA& c1, COPROC_NVIDIA& c2, bool loose) {
148-
if (c1.prop.major > c2.prop.major) return 1;
149-
if (c1.prop.major < c2.prop.major) return -1;
150-
if (c1.prop.minor > c2.prop.minor) return 1;
151-
if (c1.prop.minor < c2.prop.minor) return -1;
148+
if (c1.cuda_prop.major > c2.cuda_prop.major) return 1;
149+
if (c1.cuda_prop.major < c2.cuda_prop.major) return -1;
150+
if (c1.cuda_prop.minor > c2.cuda_prop.minor) return 1;
151+
if (c1.cuda_prop.minor < c2.cuda_prop.minor) return -1;
152152
if (c1.cuda_version > c2.cuda_version) return 1;
153153
if (c1.cuda_version < c2.cuda_version) return -1;
154154
if (loose) {
@@ -402,52 +402,52 @@ void* cudalib = NULL;
402402
gpu_warning(warnings, buf);
403403

404404
for (j=0; j<cuda_ndevs; j++) {
405-
cc.prop.clear();
405+
cc.cuda_prop.clear();
406406
CUdevice device;
407407
retval = (*p_cuDeviceGet)(&device, j);
408408
if (retval) {
409409
snprintf(buf, sizeof(buf), "cuDeviceGet(%d) returned %d", j, retval);
410410
gpu_warning(warnings, buf);
411411
goto leave;
412412
}
413-
retval = (*p_cuDeviceGetName)(cc.prop.name, 256, device);
413+
retval = (*p_cuDeviceGetName)(cc.cuda_prop.name, 256, device);
414414
if (retval) {
415415
snprintf(buf, sizeof(buf), "cuDeviceGetName(%d) returned %d", j, retval);
416416
gpu_warning(warnings, buf);
417417
goto leave;
418418
}
419-
(*p_cuDeviceComputeCapability)(&cc.prop.major, &cc.prop.minor, device);
419+
(*p_cuDeviceComputeCapability)(&cc.cuda_prop.major, &cc.cuda_prop.minor, device);
420420
if (p_cuDeviceTotalMem_v2) {
421421
(*p_cuDeviceTotalMem_v2)(&global_mem, device);
422422
} else {
423423
(*p_cuDeviceTotalMem)(&global_mem, device);
424424
}
425-
cc.prop.totalGlobalMem = (double) global_mem;
425+
cc.cuda_prop.totalGlobalMem = (double) global_mem;
426426
(*p_cuDeviceGetAttribute)(&itemp, CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK, device);
427-
cc.prop.sharedMemPerBlock = (double) itemp;
428-
(*p_cuDeviceGetAttribute)(&cc.prop.regsPerBlock, CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK, device);
429-
(*p_cuDeviceGetAttribute)(&cc.prop.warpSize, CU_DEVICE_ATTRIBUTE_WARP_SIZE, device);
427+
cc.cuda_prop.sharedMemPerBlock = (double) itemp;
428+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.regsPerBlock, CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK, device);
429+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.warpSize, CU_DEVICE_ATTRIBUTE_WARP_SIZE, device);
430430
(*p_cuDeviceGetAttribute)(&itemp, CU_DEVICE_ATTRIBUTE_MAX_PITCH, device);
431-
cc.prop.memPitch = (double) itemp;
432-
retval = (*p_cuDeviceGetAttribute)(&cc.prop.maxThreadsPerBlock, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, device);
433-
retval = (*p_cuDeviceGetAttribute)(&cc.prop.maxThreadsDim[0], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X, device);
434-
(*p_cuDeviceGetAttribute)(&cc.prop.maxThreadsDim[1], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y, device);
435-
(*p_cuDeviceGetAttribute)(&cc.prop.maxThreadsDim[2], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z, device);
436-
(*p_cuDeviceGetAttribute)(&cc.prop.maxGridSize[0], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X, device);
437-
(*p_cuDeviceGetAttribute)(&cc.prop.maxGridSize[1], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y, device);
438-
(*p_cuDeviceGetAttribute)(&cc.prop.maxGridSize[2], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z, device);
439-
(*p_cuDeviceGetAttribute)(&cc.prop.clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, device);
431+
cc.cuda_prop.memPitch = (double) itemp;
432+
retval = (*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxThreadsPerBlock, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, device);
433+
retval = (*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxThreadsDim[0], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X, device);
434+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxThreadsDim[1], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y, device);
435+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxThreadsDim[2], CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z, device);
436+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxGridSize[0], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X, device);
437+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxGridSize[1], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y, device);
438+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.maxGridSize[2], CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z, device);
439+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, device);
440440
(*p_cuDeviceGetAttribute)(&itemp, CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY, device);
441-
cc.prop.totalConstMem = (double) itemp;
441+
cc.cuda_prop.totalConstMem = (double) itemp;
442442
(*p_cuDeviceGetAttribute)(&itemp, CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT, device);
443-
cc.prop.textureAlignment = (double) itemp;
444-
(*p_cuDeviceGetAttribute)(&cc.prop.deviceOverlap, CU_DEVICE_ATTRIBUTE_GPU_OVERLAP, device);
445-
(*p_cuDeviceGetAttribute)(&cc.prop.multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device);
443+
cc.cuda_prop.textureAlignment = (double) itemp;
444+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.deviceOverlap, CU_DEVICE_ATTRIBUTE_GPU_OVERLAP, device);
445+
(*p_cuDeviceGetAttribute)(&cc.cuda_prop.multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device);
446446
(*p_cuDeviceGetAttribute)(&cc.pci_info.bus_id, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, device);
447447
(*p_cuDeviceGetAttribute)(&cc.pci_info.device_id, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, device);
448448
(*p_cuDeviceGetAttribute)(&cc.pci_info.domain_id, CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, device);
449-
if (cc.prop.major <= 0) continue; // major == 0 means emulation
450-
if (cc.prop.major > 100) continue; // e.g. 9999 is an error
449+
if (cc.cuda_prop.major <= 0) continue; // major == 0 means emulation
450+
if (cc.cuda_prop.major > 100) continue; // e.g. 9999 is an error
451451
#ifdef SIM
452452
cc.display_driver_version = 0;
453453
#elif defined(_WIN32)
@@ -498,7 +498,7 @@ void COPROC_NVIDIA::correlate(
498498
nvidia_gpus[i].is_used = COPROC_IGNORED;
499499
if (in_vector(nvidia_gpus[i].device_num, ignore_devs)) continue;
500500
#ifdef __APPLE__
501-
if ((nvidia_gpus[i].cuda_version >= 6050) && nvidia_gpus[i].prop.major < 2) {
501+
if ((nvidia_gpus[i].cuda_version >= 6050) && nvidia_gpus[i].cuda_prop.major < 2) {
502502
// Can't use GPUs with compute capability < 2 with CUDA drivers >= 6.5.x
503503
nvidia_gpus[i].is_used = COPROC_UNUSED;
504504
continue;
@@ -563,7 +563,7 @@ static void get_available_nvidia_ram(COPROC_NVIDIA &cc, vector<string>& warnings
563563
void* ctx;
564564
char buf[256];
565565

566-
cc.available_ram = cc.prop.totalGlobalMem;
566+
cc.available_ram = cc.cuda_prop.totalGlobalMem;
567567
if (!p_cuDeviceGet) {
568568
gpu_warning(warnings, "cuDeviceGet() missing from NVIDIA library");
569569
return;

0 commit comments

Comments
 (0)