-
Notifications
You must be signed in to change notification settings - Fork 1
/
parameters.cpp
255 lines (213 loc) · 11.6 KB
/
parameters.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#ifndef PARAMS_CLASS_INC
#define PARAMS_CLASS_INC
#include "parameters.h"
#endif
// Get integer from next line formated as follows : "Label information = 5000"
long long BenchParams::GetNextInteger(std::ifstream &inFile) {
std::string lineStr = GetNextLine(inFile);
lineStr = lineStr.substr(lineStr.find ('=') + 1);
lineStr = lineStr.substr(lineStr.find_first_not_of(' '));
return std::atoll(lineStr.c_str());
}
// Get boolean from next line formated as follows : "Label information = true"
bool BenchParams::GetNextBool(std::ifstream &inFile) {
std::string lineStr = GetNextLine(inFile);
return ((lineStr.find("alse") >= lineStr.length()) ? true : false);
}
// Get string from next line formated as follows : "Label information = STRING_NAME_HERE"
std::string BenchParams::GetNextString(std::ifstream &inFile) {
std::string lineStr = GetNextLine(inFile);
lineStr = lineStr.substr(lineStr.find('=') + 1);
return lineStr.substr(lineStr.find_first_not_of(' '));
}
// Gets next line from file that is not a comment
// Comment lines start with a dash ("-")
std::string BenchParams::GetNextLine(std::ifstream &inFile) {
// get lines of the input file until the first character of the line is not a dash
// dashes represent comments
std::string lineStr;
do {
if (inFile)
std::getline(inFile, lineStr);
} while (inFile && lineStr[0] == '-');
return lineStr;
}
// Function for parsing user provided input file.
// Users must adhere to input file structure provided
// in the sample input file to insure correct parsing
void BenchParams::ParseParamFile(std::string fileStr) {
inputFile = fileStr;
std::string lineStr;
std::ifstream inFile(inputFile.c_str());
if (inFile.fail()) {
SetDefault();
return;
}
useDefaultParams = false;
// Benchmark Parameters
runTag = GetNextString(inFile); // runTag
devPropFile = runTag + "_device_info.out";
topoFile = runTag + "_topology.out";
// All Tests
runAllDevices = GetNextBool(inFile); // runAllDevices
testAllMemTypes = GetNextBool(inFile); // testAllMemTypes
runBurstTests = GetNextBool(inFile); // runBurstTests
runRangeTests = GetNextBool(inFile); // runRangeTests
runSustainedTests = GetNextBool(inFile); // runSustainedTests
runSocketTests = GetNextBool(inFile); // runSocketTests
runPatternTests = GetNextBool(inFile); // runPatternTests
numPatterns = (runPatternTests ? NUM_ACCESS_PATTERNS: 1);
numStepRepeats = (long) GetNextInteger(inFile); // numStepRepeats
numRangeSteps = (long) GetNextInteger(inFile); // numRangeSteps
burstBlockSize = GetNextInteger(inFile); // burstBlockSize
// Memory Overhead Test
runMemoryOverheadTest = GetNextBool(inFile); // runMemoryOverheadTest
for (int i = 0; i < 2; i++) // rangeMemOverhead
rangeMemOH[i] = GetNextInteger(inFile);
// Host-Host Bandwidth Test
runBandwidthTestHH = GetNextBool(inFile); // runHHBandwidthTest
for (int i = 0; i < 2; i++) // rangeHostHostBW
rangeHHBW[i] = GetNextInteger(inFile);
// Host-Device Bandwidth Test
runBandwidthTestHD = GetNextBool(inFile); // runHDBandwidthTest
for (int i = 0; i < 2; i++) // rangeHostDeviceBW
rangeHDBW[i] = GetNextInteger(inFile);
// P2P Bandwidth Test
runBandwidthTestP2P = GetNextBool(inFile); // runP2PBandwidthTest
for (int i = 0; i < 2; i++) // rangeDeviceP2P
rangeP2PBW[i] = GetNextInteger(inFile);
// NURMA Test
runNURMATest = GetNextBool(inFile); // runNURMATest
gapNURMA = GetNextInteger(inFile); // gapNURMA
blockSizeNURMA = GetNextInteger(inFile); // blockSizeNURMA
for (int i = 0; i < 2; i++) // rangeNURMA
rangeNURMA[i] = GetNextInteger(inFile);
// Memory System Contention Test
runContentionTest = GetNextBool(inFile); // runContentionTest
numContRepeats = GetNextInteger(inFile); // numContRepeats
for (int i = 0; i < 3; i++) // rangeCont
contBlockSize[i] = GetNextInteger(inFile);
}
// Set default device properties based on an interesting variety of tests
// in case no input file is provided. These values do necessarily reflect
// what the developer recommends to demonstrate category performance on any
// specific system system
void BenchParams::SetDefault() {
inputFile = "none";
useDefaultParams = true;
runTag = "results";
devPropFile = runTag + "_device_info.out";
topoFile = runTag + "_topology.out";
runAllDevices = true;
testAllMemTypes = true;
runBurstTests = true;
runRangeTests = true;
runSustainedTests = true;
runSocketTests = true;
runPatternTests = true;
numPatterns = NUM_ACCESS_PATTERNS;
numStepRepeats = 10;
numRangeSteps = 10;
burstBlockSize = 100000000;
runMemoryOverheadTest = true;
rangeMemOH[0] = 1000;
rangeMemOH[1] = 100000000;
runBandwidthTestHH = true;
rangeHDBW[0] = 1000;
rangeHDBW[1] = 1000000000;
runBandwidthTestHD = true;
rangeHDBW[0] = 1000;
rangeHDBW[1] = 1000000000;
runBandwidthTestP2P = true;
rangeP2PBW[0] = 1000; // 100B min block size
rangeP2PBW[1] = 1000000000; // 1500MB max block size
runNURMATest = true;
gapNURMA = 65430;
blockSizeNURMA = 300000000;
rangeNURMA[0] = 100;
rangeNURMA[1] = 100000000;
runContentionTest = false;
numContRepeats = 50;
contBlockSize[0] = 100000000; // Local Host Memory Contention Test
contBlockSize[1] = 100000000; // QPI Intersocket Memory Contententon Test
contBlockSize[2] = 100000000; // Host-Device Memory Contention Test (PCIe)
}
void BenchParams::PrintParams() {
std::stringstream outParamStr;
outParamStr << std::boolalpha;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "------------------------- Test Parameters -----------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Input File:\t\t\t" << inputFile << std::endl;
outParamStr << "Using Defaults:\t\t\t" << useDefaultParams << std::endl;
outParamStr << "Run Tag:\t\t\t" << runTag << std::endl;
outParamStr << "Device Property File:\t\t" << devPropFile << std::endl;
outParamStr << "Topology File:\t\t\t" << topoFile << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "------------------ General Benchmark Parameters ----------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Use all Devices:\t\t" << runAllDevices << std::endl;
outParamStr << "Device Count:\t\t\t" << nDevices << std::endl;
outParamStr << "Test All Sockets:\t\t" << runSocketTests << std::endl;
outParamStr << "# CPU Sockets:\t\t\t" << nSockets << std::endl;
outParamStr << "# NUMA Nodes:\t\t\t" << nNodes << std::endl;
outParamStr << "Test Access Patterns:\t\t" << runPatternTests << std::endl;
outParamStr << "# Mem Access patterns:\t\t" << numPatterns << std::endl;
outParamStr << "Test Host Mem Types:\t\t" << testAllMemTypes << std::endl;
outParamStr << "Ranged Tests:\t\t\t" << runRangeTests << std::endl;
outParamStr << "Burst Tests:\t\t\t" << runBurstTests << std::endl;
outParamStr << "Burst Block Size:\t\t" << burstBlockSize << std::endl;
outParamStr << "Sustained Tests:\t\t" << runSustainedTests << std::endl;
outParamStr << "# Repeated Steps:\t\t" << numStepRepeats << std::endl;
outParamStr << "Number Steps Per Magnitude:\t" << numRangeSteps << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "---------------------- Memory Overhead Test ---------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Test:\t\t\t" << runMemoryOverheadTest << std::endl;
outParamStr << "Allocation Range: \t\t";
outParamStr << rangeMemOH[0] << "," << rangeMemOH[1] << " (min,max)" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "------------------- Host-Host Bandwidth Test --------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Test:\t\t\t" << runBandwidthTestHH << std::endl;
outParamStr << "Allocation Range:\t\t";
outParamStr << rangeHHBW[0] << "," << rangeHHBW[1] << " (min,max)" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "------------------- Host-Device Bandwidth Test ------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Test:\t\t\t" << runBandwidthTestHD << std::endl;
outParamStr << "Allocation Range:\t\t";
outParamStr << rangeHDBW[0] << "," << rangeHDBW[1] << " (min,max)" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "---------------------- P2P Bandwidth Test -----------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Test:\t\t\t" << runBandwidthTestP2P << std::endl;
outParamStr << "Allocation Range:\t\t";
outParamStr << rangeP2PBW[0] << "," << rangeP2PBW[1] << " (min,max)" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "------------- Non-Uniform Random Memory Access Test -------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Test:\t\t\t" << runNURMATest << std::endl;
outParamStr << "Memory Access Gap (doubles):\t" << gapNURMA << std::endl;
outParamStr << "Memory Block Size (doubles):\t" << blockSizeNURMA << std::endl;
outParamStr << "Access Count Range (doubles):\t";
outParamStr << rangeNURMA[0] << "," << rangeNURMA[1] << " (min,max)" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "---------------------- Resource Contention ----------------------" << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << "Run Contention Test:\t\t" << runContentionTest << std::endl;
outParamStr << "# Repeated Operations:\t\t" << numContRepeats << std::endl;
outParamStr << "Local Host Block Size:\t\t" << contBlockSize[0] << std::endl;
outParamStr << "Host QPI Mem BlockSize:\t\t" << contBlockSize[1] << std::endl;
outParamStr << "PCIe Mem Block Size:\t\t" << contBlockSize[2] << std::endl;
outParamStr << "-----------------------------------------------------------------" << std::endl;
outParamStr << std::noboolalpha;
//Print benchmark parameters to string
std::cout << "\n" << outParamStr.str();
// Print benchmark parameters to output file
std::string paramFileName = "./results/" + runTag + "_parameters.out";
std::ofstream outParamFile(paramFileName.c_str());
outParamFile << outParamStr.str() << std::endl;
//read params out to command line
outParamFile.close();
}