27 | | == Scheduling policy == |
| 26 | Suppose you've developed a multi-threaded program, |
| 27 | and that it achieves a linear speedup on up to 16 processors, and no additional speedup beyond that. |
| 28 | To deploy it: |
| 29 | |
| 30 | * Choose a "planning class" name for the program, say "par16" (see below). |
| 31 | * Create an [UpdateVersions app version]. Include a file '''app_plan''' containing "par16". |
| 32 | * Link the following function into your scheduler: |
| 33 | {{{ |
| 34 | bool app_plan(HOST& host, char* plan_class, HOST_USAGE& hu) { |
| 35 | if (!strcmp(plan_class, "par16")) { |
| 36 | if (host.ncpus < 16) { |
| 37 | hu.ncpus = host.ncpus; |
| 38 | hu.flops = host.p_fpops*host.p_ncpus; |
| 39 | } else { |
| 40 | hu.ncpus = 16; |
| 41 | hu.flops = host.p_fpops*16; |
| 42 | } |
| 43 | return true; |
| 44 | } |
| 45 | return false; |
| 46 | } |
| 47 | }}} |
| 48 | |
| 49 | == Client scheduling policy == |
44 | | API functions: |
45 | | {{{ |
46 | | int boinc_ncpus_available(); |
47 | | }}} |
48 | | This returns the number of available CPUs |
49 | | (this may be less than the number of physical CPUs, |
50 | | if the user preferences specify this). |
51 | | An application should call {{{boinc_ncpus_available()}}} on startup |
52 | | to decide how many threads to use. |
53 | | It may optionally call it again at points where it is able to change its number of threads, |
54 | | in case the number of available CPUs has changed |
55 | | (e.g. as the computer becomes idle and busy). |
56 | | {{{ |
57 | | void boinc_nthreads(int actual); |
58 | | }}} |
59 | | An application calls this to report its actual number of threads. |
60 | | It should call this whenever this quantity changes. |
61 | | |
62 | | A WU DB record can specify "max average threads", |
63 | | an estimate of the average number of threads on a host with arbitrarily many CPUs. |
64 | | This is used by the client and scheduler to estimate completion time. |
65 | | |
66 | | == Implementation == |
67 | | |
68 | | App init file: |
69 | | * <ncpus_available> |
70 | | |
71 | | State: |
72 | | * int ACTIVE_TASK::nthreads |
73 | | |
74 | | Implementation ({{{enforce_schedule()}}}): |
75 | | as we schedule jobs, decrement CPU count by {{{atp->nthreads}}}. |
76 | | {{{rr_simulation()}}} needs to be modified too. |
77 | | |
78 | | == Notes == |