int main() { SCHEDULER_REQUEST sreq; SCHEDULER_REPLY sreply; g_request = &sreq; g_reply = &sreply; g_wreq = &sreply.wreq; PLAN_CLASS_SPECS pcs; int retval = pcs.parse_file("plan_class_spec.xml.sample"); if (retval) { printf("parse_file: %d\n"); exit(1); } config.debug_version_select = true; HOST_USAGE hu; strcpy(sreq.host.p_features, "sse3"); sreq.host.p_fpops =5e9; g_wreq->effective_ncpus = 4; if (1) { sreq.coprocs.nvidia.fake(18000, 512*MEGA, 490*MEGA, 1); sreq.coprocs.nvidia.opencl_prop.opencl_device_version_int = 0; } else { sreq.coprocs.nvidia.count = 0; } if (1) { sreq.coprocs.ati.fake(512*MEGA, 256*MEGA, 1); sreq.coprocs.ati.have_cal = true; sreq.coprocs.ati.opencl_prop.opencl_device_version_int = 0; } else { sreq.coprocs.ati.count = 0; } for (unsigned int i=0; i<pcs.classes.size(); i++) { bool b = pcs.check(sreq, pcs.classes[i].name, hu); if (b) { printf("%s: check succeeded\n", pcs.classes[i].name); printf("\tncudas: %f\n\tnatis: %f\n\tgpu_ram: %fMB\n\tavg_ncpus: %f\n\tprojected_flops: %fG\n\tpeak_flops: %fG\n", hu.ncudas, hu.natis, hu.gpu_ram/1e6, hu.avg_ncpus, hu.projected_flops/1e9, hu.peak_flops/1e9 ); } else { printf("%s: check failed\n", pcs.classes[i].name); } } }
// app planning function. // See http://boinc.berkeley.edu/trac/wiki/AppPlan // bool app_plan(SCHEDULER_REQUEST& sreq, char* plan_class, HOST_USAGE& hu) { char buf[256]; static bool check_plan_class_spec = true; static bool have_plan_class_spec = false; static bool bad_plan_class_spec = false; if (config.debug_version_select) { log_messages.printf(MSG_NORMAL, "[version] Checking plan class '%s'\n", plan_class ); } if (check_plan_class_spec) { check_plan_class_spec = false; safe_strcpy(buf, config.project_dir); safe_strcat(buf, "/plan_class_spec.xml"); int retval = plan_class_specs.parse_file(buf); if (retval == ERR_FOPEN) { have_plan_class_spec = false; } else if (retval) { log_messages.printf(MSG_CRITICAL, "Error parsing plan class spec file '%s'\n", buf ); bad_plan_class_spec = true; } else { if (config.debug_version_select) { log_messages.printf(MSG_NORMAL, "[version] reading plan classes from file '%s'\n", buf ); } have_plan_class_spec = true; } } if (bad_plan_class_spec) { return false; } if (have_plan_class_spec) { return plan_class_specs.check(sreq, plan_class, hu); } if (!strcmp(plan_class, "mt")) { return app_plan_mt(sreq, hu); } else if (strstr(plan_class, "opencl") == plan_class) { return app_plan_opencl(sreq, plan_class, hu); } else if (strstr(plan_class, "ati") == plan_class) { return app_plan_ati(sreq, plan_class, hu); } else if (strstr(plan_class, "cuda")) { return app_plan_nvidia(sreq, plan_class, hu); } else if (!strcmp(plan_class, "nci")) { return app_plan_nci(sreq, hu); } else if (!strcmp(plan_class, "sse3")) { return app_plan_sse3(sreq, hu); } else if (strstr(plan_class, "vbox")) { return app_plan_vbox(sreq, plan_class, hu); } else if (strstr(plan_class, "opencl_cpu_intel")) { return app_plan_opencl_cpu_intel(sreq, hu); } log_messages.printf(MSG_CRITICAL, "Unknown plan class: %s\n", plan_class ); return false; }