-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmdLine.cpp
63 lines (52 loc) · 1.34 KB
/
cmdLine.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Process command line arguments
//
// Do not change the code in this file, as doing so
// could cause your submission to be graded incorrectly
//
#include <stdlib.h> // For: exit, drand48, malloc, free, NULL, EXIT_FAILURE
#include <stdio.h> // For: perror
#include <string.h> // For: memset
#include <getopt.h>
void cmdLine(int argc, char *argv[], int& n, int& noCheck, int& identDebug, int& genDATA){
// Command line arguments
// Default value of the matrix size
static struct option long_options[] = {
{"no-check", no_argument, 0, 'c'},
{"n", required_argument, 0, 'n'},
{"i", no_argument, 0, 'i'}, // identiy matrix
{"g", no_argument, 0, 'g'}, //genDATA
};
// Set default values
n=0;
noCheck = 0;
identDebug = 0;
genDATA = 0;
// Process command line arguments
int ac;
for(ac=1; ac<argc; ac++) {
int c;
while ((c=getopt_long(argc,argv,"gcin:",long_options,NULL)) != -1){
switch (c) {
case 'c':
noCheck = 1;
break;
case 'i':
// setup identity matrix x sequential matrix
identDebug = 1;
break;
case 'n':
// Size of the matrix
n = atoi(optarg);
break;
case 'g':
genDATA = 1;
break;
// Dont' check accuracy - used for tallying cache activity
// Error
default:
printf("Usage: mmpy [-n <matrix dim>]\n");
exit(-1);
}
}
}
}