summaryrefslogtreecommitdiff
path: root/BFS/support/params.h
blob: f4f12e7fb2cd703889ce67f80f2768e6b36eb4c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#ifndef _PARAMS_H_
#define _PARAMS_H_

#include "common.h"
#include "utils.h"

static void usage() {
    PRINT(  "\nUsage:  ./program [options]"
            "\n"
            "\nBenchmark-specific options:"
            "\n    -f <F>    input matrix file name (default=data/roadNet-CA.txt)"
            "\n"
            "\nGeneral options:"
            "\n    -v <V>    verbosity"
            "\n    -h        help"
            "\n\n");
}

typedef struct Params {
  const char* fileName;
  unsigned int verbosity;
} Params;

static struct Params input_params(int argc, char **argv) {
    struct Params p;
    p.fileName      = "data/roadNet-CA.txt";
    p.verbosity     = 0;
    int opt;
    while((opt = getopt(argc, argv, "f:v:h")) >= 0) {
        switch(opt) {
            case 'f': p.fileName    = optarg;       break;
            case 'v': p.verbosity   = atoi(optarg); break;
            case 'h': usage(); exit(0);
            default:
                      PRINT_ERROR("Unrecognized option!");
                      usage();
                      exit(0);
        }
    }

    return p;
}

#endif