Version 16 (modified by 16 years ago) (diff) | ,
---|
Applications that use coprocessors
This document describes BOINC's support for applications that use coprocessors such as
- GPUs
- Cell SPEs
We'll assume that these resources are allocated rather than scheduled: i.e., an application using a coprocessor has it locked while the app is in memory, even if the app is suspended by BOINC or descheduled by the OS.
The BOINC client probes for coprocessors and reports them in scheduler requests.
Deploying a coprocessor app
BOINC uses the application planning mechanism to coordinate the scheduling of multi-threaded applications.
Suppose you've developed a coprocessor program, that it uses a CUDA GPU and 1 GFLOPS of the CPU, and produces a total of 100 GFLOPS. To deploy it:
- Choose a "planning class" name for the program, say "cuda" (see below).
- Create an app version. Include a file app_plan containing "cuda".
- Link the following function into your scheduler:
bool app_plan(SCHEDULER_REQUEST& sreq, char* plan_class, HOST_USAGE& hu) { if (!strcmp(plan_class, "mt")) { // the following is for an app that can use anywhere // from 1 to 64 threads, can control this exactly, // and whose speedup is .95N // (so on a uniprocessor, we'll use a sequential app // if one is available) // int ncpus, nthreads; bool bounded; get_ncpus(sreq, ncpus, bounded); nthreads = ncpus; if (nthreads > 64) nthreads = 64; hu.avg_ncpus = nthreads; hu.max_ncpus = nthreads; sprintf(hu.cmdline, "--nthreads %d", nthreads); hu.flops = 0.95*sreq.host.p_fpops*nthreads; return true; } else if (!strcmp(plan_class, "cuda")) { // the following is for an app that uses a CUDA GPU // and some CPU also, and gets 50 GFLOPS total // for (unsigned int i=0; i<sreq.coprocs.coprocs.size(); i++) { COPROC* cp = sreq.coprocs.coprocs[i]; if (!strcmp(cp->type, "CUDA")) { COPROC* cu = new COPROC (cp->type); cu->count = 1; hu.coprocs.coprocs.push_back(cu); double x = 1e9/sreq.host.p_fpops; if (x > 1) x = 1; hu.avg_ncpus = x; hu.max_ncpus = x; hu.flops = 5e11; return true; } } if (config.debug_version_select) { log_messages.printf(MSG_DEBUG, "Host lacks CUDA coprocessor for plan class %s\n", plan_class ); } return false; } log_messages.printf(MSG_CRITICAL, "Unknown plan class: %s\n", plan_class ); return false; }
Questions
- How does BOINC know if non-BOINC applications are using resources?
Possible future additions
- Allow app_versions to specify min and max requirements (and have a corresponding allocation scheme in the client).
- Let projects define their own resources, unknown to BOINC, and have "probe" programs (using the assigned-job mechanism) that surveys the resources on each host.
- Store the resource descriptions in the DB (or maybe flat files), so that you can study your host population.