MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_PerfModels_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
11
12#include <cstdio>
13#include <cmath>
14#include <numeric>
15#include <utility>
16#include <chrono>
17#include <iomanip>
18#include <Teuchos_ScalarTraits.hpp>
19#include <KokkosKernels_ArithTraits.hpp>
20#include <Xpetra_Import.hpp>
21#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MPI)
22#include <Xpetra_TpetraImport.hpp>
23#include <Tpetra_Import.hpp>
24#include <Tpetra_Distributor.hpp>
25#include <mpi.h>
26#endif
27
28#ifdef HAVE_MPI
29#endif
30
31namespace MueLu {
32
33namespace PerfDetails {
34template <class Scalar, class Node>
35double stream_vector_add(int KERNEL_REPEATS, int VECTOR_SIZE) {
36 // PerfDetails' STREAM routines need to be instantiatiated on impl_scalar_type, not Scalar
37 using impl_scalar_type = typename KokkosKernels::ArithTraits<Scalar>::val_type;
38
39 using exec_space = typename Node::execution_space;
40 using memory_space = typename Node::memory_space;
41 using range_policy = Kokkos::RangePolicy<exec_space>;
42
43 Kokkos::View<impl_scalar_type *, memory_space> a("a", VECTOR_SIZE);
44 Kokkos::View<impl_scalar_type *, memory_space> b("b", VECTOR_SIZE);
45 Kokkos::View<impl_scalar_type *, memory_space> c("c", VECTOR_SIZE);
46 double total_test_time = 0.0;
47
48 impl_scalar_type ONE = Teuchos::ScalarTraits<impl_scalar_type>::one();
49
50 Kokkos::parallel_for(
51 "stream/fill", range_policy(0, VECTOR_SIZE), KOKKOS_LAMBDA(const size_t i) {
52 a(i) = ONE * (double)i;
53 b(i) = a(i);
54 });
55 exec_space().fence();
56
57 using clock = std::chrono::high_resolution_clock;
58
59 clock::time_point start, stop;
60
61 for (int i = 0; i < KERNEL_REPEATS; i++) {
62 start = clock::now();
63 Kokkos::parallel_for(
64 "stream/add", range_policy(0, VECTOR_SIZE), KOKKOS_LAMBDA(const size_t j) { // Vector Addition
65 c(j) = a(j) + b(j);
66 });
67
68 exec_space().fence();
69 stop = clock::now();
70 double my_test_time = std::chrono::duration<double>(stop - start).count();
71 total_test_time += my_test_time;
72 }
73
74 return total_test_time / KERNEL_REPEATS;
75}
76
77template <class Scalar, class Node>
78double stream_vector_copy(int KERNEL_REPEATS, int VECTOR_SIZE) {
79 // PerfDetails' STREAM routines need to be instantiatiated on impl_scalar_type, not Scalar
80 using impl_scalar_type = typename KokkosKernels::ArithTraits<Scalar>::val_type;
81
82 using exec_space = typename Node::execution_space;
83 using memory_space = typename Node::memory_space;
84 using range_policy = Kokkos::RangePolicy<exec_space>;
85
86 Kokkos::View<impl_scalar_type *, memory_space> a("a", VECTOR_SIZE);
87 Kokkos::View<impl_scalar_type *, memory_space> b("b", VECTOR_SIZE);
88 double total_test_time = 0.0;
89
90 impl_scalar_type ONE = Teuchos::ScalarTraits<impl_scalar_type>::one();
91
92 Kokkos::parallel_for(
93 "stream/fill", range_policy(0, VECTOR_SIZE), KOKKOS_LAMBDA(const size_t i) {
94 a(i) = ONE;
95 });
96 exec_space().fence();
97
98 using clock = std::chrono::high_resolution_clock;
99 clock::time_point start, stop;
100
101 for (int i = 0; i < KERNEL_REPEATS; i++) {
102 start = clock::now();
103 Kokkos::parallel_for(
104 "stream/copy", range_policy(0, VECTOR_SIZE), KOKKOS_LAMBDA(const size_t j) { // Vector Addition
105 b(j) = a(j);
106 });
107
108 exec_space().fence();
109 stop = clock::now();
110 double my_test_time = std::chrono::duration<double>(stop - start).count();
111 total_test_time += my_test_time;
112 }
113
114 return total_test_time / KERNEL_REPEATS;
115}
116
117double table_lookup(const std::vector<int> &x, const std::vector<double> &y, int value) {
118 // If there's no table, nan
119 if (x.size() == 0) return Teuchos::ScalarTraits<double>::nan();
120
121 // NOTE: This should probably be a binary search, but this isn't performance sensitive, so we'll go simple
122 int N = (int)x.size();
123 int hi = 0;
124 for (; hi < N; hi++) {
125 if (x[hi] > value)
126 break;
127 }
128
129 if (hi == 0) {
130 // Lower end (return the min time)
131 // printf("Lower end: %d < %d\n",value,x[0]);
132 return y[0];
133 } else if (hi == N) {
134 // Higher end (extrapolate from the last two points)
135 // printf("Upper end: %d > %d\n",value,x[N-1]);
136 hi = N - 1;
137 int run = x[hi] - x[hi - 1];
138 double rise = y[hi] - y[hi - 1];
139 double slope = rise / run;
140 int diff = value - x[hi - 1];
141
142 return y[hi - 1] + slope * diff;
143 } else {
144 // Interpolate
145 // printf("Middle: %d < %d < %d\n",x[hi-1],value,x[hi]);
146 int run = x[hi] - x[hi - 1];
147 double rise = y[hi] - y[hi - 1];
148 double slope = rise / run;
149 int diff = value - x[hi - 1];
150
151 return y[hi - 1] + slope * diff;
152 }
153}
154
155// Report bandwidth in GB / sec
156const double GB = 1024.0 * 1024.0 * 1024.0;
157double convert_time_to_bandwidth_gbs(double time, int num_calls, double memory_per_call_bytes) {
158 double time_per_call = time / num_calls;
159 return memory_per_call_bytes / GB / time_per_call;
160}
161
162template <class exec_space, class memory_space>
163void pingpong_basic(int KERNEL_REPEATS, int MAX_SIZE, const Teuchos::Comm<int> &comm, std::vector<int> &sizes, std::vector<double> &times) {
164#ifdef HAVE_MPI
165 int rank = comm.getRank();
166 int nproc = comm.getSize();
167
168 if (nproc < 2) return;
169
170 const int buff_size = (int)pow(2, MAX_SIZE);
171
172 sizes.resize(MAX_SIZE + 1);
173 times.resize(MAX_SIZE + 1);
174
175 // Allocate memory for the buffers (and fill send)
176 Kokkos::View<char *, memory_space> r_buf("recv", buff_size), s_buf("send", buff_size);
177 Kokkos::deep_copy(s_buf, 1);
178
179 // Send and recieve.
180 // NOTE: Do consectutive pair buddies here for simplicity. We should be smart later
181 int odd = rank % 2;
182 int buddy = odd ? rank - 1 : rank + 1;
183
184 for (int i = 0; i < MAX_SIZE + 1; i++) {
185 int msg_size = (int)pow(2, i);
186 comm.barrier();
187
188 double t0 = MPI_Wtime();
189 for (int j = 0; j < KERNEL_REPEATS; j++) {
190 if (buddy < nproc) {
191 if (odd) {
192 comm.send(msg_size, (char *)s_buf.data(), buddy);
193 comm.receive(buddy, msg_size, (char *)r_buf.data());
194 } else {
195 comm.receive(buddy, msg_size, (char *)r_buf.data());
196 comm.send(msg_size, (char *)s_buf.data(), buddy);
197 }
198 }
199 }
200
201 double time_per_call = (MPI_Wtime() - t0) / (2.0 * KERNEL_REPEATS);
202 sizes[i] = msg_size;
203 times[i] = time_per_call;
204 }
205#else
206 return;
207#endif
208}
209
210template <class exec_space, class memory_space, class LocalOrdinal, class GlobalOrdinal, class Node>
211void halopong_basic(int KERNEL_REPEATS, int MAX_SIZE, const RCP<const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import, std::vector<int> &sizes, std::vector<double> &times) {
212 int nproc = import->getSourceMap()->getComm()->getSize();
213 if (nproc < 2) return;
214#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MPI)
215 // NOTE: We need to get the distributer here, which means we need Tpetra, since Xpetra does
216 // not have a distributor interface
217 using x_import_type = Xpetra::TpetraImport<LocalOrdinal, GlobalOrdinal, Node>;
218 RCP<const x_import_type> Ximport = Teuchos::rcp_dynamic_cast<const x_import_type>(import);
219 RCP<const Teuchos::MpiComm<int> > mcomm = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(import->getSourceMap()->getComm());
220 MPI_Comm communicator = *mcomm->getRawMpiComm();
221
222 if (Ximport.is_null() || mcomm.is_null()) return;
223 auto Timport = Ximport->getTpetra_Import();
224 auto distor = Timport->getDistributor();
225
226 // Distributor innards
227 Teuchos::ArrayView<const int> procsFrom = distor.getProcsFrom();
228 Teuchos::ArrayView<const int> procsTo = distor.getProcsTo();
229 int num_recvs = (int)distor.getNumReceives();
230 int num_sends = (int)distor.getNumSends();
231
232 const int buff_size_per_msg = (int)pow(2, MAX_SIZE);
233 sizes.resize(MAX_SIZE + 1);
234 times.resize(MAX_SIZE + 1);
235
236 // Allocate memory for the buffers (and fill send)
237 Kokkos::View<char *, memory_space> f_recv_buf("forward_recv", buff_size_per_msg * num_recvs), f_send_buf("forward_send", buff_size_per_msg * num_sends);
238 Kokkos::View<char *, memory_space> r_recv_buf("reverse_recv", buff_size_per_msg * num_sends), r_send_buf("reverse_send", buff_size_per_msg * num_recvs);
239 Kokkos::deep_copy(f_send_buf, 1);
240 Kokkos::deep_copy(r_send_buf, 1);
241
242 std::vector<MPI_Request> requests(num_sends + num_recvs);
243 std::vector<MPI_Status> status(num_sends + num_recvs);
244
245 for (int i = 0; i < MAX_SIZE + 1; i++) {
246 int msg_size = (int)pow(2, i);
247
248 MPI_Barrier(communicator);
249
250 double t0 = MPI_Wtime();
251 for (int j = 0; j < KERNEL_REPEATS; j++) {
252 int ct = 0;
253 // Recv/Send the forward messsages
254 for (int r = 0; r < num_recvs; r++) {
255 const int tag = 1000 + j;
256 MPI_Irecv(f_recv_buf.data() + msg_size * r, msg_size, MPI_CHAR, procsFrom[r], tag, communicator, &requests[ct]);
257 ct++;
258 }
259 for (int s = 0; s < num_sends; s++) {
260 const int tag = 1000 + j;
261 MPI_Isend(f_send_buf.data() + msg_size * s, msg_size, MPI_CHAR, procsTo[s], tag, communicator, &requests[ct]);
262 ct++;
263 }
264 // Wait for the forward messsages
265 MPI_Waitall(ct, requests.data(), status.data());
266
267 ct = 0;
268 // Recv/Send the reverse messsages
269 for (int r = 0; r < num_sends; r++) {
270 const int tag = 2000 + j;
271 MPI_Irecv(r_recv_buf.data() + msg_size * r, msg_size, MPI_CHAR, procsTo[r], tag, communicator, &requests[ct]);
272 ct++;
273 }
274 for (int s = 0; s < num_recvs; s++) {
275 const int tag = 2000 + j;
276 MPI_Isend(r_send_buf.data() + msg_size * s, msg_size, MPI_CHAR, procsFrom[s], tag, communicator, &requests[ct]);
277 ct++;
278 }
279 // Wait for the reverse messsages
280 MPI_Waitall(ct, requests.data(), status.data());
281 }
282
283 double time_per_call = (MPI_Wtime() - t0) / (2.0 * KERNEL_REPEATS);
284 sizes[i] = msg_size;
285 times[i] = time_per_call;
286 }
287
288#endif
289}
290
291} // end namespace PerfDetails
292
293template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
296
297template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
299
300/****************************************************************************************/
301/****************************************************************************************/
302/****************************************************************************************/
303
304template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
306 // We need launch/waits latency estimates for corrected stream
307 launch_latency_make_table(KERNEL_REPEATS);
308 double latency = launch_latency_lookup();
309
310 if (LOG_MAX_SIZE < 2)
311 LOG_MAX_SIZE = 20;
312
313 stream_sizes_.resize(LOG_MAX_SIZE + 1);
314 stream_copy_times_.resize(LOG_MAX_SIZE + 1);
315 stream_add_times_.resize(LOG_MAX_SIZE + 1);
316 latency_corrected_stream_copy_times_.resize(LOG_MAX_SIZE + 1);
317 latency_corrected_stream_add_times_.resize(LOG_MAX_SIZE + 1);
318
319 for (int i = 0; i < LOG_MAX_SIZE + 1; i++) {
320 int size = (int)pow(2, i);
321 double c_time = PerfDetails::stream_vector_copy<Scalar, Node>(KERNEL_REPEATS, size);
322 double a_time = PerfDetails::stream_vector_add<Scalar, Node>(KERNEL_REPEATS, size);
323
324 stream_sizes_[i] = size;
325
326 // Correct for the difference in memory transactions per element
327 stream_copy_times_[i] = c_time / 2.0;
328 stream_add_times_[i] = a_time / 3.0;
329
330 // Correct for launch latency too. We'll note that sometimes the latency estimate
331 // is higher than the actual copy/add time estimate. If so, we don't correct
332 latency_corrected_stream_copy_times_[i] = (c_time - latency <= 0.0) ? c_time / 2.0 : ((c_time - latency) / 2.0);
333 latency_corrected_stream_add_times_[i] = (a_time - latency <= 0.0) ? a_time / 3.0 : ((a_time - latency) / 3.0);
334 }
335}
336
337template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
338double
340 return PerfDetails::table_lookup(stream_sizes_, stream_copy_times_, SIZE_IN_BYTES / sizeof(Scalar));
341}
342
343template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
344double
346 return PerfDetails::table_lookup(stream_sizes_, stream_add_times_, SIZE_IN_BYTES / sizeof(Scalar));
347}
348
349template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
350double
352 return std::min(stream_vector_copy_lookup(SIZE_IN_BYTES), stream_vector_add_lookup(SIZE_IN_BYTES));
353}
354
355template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
356double
358 return PerfDetails::table_lookup(stream_sizes_, latency_corrected_stream_copy_times_, SIZE_IN_BYTES / sizeof(Scalar));
359}
360
361template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
362double
364 return PerfDetails::table_lookup(stream_sizes_, latency_corrected_stream_add_times_, SIZE_IN_BYTES / sizeof(Scalar));
365}
366
367template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
368double
370 return std::min(latency_corrected_stream_vector_copy_lookup(SIZE_IN_BYTES), latency_corrected_stream_vector_add_lookup(SIZE_IN_BYTES));
371}
372
373template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
375 print_stream_vector_table_impl(out, false, prefix);
376}
377
378template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
380 print_stream_vector_table_impl(out, true, prefix);
381}
382
383template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
384void PerfModels<Scalar, LocalOrdinal, GlobalOrdinal, Node>::print_stream_vector_table_impl(std::ostream &out, bool use_latency_correction, const std::string &prefix) {
385 using namespace std;
386 std::ios old_format(NULL);
387 old_format.copyfmt(out);
388
389 out << prefix
390 << setw(20) << "Length in Scalars" << setw(1) << " "
391 << setw(20) << "COPY (us)" << setw(1) << " "
392 << setw(20) << "ADD (us)" << setw(1) << " "
393 << setw(20) << "COPY (GB/s)" << setw(1) << " "
394 << setw(20) << "ADD (GB/s)" << std::endl;
395
396 out << prefix
397 << setw(20) << "-----------------" << setw(1) << " "
398 << setw(20) << "---------" << setw(1) << " "
399 << setw(20) << "--------" << setw(1) << " "
400 << setw(20) << "-----------" << setw(1) << " "
401 << setw(20) << "----------" << std::endl;
402
403 for (int i = 0; i < (int)stream_sizes_.size(); i++) {
404 int size = stream_sizes_[i];
405 double c_time = use_latency_correction ? latency_corrected_stream_copy_times_[i] : stream_copy_times_[i];
406 double a_time = use_latency_correction ? latency_corrected_stream_add_times_[i] : stream_add_times_[i];
407 // We've already corrected for the transactions per element difference
408 double c_bw = PerfDetails::convert_time_to_bandwidth_gbs(c_time, 1, size * sizeof(Scalar));
409 double a_bw = PerfDetails::convert_time_to_bandwidth_gbs(a_time, 1, size * sizeof(Scalar));
410
411 out << prefix
412 << setw(20) << size << setw(1) << " "
413 << setw(20) << fixed << setprecision(4) << (c_time * 1e6) << setw(1) << " "
414 << setw(20) << fixed << setprecision(4) << (a_time * 1e6) << setw(1) << " "
415 << setw(20) << fixed << setprecision(4) << c_bw << setw(1) << " "
416 << setw(20) << fixed << setprecision(4) << a_bw << std::endl;
417 }
418
419 out.copyfmt(old_format);
420}
421
422/****************************************************************************************/
423/****************************************************************************************/
424/****************************************************************************************/
425
426template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
427void PerfModels<Scalar, LocalOrdinal, GlobalOrdinal, Node>::pingpong_make_table(int KERNEL_REPEATS, int LOG_MAX_SIZE, const RCP<const Teuchos::Comm<int> > &comm) {
428 PerfDetails::pingpong_basic<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>(KERNEL_REPEATS, LOG_MAX_SIZE, *comm, pingpong_sizes_, pingpong_host_times_);
429
430 PerfDetails::pingpong_basic<typename Node::execution_space, typename Node::memory_space>(KERNEL_REPEATS, LOG_MAX_SIZE, *comm, pingpong_sizes_, pingpong_device_times_);
431}
432
433template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
434double
436 return PerfDetails::table_lookup(pingpong_sizes_, pingpong_host_times_, SIZE_IN_BYTES);
437}
438
439template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
440double
442 return PerfDetails::table_lookup(pingpong_sizes_, pingpong_device_times_, SIZE_IN_BYTES);
443}
444
445template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
446void PerfModels<Scalar, LocalOrdinal, GlobalOrdinal, Node>::print_pingpong_table(std::ostream &out, const std::string &prefix) {
447 if (pingpong_sizes_.size() == 0) return;
448
449 using namespace std;
450 std::ios old_format(NULL);
451 old_format.copyfmt(out);
452
453 out << prefix
454 << setw(20) << "Message Size" << setw(1) << " "
455 << setw(20) << "Host (us)" << setw(1) << " "
456 << setw(20) << "Device (us)" << std::endl;
457
458 out << prefix
459 << setw(20) << "------------" << setw(1) << " "
460 << setw(20) << "---------" << setw(1) << " "
461 << setw(20) << "-----------" << std::endl;
462
463 for (int i = 0; i < (int)pingpong_sizes_.size(); i++) {
464 int size = pingpong_sizes_[i];
465 double h_time = pingpong_host_times_[i];
466 double d_time = pingpong_device_times_[i];
467
468 out << prefix
469 << setw(20) << size << setw(1) << " "
470 << setw(20) << fixed << setprecision(4) << (h_time * 1e6) << setw(1) << " "
471 << setw(20) << fixed << setprecision(4) << (d_time * 1e6) << setw(1) << std::endl;
472 }
473
474 out.copyfmt(old_format);
475}
476
477/****************************************************************************************/
478/****************************************************************************************/
479/****************************************************************************************/
480template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
481void PerfModels<Scalar, LocalOrdinal, GlobalOrdinal, Node>::halopong_make_table(int KERNEL_REPEATS, int LOG_MAX_SIZE, const RCP<const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import) {
482 PerfDetails::halopong_basic<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>(KERNEL_REPEATS, LOG_MAX_SIZE, import, halopong_sizes_, halopong_host_times_);
483
484 PerfDetails::halopong_basic<typename Node::execution_space, typename Node::memory_space>(KERNEL_REPEATS, LOG_MAX_SIZE, import, halopong_sizes_, halopong_device_times_);
485}
486
487template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
488double
490 return PerfDetails::table_lookup(halopong_sizes_, halopong_host_times_, SIZE_IN_BYTES);
491}
492
493template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
494double
496 return PerfDetails::table_lookup(halopong_sizes_, halopong_device_times_, SIZE_IN_BYTES);
497}
498
499template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
500void PerfModels<Scalar, LocalOrdinal, GlobalOrdinal, Node>::print_halopong_table(std::ostream &out, const std::string &prefix) {
501 if (halopong_sizes_.size() == 0) return;
502
503 using namespace std;
504 std::ios old_format(NULL);
505 old_format.copyfmt(out);
506
507 out << prefix
508 << setw(20) << "Message Size" << setw(1) << " "
509 << setw(20) << "Host (us)" << setw(1) << " "
510 << setw(20) << "Device (us)" << std::endl;
511
512 out << prefix
513 << setw(20) << "------------" << setw(1) << " "
514 << setw(20) << "---------" << setw(1) << " "
515 << setw(20) << "-----------" << std::endl;
516
517 for (int i = 0; i < (int)halopong_sizes_.size(); i++) {
518 int size = halopong_sizes_[i];
519 double h_time = halopong_host_times_[i];
520 double d_time = halopong_device_times_[i];
521
522 out << prefix
523 << setw(20) << size << setw(1) << " "
524 << setw(20) << fixed << setprecision(4) << (h_time * 1e6) << setw(1) << " "
525 << setw(20) << fixed << setprecision(4) << (d_time * 1e6) << setw(1) << std::endl;
526 }
527
528 out.copyfmt(old_format);
529}
530
531/****************************************************************************************/
532/****************************************************************************************/
533/****************************************************************************************/
534
535template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
537 using exec_space = typename Node::execution_space;
538 using range_policy = Kokkos::RangePolicy<exec_space>;
539 using clock = std::chrono::high_resolution_clock;
540
541 double total_test_time = 0;
542 clock::time_point start, stop;
543 for (int i = 0; i < KERNEL_REPEATS; i++) {
544 start = clock::now();
545 Kokkos::parallel_for(
546 "empty kernel", range_policy(0, 1), KOKKOS_LAMBDA(const size_t /*j*/) {
547 ;
548 });
549 exec_space().fence();
550 stop = clock::now();
551 double my_test_time = std::chrono::duration<double>(stop - start).count();
552 total_test_time += my_test_time;
553 }
554
555 launch_and_wait_latency_ = total_test_time / KERNEL_REPEATS;
556}
557
558template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
559double
563
564template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
566 using namespace std;
567 std::ios old_format(NULL);
568 old_format.copyfmt(out);
569
570 out << prefix
571 << setw(20) << "Launch+Wait Latency (us)" << setw(1) << " "
572 << setw(20) << fixed << setprecision(4) << (launch_and_wait_latency_ * 1e6) << std::endl;
573
574 out.copyfmt(old_format);
575}
576
577} // namespace MueLu
MueLu::DefaultScalar Scalar
void print_halopong_table(std::ostream &out, const std::string &prefix="")
void halopong_make_table(int KERNEL_REPEATS, int LOG_MAX_SIZE, const RCP< const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import)
void print_launch_latency_table(std::ostream &out, const std::string &prefix="")
void print_stream_vector_table(std::ostream &out, const std::string &prefix="")
double stream_vector_copy_lookup(int SIZE_IN_BYTES)
void stream_vector_make_table(int KERNEL_REPEATS, int LOG_MAX_SIZE=20)
double latency_corrected_stream_vector_lookup(int SIZE_IN_BYTES)
void print_latency_corrected_stream_vector_table(std::ostream &out, const std::string &prefix="")
void print_stream_vector_table_impl(std::ostream &out, bool use_latency_correction, const std::string &prefix)
void pingpong_make_table(int KERNEL_REPEATS, int LOG_MAX_SIZE, const RCP< const Teuchos::Comm< int > > &comm)
double halopong_device_lookup(int SIZE_IN_BYTES_PER_MESSAGE)
double latency_corrected_stream_vector_copy_lookup(int SIZE_IN_BYTES)
double pingpong_device_lookup(int SIZE_IN_BYTES)
double pingpong_host_lookup(int SIZE_IN_BYTES)
double latency_corrected_stream_vector_add_lookup(int SIZE_IN_BYTES)
double stream_vector_add_lookup(int SIZE_IN_BYTES)
void print_pingpong_table(std::ostream &out, const std::string &prefix="")
double halopong_host_lookup(int SIZE_IN_BYTES_PER_MESSAGE)
double stream_vector_lookup(int SIZE_IN_BYTES)
void launch_latency_make_table(int KERNEL_REPEATS)
double table_lookup(const std::vector< int > &x, const std::vector< double > &y, int value)
double stream_vector_add(int KERNEL_REPEATS, int VECTOR_SIZE)
void pingpong_basic(int KERNEL_REPEATS, int MAX_SIZE, const Teuchos::Comm< int > &comm, std::vector< int > &sizes, std::vector< double > &times)
void halopong_basic(int KERNEL_REPEATS, int MAX_SIZE, const RCP< const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import, std::vector< int > &sizes, std::vector< double > &times)
double convert_time_to_bandwidth_gbs(double time, int num_calls, double memory_per_call_bytes)
double stream_vector_copy(int KERNEL_REPEATS, int VECTOR_SIZE)
Namespace for MueLu classes and methods.