00001
00023 #ifndef LONESTAR_COMMANDLINE_H
00024 #define LONESTAR_COMMANDLINE_H
00025
00026 #include "Galois/Runtime/Support.h"
00027 #include <sstream>
00028 #include <unistd.h>
00029 #include <stdio.h>
00030
00031 static bool skipVerify = false;
00032 static long numThreads = 1;
00033
00036 std::vector<const char*> parse_command_line(int argc, const char** argv, const char* proghelp) {
00037 std::vector<const char*> retval;
00038
00039
00040
00041
00042
00043
00044 std::ostringstream out;
00045 for (int i = 0; i < argc; ++i) {
00046 out << argv[i];
00047 if (i != argc - 1)
00048 out << " ";
00049 }
00050 GaloisRuntime::reportInfo("CommandLine", out.str().c_str());
00051 char name[256];
00052 gethostname(name, 256);
00053 GaloisRuntime::reportInfo("Hostname", name);
00054
00055 for (int i = 1; i < argc; ++i) {
00056 if (std::string("-t").compare(argv[i]) == 0) {
00057 if (i + 1 >= argc) {
00058 fputs("Error parsing -t option, missing number\n", stderr);
00059 abort();
00060 }
00061 char* endptr = 0;
00062 numThreads = strtol(argv[i+1], &endptr, 10);
00063 if (endptr == argv[i+1]) {
00064 fputs("Error parsing -t option, number not recognized\n", stderr);
00065 abort();
00066 }
00067 numThreads = Galois::setMaxThreads(numThreads);
00068 ++i;
00069 } else if (std::string("-noverify").compare(argv[i]) == 0) {
00070 skipVerify = true;
00071 } else if (std::string("-help").compare(argv[i]) == 0) {
00072 fprintf(stderr, "%s%s%s\n",
00073 "[-t numThreads] use numThreads threads (1)\n",
00074 "[-noverify] skip verification\n",
00075 proghelp);
00076 exit(0);
00077 } else {
00078 retval.push_back(argv[i]);
00079 }
00080 }
00081 return retval;
00082 }
00083 #endif