worker_main.cc 679 B

123456789101112131415161718192021222324252627282930
  1. #include <string>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6. #include "worker.h"
  7. // Used to prefix output from this process
  8. std::string output_prefix;
  9. int main(int argc, char **argv)
  10. {
  11. if (argc != 4) {
  12. fprintf(stderr, "Usage: %s controller_host controller_port cuda_dev_id\n", argv[0]);
  13. return 1;
  14. }
  15. unsigned short controller_port = strtoul(argv[2], NULL, 10);
  16. // Initialize the output prefix
  17. char prefix[300];
  18. gethostname(prefix, 256);
  19. strcat(prefix, "-");
  20. strcat(prefix, argv[3]);
  21. output_prefix = std::string(prefix);
  22. return worker_main(argv[1], controller_port, strtol(argv[3], NULL, 10));
  23. }