| 1 | = API for multi-thread apps = |
| 2 | |
| 3 | The following is a design document, not implemented yet. |
| 4 | |
| 5 | == Assumptions == |
| 6 | |
| 7 | A 'multi-thread app' A uses multiple threads, say Nthreads(A). |
| 8 | The average number of processors used, Ncpus(A), may be less |
| 9 | (because of I/O or synchronization). |
| 10 | |
| 11 | Ideally, on a host with N CPUs, we want |
| 12 | Ncpus(A), summed over running apps, to be about N. |
| 13 | If it's less, we're not using CPU time. |
| 14 | If it's more: |
| 15 | * we increase latency without increasing throughput |
| 16 | * we use more RAM than needed |
| 17 | * higher synchronization overhead |
| 18 | |
| 19 | We assume that applications may be able to change Nthreads(A) dynamically |
| 20 | in response to hints from BOINC. |
| 21 | Nthreads(A) need not be equal to the hint. |
| 22 | |
| 23 | Example: suppose |
| 24 | * we have an 80-core CPU |
| 25 | * app A can use 1,2,4,8,16,32 threads |
| 26 | * app B can use 1,2,4,8,16,32,64 threads |
| 27 | |
| 28 | Then we want to have either (16,64) or (32,32) threads most of the time. |
| 29 | |
| 30 | == Proposal == |
| 31 | |
| 32 | {{{ |
| 33 | int boinc_target_nthreads(); |
| 34 | void boinc_actual_nthreads(int); |
| 35 | }}} |
| 36 | |
| 37 | An application calls boinc_target_nthreads() periodically, |
| 38 | at points where it is able to change its number of threads. |
| 39 | It calls boinc_actual_nthreads() to report its actual number of threads. |
| 40 | |
| 41 | Shared-memory messages: |
| 42 | * core->app (process control channel): <target_nthreads> |
| 43 | * app->core (process control channel): <actual_nthreads> |
| 44 | |
| 45 | Client maintains estimates of CPU effiency per job, |
| 46 | uses this to scale target_nthreads. |
| 47 | |
| 48 | A WU can specify "max average nthreads"; this is used |
| 49 | by the client and scheduler to estimate completion time. |
| 50 | |
| 51 | Implementation (enforce_schedule()): |
| 52 | as we schedule jobs, decrement CPU count by scaled actual_nthreads. |
| 53 | rr_simulation() needs to be modified too. |