-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
98 lines (90 loc) · 3.38 KB
/
main.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "Benchmark.h"
using namespace std;
using namespace cv;
int main(int argc, char **argv) {
if (argc < 3) {
cout << "Usage: ./benchmark [Image Folder][Iteration Count][-f16][numCore]" << endl;
return 0;
}
bool use_fp16 = false;
string dir = argv[1];
dir.append("/");
dir+="*";
int count = atoi(argv[2]);
int numCore;
if (argc >=5) {
use_fp16 = true;
} else if (argc >= 4) {
string option = argv[3];
if (option == "-f16") {
use_fp16 = true;
}
else {
numCore = std::stoi(option);
}
}
Benchmark bEngine(dir, use_fp16, count, numCore);
bEngine.run();
// unsigned int totalByte = 0;
// float totalReadTime = 0;
// for (int i = 0; i < count; i++) {
// unsigned int byteRead = 0;
// t0 = clockCounter();
// byteRead+=benchmark.readFile(i);
// t1 = clockCounter();
// float readTime = (float)(t1-t0)*1000.0f/(float)freq;
// if (show) {
// printf("Iteration %d\n", i+1);
// printf("--------------------------------\n");
// printAverage(0, readTime, benchmark.getFileSize(), byteRead);
// }
// totalReadTime+=readTime;
// totalByte+=byteRead;
// }
// printAverage(0, totalReadTime/count, benchmark.getFileSize(), totalByte/count);
// cout << "The total number of threads: "<< num_of_cores << endl << endl;
// // decode & convert to tensor
// while (!benchmark.isEmptyQueue()) {
// benchmark.decodeFile();
// }
// for (int cores = 1; cores<= num_of_cores; cores*=2) {
// //vector<thread> dec_threads(cores);
// // float avgdecode = 0;
// while(!mFileQueue.isEmpty()) {
// cout << mFileQueue.getSize() << endl;
// tuple<char*, int> image = mFileQueue.dequeue();
// char * bytestream = get<0>(image);
// int size = get<1>(image);
// //benchmark.decodeFile(bytestream, size);
// }
// }
// float decodetook = 0;
// float decodebyte = 0;
// for (int i=0; i<split.size(); i++) {
// int size = split[i].size() / cores;
// size = size < 1 ? 1 : size;
// vector<vector<pair<char*, int>>> temp = splitVector(split[i], size);
// // if the batch size is smaller than the total number of threads, use only that are needed
// int minSize = min ((int)temp.size(), cores);
// t0 = clockCounter();
// for (int j=0; j<minSize; j++) {
// //decode
// dec_threads[j] = thread(bind(&decodeFile, temp[j], use_fp16));
// }
// for (int i=0; i<minSize; i++) {
// dec_threads[i].join();
// }
// t1 = clockCounter();
// float decodetime = (float)(t1-t0)*1000.0f/(float)freq;
// decodetook+=decodetime;
// }
// avgdecode+=decodetook;
// //printf("Decoding %d files took %.3f msec\n", (int)buffers.size(), decodetook);
// }
// avgdecode /= count;
// printf("Decode with %d core(s)\n", cores);
// printAverage(1, avgdecode, (int)buffers.size(), totalbyte);
// }
cout << endl << "Done" << endl;
return 0;
}