Changes between Version 7 and Version 8 of AppMultiThread
- Timestamp:
- Nov 24, 2007, 2:10:35 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AppMultiThread
v7 v8 16 16 * If you want to reduce the turnaround time of your jobs (either because of human factors, or to reduce server occupancy). 17 17 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. 18 Writing and debugging a multi-threaded app is hard. 19 You may be able to use languages like Titanium or Cilk, 20 or libraries of 21 numerical "kernels" that are multi-threaded. 21 22 22 23 == Assumptions == 23 24 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). 25 Suppose an app A uses NT(A) threads. 27 26 28 27 Ideally, on a host with N CPUs, we want 29 N cpus(A), summed over running apps, to be about N.28 NT(A), summed over running apps, to be about N. 30 29 If it's less, we're not using CPU time. 31 If it's more :30 If it's more, then 32 31 * we increase latency without increasing throughput 33 32 * we use more RAM than needed 34 * higher synchronization overhead33 * synchronization overhead is high 35 34 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. 35 We assume that applications may be able to change NT(A) dynamically 36 in response to suggestions from BOINC. 39 37 40 38 Example: suppose … … 43 41 * app B can use 1,2,4,8,16,32,64 threads 44 42 45 Then we want to have either (16, 64) or (32,32) threads most of the time.43 Then we want to have either (16, 64) or (32, 32, 16) threads most of the time. 46 44 47 45 == Proposal == … … 49 47 API functions: 50 48 {{{ 51 int boinc_target_nthreads(); 52 void boinc_actual_nthreads(int); 49 int boinc_nthreads_hint(); 53 50 }}} 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. 56 {{{ 57 void boinc_nthreads(int actual, int possible); 58 }}} 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. 54 62 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. 63 A 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. 61 65 This is used by the client and scheduler to estimate completion time. 62 66 … … 67 71 * app->core (process control channel): {{{<actual_nthreads>}}} 68 72 69 {{{70 #!comment71 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.net77 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 81 73 Client maintains estimates of CPU efficiency per job, 82 74 uses this to scale {{{target_nthreads}}}. … … 85 77 as we schedule jobs, decrement CPU count by scaled {{{actual_nthreads}}}. 86 78 {{{rr_simulation()}}} needs to be modified too. 79 80 == Notes == 81 The average number of processors used, Ncpus(A), may be less 82 (because of I/O or synchronization).