Changes between Version 8 and Version 9 of AppMultiThread
- Timestamp:
- Nov 24, 2007, 3:26:21 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AppMultiThread
v8 v9 23 23 == Assumptions == 24 24 25 We 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 25 32 Suppose an app A uses NT(A) threads. 33 Ideally, on a host with N CPUs, we want 34 NT(A), summed over running apps, to be at least N; 35 otherwise CPU time is wasted. 36 However, if it's much more than N, 37 we increase latency without increasing throughput, 38 we may increase synchronization overhead, 39 and we may use more RAM than needed. 26 40 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 41 Our scheduling policy, given N CPUs, is: 34 42 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. 37 46 38 Example: suppose39 * we have an 80-core CPU40 * app A can use 1,2,4,8,16,32 threads41 * app B can use 1,2,4,8,16,32,64 threads42 47 43 Then we want to have either (16, 64) or (32, 32, 16) threads most of the time. 44 45 == Proposal == 48 == API == 46 49 47 50 API functions: 48 51 {{{ 49 int boinc_n threads_hint();52 int boinc_ncpus(); 50 53 }}} 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. 54 This returns the number of available CPUs 55 (this may be less than the number of physical CPUs, 56 if the user preferences specify this). 57 An application should call {{{boinc_ncpus()}}} on startup 58 to decide how many threads to use. 59 It may optionally call it again at points where it is able to change its number of threads, 60 in case the number of available CPUs has changed 61 (e.g. as the computer becomes idle and busy). 56 62 {{{ 57 void boinc_nthreads(int actual , int possible);63 void boinc_nthreads(int actual); 58 64 }}} 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. 65 An application calls this to report its actual number of threads. 66 It should call this whenever this quantity changes. 62 67 63 68 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.69 an estimate of the average number of threads on a host with arbitrarily many CPUs. 65 70 This is used by the client and scheduler to estimate completion time. 66 71 67 72 == Implementation == 68 73 74 App init file: 75 * <ncpus_available> 76 69 77 Shared-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>}}} 72 80 73 Client maintains estimates of CPU efficiency per job, 74 uses this to scale {{{target_nthreads}}}. 81 State: 82 * ACTIVE_TASK::nthreads_actual 75 83 76 84 Implementation ({{{enforce_schedule()}}}): 77 as we schedule jobs, decrement CPU count by scaled{{{actual_nthreads}}}.85 as we schedule jobs, decrement CPU count by {{{actual_nthreads}}}. 78 86 {{{rr_simulation()}}} needs to be modified too. 79 87