| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include <NTL/ZZ.h>
- #include <iostream>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include "desired_resources.h"
- #include "controller.h"
- NTL_CLIENT
- // The total number of workers
- static unsigned short total_workers = 1;
- // The total number of nodes (that is, dpnodes)
- static unsigned short total_nodes = 1;
- // The amount of memory we can use per dpnode
- static unsigned short GB_mem_per_node = 1;
- // Input: order
- // Output: desired_dpnodes, max_workers, dpfreq
- void custom_desired_resources(const ZZ &order,
- unsigned short &desired_dpnodes, unsigned int &max_workers,
- unsigned int &dpfreq)
- {
- unsigned short custom_total_workers = total_workers;
- unsigned short custom_total_nodes = total_nodes;
- #ifdef MAKE_VERSIONS_COMPARABLE
- custom_total_nodes = 1;
- // override the total number of nodes so that only
- // one dpnode is used for each subproblem and the
- // results are comparable to the dlrho version
- #endif
- #if defined(SAVE_DPS) || defined(MAKE_VERSIONS_COMPARABLE)
- custom_total_workers = 1;
- // (1) can't use multiple workers when saving dps since
- // we want the order of dps to be deterministic
- // (2) the dlrho version uses 1 worker per subproblem
- #endif
- unsigned short freq_reduction_threshold = 4;
- // this should be okay in most cases and shouldn't cause
- // any negative effects if it's too low
- return desired_resources(order, custom_total_workers,
- custom_total_nodes, GB_mem_per_node,
- freq_reduction_threshold,
- desired_dpnodes, max_workers, dpfreq);
- }
- static void boundcb(const char *boundaddr, unsigned short boundport)
- {
- cout << "Listening on " << boundaddr << ":" << boundport << "\n";
- const char *fdenv = getenv("CONTROLLER_BOUNDCB_FD");
- if (fdenv) {
- int fd = atoi(fdenv);
- if (fd > 2) {
- write(fd, &boundport, 2);
- write(fd, boundaddr, strlen(boundaddr));
- close(fd);
- }
- }
- }
- int main(int argc, char **argv)
- {
- #ifdef SAVE_DPS
- std::cerr << "Note: Saving the distinguished points. Do not run huge problems or else it will use up all of your disk space.\n";
- #ifndef DERANDOMIZE
- std::cerr << "Saving DPs without derandomization!\n";
- #endif
- #endif
- unsigned short bindport = 0;
- Worklist worklist;
- if (controller_parse_args(argc, argv, bindport, worklist, total_workers,
- total_nodes, GB_mem_per_node)) {
- std::cerr << "Usage: " << argv[0] << " [-p listenport] [-w num_workers] [-n num_dpnodes] [-m GB_mem_per_node] [-r reps] N1 iter1 N2 iter2 ...\n";
- return 1;
- }
- return controller_main(worklist, bindport, boundcb);
- }
|