wiki:AppCoprocessor

Applications that use coprocessors

BOINC supports applications that use coprocessors such as GPUs. The BOINC client maintains a list of the coprocessors on the host. It detects NVIDIA, AMD, and Intel GPUs, as well as OpenCL coprocessors. Volunteers can specify other coprocessor types in the cc_config.xml configuration file .

The client reports coprocessors in scheduler requests; the scheduler tries to send jobs that use available coprocessors. The client keeps track of coprocessor allocation, i.e. which instances of each are free. When it runs a GPU app, it assigns it to a free instance.

You can develop your application using any programming system, e.g. CUDA (for NVIDIA), CAL (for ATI) or OpenCL.

Dealing with GPU memory allocation failures

GPUs don't have virtual memory. GPU memory allocations may fail because other applications are using the GPU. This is typically a temporary condition. Rather than exiting with an error in this case, call

boinc_temporary_exit(60);

This exits the application and tells the BOINC client to restart it again in at least 60 seconds, at which point memory may be available.

Device selection

Some hosts have multiple GPUs. The BOINC client tells your application which instance to use. Call boinc_get_init_data() to get an APP_INIT_DATA structure; the device number (0, 1, ...) is in the gpu_device_num field. Old (pre-7.0.12) clients pass the device number via a command-line argument, --device N. In this case API_INIT_DATA::gpu_device_num will be -1, and your application must check its command-line args. So to be compatible with all clients, your app should do something like

int device_num;
APP_INIT_DATA aid;
boinc_get_init_data(aid);
if (aid.gpu_device_num >= 0) {
   device_num = aid.gpu_device_num;
} else {
   device_num = (scan argc/argv for --device argument);
}

OpenCL apps don't need this; instead, use the boinc_get_opencl_ids() API as described here.

Do GPU kernels within critical sections

The BOINC client may kill your application during execution. If a GPU kernel is in progress at this point, a system crash or hang may occur. To prevent this, do GPU kernels within a critical section, e.g.

boinc_begin_critical_section();
... do GPU kernel
boinc_end_critical_section();

Plan classes

All GPU applications must use a plan class to specify their properties. You may be able use one of the predefined plan classes; otherwise you must define your own plan class, using either XML or C++.

Plan class names for GPU apps must obey these rules:

  • For OpenCL apps, the name must contain "opencl"
  • For CUDA apps, the name must contain "cuda"
  • For CAL apps, the name must contain "ati".
Last modified 3 years ago Last modified on 07/30/14 14:35:58