-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.cc
81 lines (68 loc) · 2.03 KB
/
io.cc
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include <vector>
#include <fstream>
#include <string>
#include <string.h>
#include <fstream>
#include <sstream>
#include <map>
static void load_profiled_addressess(){
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("refcount.txt", "r");
if (fp == NULL){
printf("Could not read input file. Turned on profiling\n");
return;
}
char *token;
int wordcount=0, count=0;
char *placeholders[5]; //just an estimate
//std::map<std::pair<int, unsigned long long>, int> sm_ref_holder;
int which_sm=NULL;
while ((read = getline(&line, &len, fp)) != -1) {
//line length =, read);
token = strtok(line, " \n\t");
/* While there are tokens in "string" */
while( token != NULL ) {
placeholders[count] = token;
/* Get next token: */
token = strtok( NULL, " \n\t");
count++;
}
wordcount=count;
count=0;
// if c == 3, this contains kernel, address, and count
// if c == 2, this contains SM
// if c == 1, this contains the end of the SM
if (wordcount == 3){
//continue loading data into here
printf("%d ", atoi(placeholders[0])); //kernel
printf("%llu ", atoll(placeholders[1])); //address ref
printf("%d \n", atoi(placeholders[2])); //count
/*
sm_ref_holder[std::make_pair(
atoi(placeholders[0]),
atoll(placeholders[1])
)] = atoi(placeholders[2];
*/
} else if (wordcount == 1){
//stop loading data
//find and copy over to the SM
//
} else if (wordcount == 2){
//get the SM number
which_sm = atoi(placeholders[1]); //get SM
printf("SM: %d\n", which_sm);
}
}
fclose(fp);
if (line){
free(line);
}
}
int main() {
load_profiled_addressess();
return 0;
}