-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExp_poisson_arrival_rv_nf.cpp
More file actions
156 lines (128 loc) · 5.59 KB
/
Exp_poisson_arrival_rv_nf.cpp
File metadata and controls
156 lines (128 loc) · 5.59 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// Created by bacox on 25/05/2020.
//
#include <iostream>
#include <EdgeCaffe.h>
#include <chrono>
#include <Util/Output.h>
#include <cxxopts.h>
#include <Util/Config.h>
#include <Orchestrator/Orchestrator.h>
#include <Orchestrator/OrchestratorFactory.h>
int main(int argc, char *argv[])
{
/**
* Vary Rho, fix number of networks
*/
/**
* Start parsing input parameters
*/
EdgeCaffe::Config &c_config = EdgeCaffe::Config::getInstance();
c_config.parseCli(argc, argv);
c_config.printConfig();
std::unordered_map<std::string, int> memory_values = {
{"512M", 512}
, {"1G", 1024}
, {"2G", 2048}
, {"4G", 4096}
};
/**
* End parsing input parameters
*/
EdgeCaffe::Type::MODE_TYPE mode = c_config.modeAsType();
std::string modeAsString = c_config.mode();
std::string outputFile = "layers.csv";
{
EdgeCaffe::Output output;
std::string configOutputFile = c_config.outputPrefix.valueOrDefault() + "config.csv";
output.toCSV(c_config.outputDirectory.valueOrDefault() + "/" + configOutputFile, c_config.configAsText, EdgeCaffe::Output::CONFIG);
}
/**
* End of configuring all.
* The real running begins here
*/
// if(!verbose)
::google::InitGoogleLogging(argv[0]);
/**
* Instead of defining the networks and the input, we let it be generated by a distribution
*/
EdgeCaffe::ArrivalList arrivals;
std::unique_ptr<EdgeCaffe::OrchestratorFactory> ofactory = std::make_unique<EdgeCaffe::OrchestratorFactory>();
auto orchest = ofactory->GetOrchestratorAlt();
/**
* Check if an arrival-list is given
* If an arrival-list is present we will you that one instead of generating arrivals
* If no arrival-list --> generate arrivals according to the distribution
*/
if( c_config.pathToArrivalList.isSet())
{
// std::cout << "I found an arrival-list at " << pathToArrivalList << std::endl;
arrivals.loadFromYaml(c_config.pathToArrivalList());
} else
{
// std::cout << "No arrivalList to be found" << std::endl;
arrivals.setEnabledNetworks({c_config.networks()});
arrivals.setSeed(c_config.seed());
if (c_config.poissonDistribution())
{
arrivals.generateList(c_config.numArrivals(), EdgeCaffe::ArrivalList::DISTRIBUTION_TYPE::POISSON, {c_config.iat()});
} else
{
arrivals.generateList(c_config.numArrivals(), EdgeCaffe::ArrivalList::DISTRIBUTION_TYPE::CONSTANT, {0});
}
}
{
// Make sure to save the arrival distribution
std::string arrivalListOutputFile = c_config.defaultOutPath() + "arrivals.csv";
EdgeCaffe::Output output;
output.toCSV(arrivalListOutputFile, arrivals.toCSVLines(), EdgeCaffe::Output::ARRIVALS);
}
orchest->setArrivals(arrivals);
auto system_time_start = std::chrono::system_clock::now();
auto startTime = std::chrono::high_resolution_clock::now();
orchest->start();
orchest->processTasks();
orchest->waitForStop();
auto endTime = std::chrono::high_resolution_clock::now();
auto system_time_end = std::chrono::system_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << duration << " milliseconds" << std::endl;
/**
* Processing the gathered data
* This part writes the timing information of the layers of the networks to a csv file.
* It overwrites the specified file. It is important to use a unique filename
* for each run of move the data in between runs to prevent losing data.
*/
std::string layerOutputFile = c_config.defaultOutPath() + outputFile;
orchest->processLayerData(layerOutputFile);
std::string queueEventsFile = c_config.defaultOutPath() + "stepEvents.csv";
orchest->processEventData(queueEventsFile, startTime);
std::string networkOutputFile = c_config.defaultOutPath() + "networkStats6.csv";
orchest->processNetworkData(networkOutputFile, startTime);
/**
* Save the output of the end-to-end measurement
* Here we append the measurement to the file
* If the file does not exist it is created.
*/
EdgeCaffe::Output output;
std::string tmp_network = "";
if(c_config.networks.valueOrDefault().size())
tmp_network = c_config.networks().front();
auto start_time_t = std::chrono::system_clock::to_time_t(system_time_start);
auto end_time_t = std::chrono::system_clock::to_time_t(system_time_end);
std::string generalLine;
generalLine = c_config.memoryLimit() + "," + modeAsString + "," + std::to_string(duration) + "," +
std::to_string(c_config.numArrivals()) + "," + tmp_network + "," + std::to_string(1) + "," +
std::to_string(0) + "," + std::to_string(c_config.iat()) + "," +
std::to_string(c_config.numberOfWorkers()) + "," + std::to_string(start_time_t) + "," + std::to_string(end_time_t);
output.toCSVAppend(c_config.outputDirectory() + "/" + c_config.generalOutputFile(), {generalLine}, EdgeCaffe::Output::PIPELINE_EXT);
for(const auto worker : orchest->getWorkers())
{
auto id = worker->workerId;
std::string workerStatFile = c_config.defaultOutPath() + "worker" + std::to_string(id) + ".csv";
auto lines = worker->workerProfileToCSVLines();
output.toCSV(workerStatFile, lines, EdgeCaffe::Output::WORKER);
}
output.toCSV(c_config.defaultOutPath() + "cc-networks.csv", orchest->getNr()->toCSV(), EdgeCaffe::Output::CONCURRENT_NETWORKS);
return 0;
}