Changes between Version 7 and Version 8 of AppMultiThread


Ignore:
Timestamp:
Nov 24, 2007, 2:10:35 PM (17 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AppMultiThread

    v7 v8  
    1616 * If you want to reduce the turnaround time of your jobs (either because of human factors, or to reduce server occupancy).
    1717
    18 Writing and debugging a multi-threaded app is often hard.
    19 You may be able to use existing libraries of
    20 numerical "kernels" that are already multi-threaded.
     18Writing and debugging a multi-threaded app is hard.
     19You may be able to use languages like Titanium or Cilk,
     20or libraries of
     21numerical "kernels" that are multi-threaded.
    2122
    2223== Assumptions ==
    2324
    24 A 'multi-thread app' A uses multiple threads, say Nthreads(A).
    25 The average number of processors used, Ncpus(A), may be less
    26 (because of I/O or synchronization).
     25Suppose an app A uses NT(A) threads.
    2726
    2827Ideally, on a host with N CPUs, we want
    29 Ncpus(A), summed over running apps, to be about N.
     28NT(A), summed over running apps, to be about N.
    3029If it's less, we're not using CPU time.
    31 If it's more:
     30If it's more, then
    3231 * we increase latency without increasing throughput
    3332 * we use more RAM than needed
    34  * higher synchronization overhead
     33 * synchronization overhead is high
    3534
    36 We assume that applications may be able to change Nthreads(A) dynamically
    37 in response to hints from BOINC.
    38 Nthreads(A) need not be equal to the hint.
     35We assume that applications may be able to change NT(A) dynamically
     36in response to suggestions from BOINC.
    3937
    4038Example: suppose
     
    4341 * app B can use 1,2,4,8,16,32,64 threads
    4442
    45 Then we want to have either (16,64) or (32,32) threads most of the time.
     43Then we want to have either (16, 64) or (32, 32, 16) threads most of the time.
    4644
    4745== Proposal ==
     
    4947API functions:
    5048{{{
    51 int boinc_target_nthreads();
    52 void boinc_actual_nthreads(int);
     49int boinc_nthreads_hint();
    5350}}}
     51An application calls {{{boinc_nthreads_hint()}}} periodically,
     52at points where it is able to change its number of threads.
     53It returns a suggested number N of threads.
     54The application should change its number of threads to
     55a value as large as possible but no greater than N.
     56{{{
     57void boinc_nthreads(int actual, int possible);
     58}}}
     59An application calls this to report its actual number of threads,
     60and its maximum possible number of threads.
     61It should call this whenever either quantity changes.
    5462
    55 An application calls {{{boinc_target_nthreads()}}} periodically,
    56 at points where it is able to change its number of threads.
    57 It calls {{{boinc_actual_nthreads()}}} to report its actual number of threads.
    58 
    59 A WU DB record can specify "max average ncpus",
    60 an estimate of Ncpus(A) on a host with arbitrarily many CPUs.
     63A WU DB record can specify "max average threads",
     64an estimate of the average  value of NT(A) on a host with arbitrarily many CPUs.
    6165This is used by the client and scheduler to estimate completion time.
    6266
     
    6771 * app->core (process control channel): {{{<actual_nthreads>}}}
    6872
    69 {{{
    70 #!comment
    71 
    72 *ahem*
    73 
    74 Unless, before we get to add multi-threading support, we do the sane thing and change the communication use a compact binary protocol over a pipe instead of XML over shared memory.
    75 
    76 "shared memory has to be right below 'printing and scanning with OCR' in terms of favorite means of IPC" -- rtyler on #boinc, irc.freenode.net
    77 
    78 By the way, it would be nice to stabilize the API documented here, and implement it as a stub that always tells the app to use 1 thread. That way project developers don't have to wait for BOINC support before making multi-threaded applications. They could create apps supporting multiple threads right now, and whenever the BOINC client (or an unofficial fork, since everything will be so nicely documented, right?) adds support for this, they would Just Work(tm).
    79 }}}
    80 
    8173Client maintains estimates of CPU efficiency per job,
    8274uses this to scale {{{target_nthreads}}}.
     
    8577as we schedule jobs, decrement CPU count by scaled {{{actual_nthreads}}}.
    8678{{{rr_simulation()}}} needs to be modified too.
     79
     80== Notes ==
     81The average number of processors used, Ncpus(A), may be less
     82(because of I/O or synchronization).