50 | | * Choose a "planning class" name for the program, say "par64" (see below). |
51 | | * Create an [UpdateVersions app version], specifying its plan class as "par64". |
52 | | * Link the following function into your scheduler (customized as needed): |
| 50 | * Choose a "plan class" name for the program, say "mt" (see below). |
| 51 | * Create an [AppVersionNew app version], specifying its plan class as "mt". |
| 52 | * Edit the following in sched/sched_customize.cpp if needed: |
54 | | bool app_plan(SCHEDULER_REQUEST& sreq, const char* plan_class, HOST_USAGE& hu) { |
55 | | if (!strcmp(plan_class, "par64")) { |
56 | | // the following is for an app that can use anywhere |
57 | | // from 1 to 64 threads, can control this exactly, |
58 | | // and whose speedup is .95N |
59 | | // (on a uniprocessor, we'll use a sequential app if one is available) |
60 | | // |
61 | | int ncpus, nthreads; |
62 | | bool bounded; |
| 54 | // the following is for an app that can use anywhere from 1 to 64 threads |
| 55 | // |
| 56 | static inline bool app_plan_mt( |
| 57 | SCHEDULER_REQUEST& sreq, HOST_USAGE& hu |
| 58 | ) { |
| 59 | double ncpus = g_wreq->effective_ncpus; |
| 60 | // number of usable CPUs, taking user prefs into account |
| 61 | int nthreads = (int)ncpus; |
| 62 | if (nthreads > 64) nthreads = 64; |
| 63 | hu.avg_ncpus = nthreads; |
| 64 | hu.max_ncpus = nthreads; |
| 65 | sprintf(hu.cmdline, "--nthreads %d", nthreads); |
| 66 | hu.projected_flops = sreq.host.p_fpops*hu.avg_ncpus*.99; |
| 67 | // the .99 ensures that on uniprocessors a sequential app |
| 68 | // will be used in preferences to this |
| 69 | hu.peak_flops = sreq.host.p_fpops*hu.avg_ncpus; |
| 70 | return true; |
| 71 | } |
64 | | get_ncpus(sreq, ncpus, bounded); |
65 | | nthreads = ncpus; |
66 | | if (nthreads > 64) nthreads = 64; |
67 | | hu.avg_ncpus = nthreads; |
68 | | hu.max_ncpus = nthreads; |
69 | | sprintf(hu.cmdline, "--nthreads %d", nthreads); |
70 | | hu.flops = 0.95*sreq.host.p_fpops*nthreads; |
71 | | if (config.debug_version_select) { |
72 | | log_messages.printf(MSG_NORMAL, |
73 | | "[version] Multi-thread app estimate %.2f GFLOPS\n", |
74 | | hu.flops/1e9 |
75 | | ); |
76 | | } |
77 | | return true; |
78 | | } |
79 | | ... |
80 | | } |