Changes between Version 15 and Version 16 of AppMultiThread


Ignore:
Timestamp:
Mar 12, 2008, 4:25:04 PM (17 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AppMultiThread

    v15 v16  
    1919or libraries of multi-threaded numerical "kernels".
    2020
    21 == Assumptions ==
     21== Deploying a multi-threaded app version ==
    2222
    23 We assume that an app version has a parameter Nthreads,
    24 the maximum number of threads it uses.
    25 The scheduler sends a host the app version for which Nthreads <= NCPUS and is greatest.
     23BOINC uses the [AppPlan application planning] mechanism to
     24coordinate the scheduling of multi-threaded applications.
    2625
    27 == Scheduling policy ==
     26Suppose you've developed a multi-threaded program,
     27and that it achieves a linear speedup on up to 16 processors, and no additional speedup beyond that.
     28To deploy it:
     29
     30 * Choose a "planning class" name for the program, say "par16" (see below).
     31 * Create an [UpdateVersions app version].  Include a file '''app_plan''' containing "par16".
     32 * Link the following function into your scheduler:
     33{{{
     34bool app_plan(HOST& host, char* plan_class, HOST_USAGE& hu) {
     35    if (!strcmp(plan_class, "par16")) {
     36        if (host.ncpus < 16) {
     37            hu.ncpus = host.ncpus;
     38            hu.flops = host.p_fpops*host.p_ncpus;
     39        } else {
     40            hu.ncpus = 16;
     41            hu.flops = host.p_fpops*16;
     42        }
     43        return true;
     44    }
     45    return false;
     46}
     47}}}
     48
     49== Client scheduling policy ==
    2850
    2951Suppose an app A uses NT(A) threads.
     
    4062 * Given a set of runnable applications A1, A2 (ordered by priority or deadline), run applications until the number of actual threads exceeds N.
    4163
    42 == API ==
     64== Notes ==
    4365
    44 API functions:
    45 {{{
    46 int boinc_ncpus_available();
    47 }}}
    48 This returns the number of available CPUs
    49 (this may be less than the number of physical CPUs,
    50 if the user preferences specify this).
    51 An application should call {{{boinc_ncpus_available()}}} on startup
    52 to decide how many threads to use.
    53 It may optionally call it again at points where it is able to change its number of threads,
    54 in case the number of available CPUs has changed
    55 (e.g. as the computer becomes idle and busy).
    56 {{{
    57 void boinc_nthreads(int actual);
    58 }}}
    59 An application calls this to report its actual number of threads.
    60 It should call this whenever this quantity changes.
    61 
    62 A WU DB record can specify "max average threads",
    63 an estimate of the average number of threads on a host with arbitrarily many CPUs.
    64 This is used by the client and scheduler to estimate completion time.
    65 
    66 == Implementation ==
    67 
    68 App init file:
    69  * <ncpus_available>
    70 
    71 State:
    72  * int ACTIVE_TASK::nthreads
    73 
    74 Implementation ({{{enforce_schedule()}}}):
    75 as we schedule jobs, decrement CPU count by {{{atp->nthreads}}}.
    76 {{{rr_simulation()}}} needs to be modified too.
    77 
    78 == Notes ==
    7966 * The average number of CPUs used by an app may be less than its number of thread (because of I/O or synchronization).  Ideally the client should the number of CPUs, not the number of threads.
    80  * Applications can use more threads than available processors.  Thus, user preferences that limit the number of available processors may not be respected.