Skip to content

Commit a7809b3

Browse files
authored
Standardize output formats (ROCm#140)
* remove spaces from csv * consistently set redop to none when applicable * write output file after test finishes
1 parent 645be0e commit a7809b3

File tree

4 files changed

+48
-25
lines changed

4 files changed

+48
-25
lines changed

‎src/alltoallv.cu‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ testResult_t AlltoAllvRunTest(struct threadArgs* args, int root, ncclDataType_t
181181
}
182182

183183
for (int i=0; i<type_count; i++) {
184-
TESTCHECK(TimeTest(args, run_types[i], run_typenames[i], (ncclRedOp_t)0, "", -1));
184+
TESTCHECK(TimeTest(args, run_types[i], run_typenames[i], (ncclRedOp_t)0, "none", -1));
185185
}
186186
return testSuccess;
187187
}

‎src/common.cu‎

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ Reporter::Reporter(std::string fileName, std::string outputFormat) : _outputForm
133133
if (isMainThread()) {
134134
_out = std::ofstream(fileName, std::ios_base::out);
135135
_outputValid = true;
136-
if (_outputFormat == "csv") {
137-
_out << "numCycle, ";
138-
_out << "collective, ";
139-
#ifdef MPI_SUPPORT
140-
_out << "ranks, rankspernode, gpusperrank, ";
141-
#else
142-
_out << "gpus, ";
143-
#endif
144-
_out << "size, type, redop, inplace, time, algbw, busbw, #wrong\n";
145-
}
146136
}
147137
}
148138
}
@@ -184,27 +174,54 @@ void Reporter::addResult(int gpusPerRank, int ranksPerNode, int totalRanks, size
184174
outputValuesKeys.push_back(makeValueKeyPair(busBw, "busBw"));
185175
outputValuesKeys.push_back(makeValueKeyPair(wrongEltsStr, "wrong"));
186176

187-
for (auto iter = outputValuesKeys.begin(); iter != outputValuesKeys.end(); ++iter) {
188-
if (_outputFormat == "csv") {
189-
_out << iter->first;
190-
if (std::next(iter) != outputValuesKeys.end()) {
191-
_out << ", ";
177+
_outputData.push_back(outputValuesKeys);
178+
}
179+
180+
void Reporter::writeFile() {
181+
if (!isMainThread() || !_outputValid)
182+
return;
183+
184+
if (_outputFormat == "csv") {
185+
_out << "numCycle,";
186+
_out << "collective,";
187+
#ifdef MPI_SUPPORT
188+
_out << "ranks,rankspernode,gpusperrank,";
189+
#else
190+
_out << "gpus,";
191+
#endif
192+
_out << "size,type,redop,inplace,time,algbw,busbw,#wrong\n";
193+
for (auto iterEntries = _outputData.begin(); iterEntries != _outputData.end(); ++iterEntries) {
194+
for (auto iterVals = (*iterEntries).begin(); iterVals != (*iterEntries).end(); ++iterVals) {
195+
_out << iterVals->first;
196+
if (std::next(iterVals) != (*iterEntries).end()) {
197+
_out << ",";
198+
}
192199
}
193-
} else { //json
194-
if (iter == outputValuesKeys.begin()) {
195-
_out << "{";
200+
_out << std::endl;
201+
}
202+
} else { //json
203+
_out << "[" << std::endl;
204+
for (auto iterEntries = _outputData.begin(); iterEntries != _outputData.end(); ++iterEntries) {
205+
for (auto iterVals = (*iterEntries).begin(); iterVals != (*iterEntries).end(); ++iterVals) {
206+
if (iterVals == (*iterEntries).begin()) {
207+
_out << "{";
208+
}
209+
_out << "\"" << iterVals->second << "\":" << iterVals->first;
210+
if (std::next(iterVals) != (*iterEntries).end()) {
211+
_out << ", ";
212+
}
196213
}
197-
_out << "\"" << iter->second << "\":" << iter->first;
198-
if (std::next(iter) != outputValuesKeys.end()) {
199-
_out << ", ";
214+
if (std::next(iterEntries) != _outputData.end()) {
215+
_out << "}," << std::endl;
200216
} else {
201-
_out << "}";
217+
_out << "}" << std::endl;
202218
}
203219
}
220+
_out << "]" << std::endl;
204221
}
205-
_out << std::endl;
206222
}
207223

224+
208225
bool Reporter::isMainThread() { return is_main_thread == 1; }
209226

210227
#define NUM_BLOCKS 32
@@ -1711,6 +1728,8 @@ testResult_t run() {
17111728
MPI_Finalize();
17121729
#endif
17131730

1731+
reporter.writeFile();
1732+
17141733
// 'cuda-memcheck --leak-check full' requires this
17151734
PRINT("%s\n", ncclGetLastError(NULL));
17161735
cudaDeviceReset();

‎src/common.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <string>
2323
#include <fstream>
2424
#include <iostream>
25+
#include <utility>
26+
#include <vector>
2527

2628
// Ensures backward compatibility for FP8 datatypes
2729
#if NCCL_VERSION_CODE < NCCL_VERSION(2,24,3)
@@ -119,6 +121,7 @@ class Reporter {
119121
~Reporter() { if (_outputValid) { _out.close(); } };
120122
void setParameters(const size_t numCycle, const char* name, const char* typeName, const char* opName);
121123
void addResult(int gpusPerRank, int ranksPerNode, int totalRanks, size_t numBytes, int inPlace, double timeUsec, double algBw, double busBw, int64_t wrongElts = -1);
124+
void writeFile();
122125

123126
private:
124127
bool isMainThread();
@@ -132,6 +135,7 @@ class Reporter {
132135
std::string _collectiveName;
133136
std::string _typeName;
134137
std::string _opName;
138+
std::vector<std::vector<std::pair<std::string, std::string>>> _outputData;
135139
};
136140

137141
struct testEngine {

‎src/hypercube.cu‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ testResult_t HyperCubeRunTest(struct threadArgs* args, int root, ncclDataType_t
101101
int nRanks = args->nProcs*args->nThreads*args->nGpus;
102102
if (nRanks && !(nRanks & (nRanks - 1))) {
103103
for (int i=0; i<type_count; i++) {
104-
TESTCHECK(TimeTest(args, run_types[i], run_typenames[i], (ncclRedOp_t)0, "", -1));
104+
TESTCHECK(TimeTest(args, run_types[i], run_typenames[i], (ncclRedOp_t)0, "none", -1));
105105
}
106106
} else {
107107
printf("nRanks %d is not a power of 2, skipping\n", nRanks);

0 commit comments

Comments
 (0)