Skip to content

Commit bb85def

Browse files
cyyeverfacebook-github-bot
authored andcommitted
Replace more std::endl with '\n' (#4471)
Summary: X-link: facebookresearch/FBGEMM#1536 The bench/**/*.cc files were missing in previous changes. Pull Request resolved: #4471 Reviewed By: gchalump, spcyppt Differential Revision: D78177481 Pulled By: q10 fbshipit-source-id: 6ac413c4282f30f1e91c1c38632b0c9d540dc5b8
1 parent d01549a commit bb85def

29 files changed

+103
-104
lines changed

bench/ConvUnifiedBenchmark.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void performance_test(
285285
<< "Postprocessing (ms), " << "fbgemmPacked (ms), " << "Total (ms), "
286286
<< "GOPS" << endl;
287287
#else
288-
cout << setw(6) << header << setw(5) << "GOPS" << endl;
288+
cout << setw(6) << header << setw(5) << "GOPS" << '\n';
289289
#endif
290290

291291
chrono::time_point<chrono::high_resolution_clock> begin, end;
@@ -493,7 +493,7 @@ static void performance_test(
493493
<< total_run_time / (double)NITER / 1e6 << ", "
494494
<< ttot / (double)NITER / 1e6 << ", ";
495495
#endif
496-
cout << setprecision(2) << nops / ttot << endl;
496+
cout << setprecision(2) << nops / ttot << '\n';
497497

498498
compare_buffers(
499499
Cint8_ref.data(),

bench/ConvertBenchmark.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void performance_test() {
2929
default_random_engine engine;
3030

3131
cout << setw(4) << "M" << " elements_per_ns_ref" << " elements_per_ns_simd"
32-
<< endl;
32+
<< '\n';
3333

3434
array<int, 8> dims{1, 10, 32, 40, 129, 256, 1024, 8000};
3535

@@ -59,7 +59,7 @@ static void performance_test() {
5959
duration_simd *= 1e9; // convert to ns
6060

6161
cout << setw(4) << M << setw(10) << setprecision(3) << M / duration_ref
62-
<< setw(10) << setprecision(3) << M / duration_simd << endl;
62+
<< setw(10) << setprecision(3) << M / duration_simd << '\n';
6363

6464
compare_buffers(b_ref.data(), b.data(), M, 1, 1, 5);
6565
} // M

bench/Depthwise3DBenchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ int main() {
212212
if (expected != actual) {
213213
cerr << "Depthwise 3x3x3 results differ at (" << n << ", " << t
214214
<< ", " << h << ", " << w << ", " << g << "). expected "
215-
<< (int)expected << " actual " << (int)actual << endl;
215+
<< (int)expected << " actual " << (int)actual << '\n';
216216
return -1;
217217
}
218218
assert(expected == actual);

bench/DepthwiseBenchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ int main() {
334334
if (expected != actual) {
335335
cerr << "Depthwise 3x3 results differ at (" << n << ", " << h
336336
<< ", " << w << ", " << k << "). expected " << (int)expected
337-
<< " actual " << (int)actual << endl;
337+
<< " actual " << (int)actual << '\n';
338338
return -1;
339339
}
340340
assert(expected == actual);

bench/EmbeddingIndexRemappingBenchmark.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int run_benchmark(
129129
NWARMUP,
130130
NITER);
131131
cout << "reference:" << duration_ref * 1e6 << " (us), ";
132-
cout << "Opt:" << duration * 1e6 << " (us) " << endl;
132+
cout << "Opt:" << duration * 1e6 << " (us) " << '\n';
133133

134134
return 0;
135135
}
@@ -149,13 +149,13 @@ int main() {
149149

150150
cout << "batch size" << setw(6) << batch_size << setw(10) << "num rows"
151151
<< setw(14) << num_rows << setw(16) << "avg length" << setw(6)
152-
<< average_len << endl;
152+
<< average_len << '\n';
153153
cout << "64 bit indices, ";
154154
run_benchmark(batch_size, num_rows, average_len);
155155

156156
cout << "32 bit indices, ";
157157
run_benchmark(batch_size, num_rows, average_len, true);
158-
cout << endl;
158+
cout << '\n';
159159
}
160160
return 0;
161161
}

bench/EmbeddingQuantizeBenchmark.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ static void performance_test() {
3030
constexpr int NITER = 256;
3131

3232
if constexpr (is_same_v<T, float16>) {
33-
cout << "With scale and bias as float16" << endl;
33+
cout << "With scale and bias as float16" << '\n';
3434
} else {
35-
cout << "With scale and bias as float" << endl;
35+
cout << "With scale and bias as float" << '\n';
3636
}
3737
cout << setw(8) << "bit_rate" << ", " << setw(6) << "rows" << "," << setw(6)
3838
<< "cols" << "," << setw(16) << "elems_per_usec" << "," << setw(10)
39-
<< "GB/Sec" << endl;
39+
<< "GB/Sec" << '\n';
4040
std::vector<int> bit_rates;
4141
if constexpr (is_same_v<T, float16>) {
4242
bit_rates = {2, 4, 8};
@@ -91,7 +91,7 @@ static void performance_test() {
9191
cout << setw(16) << std::fixed << std::setprecision(2)
9292
<< elements_per_usec << ", ";
9393
cout << setw(10) << std::fixed << std::setprecision(2)
94-
<< gigabyes_per_sec << endl;
94+
<< gigabyes_per_sec << '\n';
9595
} // for each cols
9696
} // for each rows
9797
} // for each bit_rate

bench/EmbeddingQuantizeFloatToFloatOrHalfBenchmark.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ static void performance_test() {
3030
constexpr int NITER = 256;
3131

3232
if constexpr (is_same_v<T, float16>) {
33-
cout << "With result as float16" << endl;
33+
cout << "With result as float16" << '\n';
3434
} else {
35-
cout << "With result as float" << endl;
35+
cout << "With result as float" << '\n';
3636
}
3737
cout << setw(6) << "rows" << "," << setw(6) << "cols" << "," << setw(16)
38-
<< "elems_per_usec" << "," << setw(10) << "GB/Sec" << endl;
38+
<< "elems_per_usec" << "," << setw(10) << "GB/Sec" << '\n';
3939

4040
for (int rowSize : {100, 120, 1000}) {
4141
for (int colSize : {16, 64, 128, 256, 512, 1024, 2048}) {
@@ -79,7 +79,7 @@ static void performance_test() {
7979
cout << setw(16) << std::fixed << std::setprecision(2)
8080
<< elements_per_usec << ", ";
8181
cout << setw(10) << std::fixed << std::setprecision(2) << gigabyes_per_sec
82-
<< endl;
82+
<< '\n';
8383
} // for each cols
8484
} // for each rows
8585
} // performance_test

bench/EmbeddingSpMDM8BitBenchmark.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int run_benchmark(
102102
// Compute the number of indices
103103
int lengths_sum = offsets[batch_size];
104104
if (fbgemm_get_thread_num() == 0) {
105-
cout << "lengths_sum " << lengths_sum << endl;
105+
cout << "lengths_sum " << lengths_sum << '\n';
106106
}
107107

108108
// Generate indices
@@ -274,11 +274,11 @@ static int run_benchmark(
274274
}
275275
} else {
276276
assert(false && "ERROR: unsupported output type");
277-
cout << "ERROR: unsupported output type" << endl;
277+
cout << "ERROR: unsupported output type" << '\n';
278278
}
279279
assert(fabs(tmp1 - tmp2) < 1e-3);
280280
if (fabs(tmp1 - tmp2) >= 1e-3) {
281-
cout << i << " " << tmp1 << " " << tmp2 << endl;
281+
cout << i << " " << tmp1 << " " << tmp2 << '\n';
282282
}
283283
}
284284
}
@@ -298,7 +298,7 @@ static int run_benchmark(
298298
}
299299
} else {
300300
assert(false && "ERROR: unsupported output type");
301-
cout << "ERROR: unsupported output type" << endl;
301+
cout << "ERROR: unsupported output type" << '\n';
302302
}
303303

304304
if (has_weight) {
@@ -331,7 +331,7 @@ static int run_benchmark(
331331
<< " GB/s" << setw(20) << "effective b/w: " << setw(16)
332332
<< bytes_padded / 1e9 / max_time << "GB/s" << setw(8) << " time "
333333
<< setw(16) << max_time << " load_imbalance " << load_imbalance
334-
<< endl;
334+
<< '\n';
335335
}
336336
} // flush_cache
337337
} // has_weight
@@ -354,7 +354,7 @@ int main() {
354354
cout << "batch size" << setw(6) << batch_size << setw(10) << "num rows"
355355
<< setw(16) << num_rows << setw(10) << "emb dim" << setw(6)
356356
<< embedding_dim << setw(16) << "avg length" << setw(6) << average_len
357-
<< endl;
357+
<< '\n';
358358
// args: batch sz, num rows, emb dim, avg len, normalize, use 32b,
359359
// prefetch
360360
cout << "64 bit indices, ";

bench/EmbeddingSpMDMBenchmark.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void run_benchmark(
9494

9595
// Compute the number of indices
9696
int lengths_sum = offsets[batch_size];
97-
cout << "lengths_sum " << lengths_sum << endl;
97+
cout << "lengths_sum " << lengths_sum << '\n';
9898

9999
// Generate indices
100100
vector<int64_t> indices;
@@ -353,7 +353,7 @@ static void run_benchmark(
353353
for (size_t i = 0; i < output.size(); ++i) {
354354
assert(output[i] == output_ref[i]);
355355
if (output[i] != output_ref[i]) {
356-
cout << i << " " << output[i] << " " << output_ref[i] << endl;
356+
cout << i << " " << output[i] << " " << output_ref[i] << '\n';
357357
}
358358
}
359359
}
@@ -378,7 +378,7 @@ static void run_benchmark(
378378
cout << setw(8) << "b/w" << setw(10) << bytes / 1e9 / t << " GB/s"
379379
<< setw(20) << "effective b/w: " << setw(16)
380380
<< bytes_padded / 1e9 / t << "GB/s" << setw(8) << " time "
381-
<< setw(16) << t << endl;
381+
<< setw(16) << t << '\n';
382382
} // flush_cache
383383
} // has_weight
384384
}
@@ -396,7 +396,7 @@ int main() {
396396
cout << "batch size" << setw(6) << batch_size << setw(10) << "num rows"
397397
<< setw(16) << num_rows << setw(10) << "emb dim" << setw(6)
398398
<< embedding_dim << setw(16) << "avg length" << setw(6) << average_len
399-
<< endl;
399+
<< '\n';
400400

401401
for (bool normalize_by_lengths : {false, true}) {
402402
for (std::string input_dtype : {"bf16", "fp16", "fp32"}) {

bench/EmbeddingSpMDMNBit2Benchmark.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static void print_benchmark_results() {
142142
<< "asmjit b/w (GB/s), asmjit effective b/w (GB/s), asmjit time, "
143143
<< "autovec b/w (GB/s), autovec effective b/w (GB/s), autovec time, "
144144
<< "ref b/w (GB/s), ref effective b/w (GB/s), ref time, "
145-
<< "asmjit speedup ratio, autovec speedup ratio" << endl;
145+
<< "asmjit speedup ratio, autovec speedup ratio" << '\n';
146146
for (auto& benchmark : benchmarks) {
147147
BenchmarkSpec& spec = benchmark.first;
148148
BenchmarkResult& res = benchmark.second;
@@ -157,7 +157,7 @@ static void print_benchmark_results() {
157157
<< res.asmjit_time << ", " << res.autovec_bw << ", "
158158
<< res.autovec_eff_bw << ", " << res.autovec_time << ", "
159159
<< res.ref_bw << ", " << res.ref_eff_bw << ", " << res.ref_time
160-
<< ", " << asmjit_speedup << ", " << autovec_speedup << endl;
160+
<< ", " << asmjit_speedup << ", " << autovec_speedup << '\n';
161161
}
162162
}
163163

@@ -456,7 +456,7 @@ static int run_benchmark(
456456
find_benchmark_record(spec).set_asmjit_result(
457457
bytes / 1e9 / t, bytes_padded / 1e9 / t, t);
458458
} else {
459-
std::cerr << "Bad kern_type parameter: " << kern_type << endl;
459+
std::cerr << "Bad kern_type parameter: " << kern_type << '\n';
460460
assert(false);
461461
}
462462
if (!success) {

0 commit comments

Comments
 (0)