Changes between Version 8 and Version 9 of AppMultiThread


Ignore:
Timestamp:
Nov 24, 2007, 3:26:21 PM (16 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AppMultiThread

    v8 v9  
    2323== Assumptions ==
    2424
     25We assume that applications have the following properties:
     26
     27 * Given a number of CPUs N, the app can select a number of threads so that it uses N CPUs as fully as possible.  This number may be less than or greater than N; it may be 1.
     28 * There may be periods during the app's execution during which its number of threads becomes less than N; e.g. there may be periods during which the app is not parallel, and the number of threads becomes 1.
     29
     30== Scheduling policy ==
     31
    2532Suppose an app A uses NT(A) threads.
     33Ideally, on a host with N CPUs, we want
     34NT(A), summed over running apps, to be at least N;
     35otherwise CPU time is wasted.
     36However, if it's much more than N,
     37we increase latency without increasing throughput,
     38we may increase synchronization overhead,
     39and we may use more RAM than needed.
    2640
    27 Ideally, on a host with N CPUs, we want
    28 NT(A), summed over running apps, to be about N.
    29 If it's less, we're not using CPU time.
    30 If it's more, then
    31  * we increase latency without increasing throughput
    32  * we use more RAM than needed
    33  * synchronization overhead is high
     41Our scheduling policy, given N CPUs, is:
    3442
    35 We assume that applications may be able to change NT(A) dynamically
    36 in response to suggestions from BOINC.
     43 * Instruct applications to use enough threads for N CPUs, and monitor how many threads NT(A) they actually use.
     44 * Given a set of runnable applications A1, A2 (ordered by priority or deadline), run applications until the number of actual threads exceeds N.
     45 * Reschedule the CPUs whenever NT(A) changes for a running app A.
    3746
    38 Example: suppose
    39  * we have an 80-core CPU
    40  * app A can use 1,2,4,8,16,32 threads
    41  * app B can use 1,2,4,8,16,32,64 threads
    4247
    43 Then we want to have either (16, 64) or (32, 32, 16) threads most of the time.
    44 
    45 == Proposal ==
     48== API ==
    4649
    4750API functions:
    4851{{{
    49 int boinc_nthreads_hint();
     52int boinc_ncpus();
    5053}}}
    51 An application calls {{{boinc_nthreads_hint()}}} periodically,
    52 at points where it is able to change its number of threads.
    53 It returns a suggested number N of threads.
    54 The application should change its number of threads to
    55 a value as large as possible but no greater than N.
     54This returns the number of available CPUs
     55(this may be less than the number of physical CPUs,
     56if the user preferences specify this).
     57An application should call {{{boinc_ncpus()}}} on startup
     58to decide how many threads to use.
     59It may optionally call it again at points where it is able to change its number of threads,
     60in case the number of available CPUs has changed
     61(e.g. as the computer becomes idle and busy).
    5662{{{
    57 void boinc_nthreads(int actual, int possible);
     63void boinc_nthreads(int actual);
    5864}}}
    59 An application calls this to report its actual number of threads,
    60 and its maximum possible number of threads.
    61 It should call this whenever either quantity changes.
     65An application calls this to report its actual number of threads.
     66It should call this whenever this quantity changes.
    6267
    6368A WU DB record can specify "max average threads",
    64 an estimate of the average  value of NT(A) on a host with arbitrarily many CPUs.
     69an estimate of the average number of threads on a host with arbitrarily many CPUs.
    6570This is used by the client and scheduler to estimate completion time.
    6671
    6772== Implementation ==
    6873
     74App init file:
     75 * <ncpus_available>
     76
    6977Shared-memory messages:
    70  * core->app (process control channel): {{{<target_nthreads>}}}
    71  * app->core (process control channel): {{{<actual_nthreads>}}}
     78 * core->app (process control channel): {{{<ncpus_available>}}}
     79 * app->core (process control channel): {{{<nthreads>}}}
    7280
    73 Client maintains estimates of CPU efficiency per job,
    74 uses this to scale {{{target_nthreads}}}.
     81State:
     82 * ACTIVE_TASK::nthreads_actual
    7583
    7684Implementation ({{{enforce_schedule()}}}):
    77 as we schedule jobs, decrement CPU count by scaled {{{actual_nthreads}}}.
     85as we schedule jobs, decrement CPU count by {{{actual_nthreads}}}.
    7886{{{rr_simulation()}}} needs to be modified too.
    7987