22 #include "Sacado_Fad_DFad.hpp"
23 #include "Sacado_mpl_apply.hpp"
24 #include "Sacado_Random.hpp"
26 #include <Kokkos_Core.hpp>
39 template <
typename VecType,
typename FadType>
46 typedef typename Sacado::mpl::apply<FadType,VecType>::type
FadVecType;
61 template <
typename VecType>
64 const std::string& tag,
68 bool success = (x.
size() == x2.
size());
69 out << tag <<
" Vec array size test";
74 out <<
": \n\tExpected: " << x.
size() <<
", \n\tGot: " << x2.
size()
78 for (
int i=0; i<x.
size(); i++) {
79 bool success2 = Sacado::IsEqual<VecType>::eval(x[i], x2[i]);
80 out << tag <<
" Vec array comparison test " << i;
85 out <<
": \n\tExpected: " << x[i] <<
", \n\tGot: " << x2[i] <<
"."
87 success = success && success2;
93 template<
typename Ordinal>
100 out <<
"\nChecking that the above test passed in all processes ...";
101 int thisResult = ( result ? 1 : 0 );
105 const bool passed = sumResult==Teuchos::size(comm);
109 out <<
" (sumResult="<<sumResult<<
"!=numProcs="<<Teuchos::size(comm)<<
") failed\n";
113 #define VEC_COMM_TESTS(VecType, FadType, Vec, FAD) \
114 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_Broadcast ) { \
115 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
116 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
119 Teuchos::Array<VecType> x(n), x2(n); \
120 for (int i=0; i<n; i++) { \
121 x[i] = VecType(setup.sz, 0.0); \
122 for (int j=0; j<setup.sz; j++) \
123 x[i].fastAccessCoeff(j) = rnd.number(); \
125 if (comm->getRank() == 0) \
127 Teuchos::broadcast(*comm, *setup.vec_serializer, 0, n, &x2[0]); \
128 success = checkVecArrays(x, x2, std::string(#Vec)+" Broadcast", out); \
129 success = checkResultOnAllProcs(*comm, out, success); \
132 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_GatherAll ) { \
133 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
134 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
137 int size = comm->getSize(); \
138 int rank = comm->getRank(); \
140 Teuchos::Array<VecType> x(n), x2(N), x3(N); \
141 for (int i=0; i<n; i++) { \
142 x[i] = VecType(setup.sz, 0.0); \
143 for (int j=0; j<setup.sz; j++) \
144 x[i].fastAccessCoeff(j) = (rank+1)*(i+1)*(j+1); \
146 for (int j=0; j<size; j++) { \
147 for (int i=0; i<n; i++) { \
148 x3[n*j+i] = VecType(setup.sz, 0.0); \
149 for (int k=0; k<setup.sz; k++) \
150 x3[n*j+i].fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
153 Teuchos::gatherAll(*comm, *setup.vec_serializer, \
154 n, &x[0], N, &x2[0]); \
155 success = checkVecArrays(x3, x2, std::string(#Vec)+" Gather All", out); \
156 success = checkResultOnAllProcs(*comm, out, success); \
159 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_SumAll ) { \
160 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
161 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
164 int num_proc = comm->getSize(); \
166 Teuchos::Array<VecType> x(n), sums(n), sums2(n); \
167 for (int i=0; i<n; i++) { \
168 x[i] = VecType(setup.sz, 0.0); \
169 for (int j=0; j<setup.sz; j++) \
170 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
172 for (int i=0; i<n; i++) { \
173 sums[i] = VecType(setup.sz, 0.0); \
174 for (int j=0; j<setup.sz; j++) \
175 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
177 Teuchos::reduceAll(*comm, *setup.vec_serializer, \
178 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
179 success = checkVecArrays(sums, sums2, \
180 std::string(#Vec)+" Sum All", out); \
181 success = checkResultOnAllProcs(*comm, out, success); \
184 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_MaxAll ) { \
185 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
186 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
189 int rank = comm->getRank(); \
190 int num_proc = comm->getSize(); \
192 Teuchos::Array<VecType> x(n), maxs(n), maxs2(n); \
193 for (int i=0; i<n; i++) { \
194 x[i] = VecType(setup.sz, 0.0); \
195 for (int j=0; j<setup.sz; j++) \
196 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
198 for (int i=0; i<n; i++) { \
199 maxs[i] = VecType(setup.sz, 0.0); \
200 for (int j=0; j<setup.sz; j++) \
201 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
203 Teuchos::reduceAll(*comm, *setup.vec_serializer, \
204 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
205 success = checkVecArrays(maxs, maxs2, \
206 std::string(#Vec)+" Max All", out); \
207 success = checkResultOnAllProcs(*comm, out, success); \
210 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_MinAll ) { \
211 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
212 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
215 int rank = comm->getRank(); \
217 Teuchos::Array<VecType> x(n), mins(n), mins2(n); \
218 for (int i=0; i<n; i++) { \
219 x[i] = VecType(setup.sz, 0.0); \
220 for (int j=0; j<setup.sz; j++) \
221 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
223 for (int i=0; i<n; i++) { \
224 mins[i] = VecType(setup.sz, 0.0); \
225 for (int j=0; j<setup.sz; j++) \
226 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
228 Teuchos::reduceAll(*comm, *setup.vec_serializer, \
229 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
230 success = checkVecArrays(mins, mins2, \
231 std::string(#Vec)+" Min All", out); \
232 success = checkResultOnAllProcs(*comm, out, success); \
235 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_ScanSum ) { \
236 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
237 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
240 int rank = comm->getRank(); \
242 Teuchos::Array<VecType> x(n), sums(n), sums2(n); \
243 for (int i=0; i<n; i++) { \
244 x[i] = VecType(setup.sz, 0.0); \
245 for (int j=0; j<setup.sz; j++) \
246 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
248 for (int i=0; i<n; i++) { \
249 sums[i] = VecType(setup.sz, 0.0); \
250 for (int j=0; j<setup.sz; j++) \
251 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
253 Teuchos::scan(*comm, *setup.vec_serializer, \
254 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
255 success = checkVecArrays(sums, sums2, \
256 std::string(#Vec)+" Scan Sum", out); \
257 success = checkResultOnAllProcs(*comm, out, success); \
260 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_ScanMax ) { \
261 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
262 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
265 int rank = comm->getRank(); \
267 Teuchos::Array<VecType> x(n), maxs(n), maxs2(n); \
268 for (int i=0; i<n; i++) { \
269 x[i] = VecType(setup.sz, 0.0); \
270 for (int j=0; j<setup.sz; j++) \
271 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
273 for (int i=0; i<n; i++) { \
274 maxs[i] = VecType(setup.sz, 0.0); \
275 for (int j=0; j<setup.sz; j++) \
276 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
278 Teuchos::scan(*comm, *setup.vec_serializer, \
279 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
280 success = checkVecArrays(maxs, maxs2, \
281 std::string(#Vec)+" Scan Max", out); \
282 success = checkResultOnAllProcs(*comm, out, success); \
285 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_ScanMin ) { \
286 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
287 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
290 int rank = comm->getRank(); \
292 Teuchos::Array<VecType> x(n), mins(n), mins2(n); \
293 for (int i=0; i<n; i++) { \
294 x[i] = VecType(setup.sz, 0.0); \
295 for (int j=0; j<setup.sz; j++) \
296 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
298 for (int i=0; i<n; i++) { \
299 mins[i] = VecType(setup.sz, 0.0); \
300 for (int j=0; j<setup.sz; j++) \
301 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
303 Teuchos::scan(*comm, *setup.vec_serializer, \
304 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
305 success = checkVecArrays(mins, mins2, \
306 std::string(#Vec)+" Scan Min", out); \
307 success = checkResultOnAllProcs(*comm, out, success); \
310 TEUCHOS_UNIT_TEST( Vec##_Comm, Vec_SendReceive ) { \
311 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
312 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
314 int num_proc = comm->getSize(); \
315 if (num_proc > 1) { \
316 int rank = comm->getRank(); \
318 Teuchos::Array<VecType> x(n), x2(n); \
319 for (int i=0; i<n; i++) { \
320 x[i] = VecType(setup.sz, 0.0); \
321 for (int j=0; j<setup.sz; j++) \
322 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(j+1); \
326 if (rank == 0) Teuchos::send(*comm, *setup.vec_serializer, \
328 if (rank == 1) Teuchos::receive(*comm, *setup.vec_serializer, \
330 success = checkVecArrays(x, x2, \
331 std::string(#Vec)+" Send/Receive", out); \
332 success = checkResultOnAllProcs(*comm, out, success); \
338 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_Broadcast ) { \
339 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
340 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
341 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
345 Teuchos::Array<FadVecType> x(n), x2(n); \
346 for (int i=0; i<n; i++) { \
347 VecType f(setup.sz, 0.0); \
348 for (int k=0; k<setup.sz; k++) \
349 f.fastAccessCoeff(k) = rnd.number(); \
350 x[i] = FadVecType(p, f); \
351 for (int j=0; j<p; j++) { \
352 VecType g(setup.sz, 0.0); \
353 for (int k=0; k<setup.sz; k++) \
354 g.fastAccessCoeff(k) = rnd.number(); \
355 x[i].fastAccessDx(j) = g; \
358 if (comm->getRank() == 0) \
360 Teuchos::broadcast(*comm, *setup.fad_vec_serializer, 0, n, &x2[0]); \
361 success = checkVecArrays(x, x2, \
362 std::string(#FAD)+"<"+#Vec+"> Broadcast", out); \
363 success = checkResultOnAllProcs(*comm, out, success); \
366 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_GatherAll ) { \
367 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
368 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
369 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
373 int size = comm->getSize(); \
374 int rank = comm->getRank(); \
376 Teuchos::Array<FadVecType> x(n), x2(N), x3(N); \
377 for (int i=0; i<n; i++) { \
378 VecType f(setup.sz, 0.0); \
379 for (int k=0; k<setup.sz; k++) \
380 f.fastAccessCoeff(k) = (rank+1)*(i+1)*(k+1); \
381 x[i] = FadVecType(p, f); \
382 for (int j=0; j<p; j++) { \
383 x[i].fastAccessDx(j) = f; \
386 for (int j=0; j<size; j++) { \
387 for (int i=0; i<n; i++) { \
388 VecType f(setup.sz, 0.0); \
389 for (int k=0; k<setup.sz; k++) \
390 f.fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
391 x3[n*j+i] = FadVecType(p, f); \
392 for (int k=0; k<p; k++) \
393 x3[n*j+i].fastAccessDx(k) = f; \
396 Teuchos::gatherAll(*comm, *setup.fad_vec_serializer, \
397 n, &x[0], N, &x2[0]); \
398 success = checkVecArrays(x3, x2, \
399 std::string(#FAD)+"<"+#Vec+"> Gather All", out); \
400 success = checkResultOnAllProcs(*comm, out, success); \
403 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_SumAll ) { \
404 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
405 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
406 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
410 int num_proc = comm->getSize(); \
412 Teuchos::Array<FadVecType> x(n), sums(n), sums2(n); \
413 for (int i=0; i<n; i++) { \
414 VecType f(setup.sz, 0.0); \
415 for (int k=0; k<setup.sz; k++) \
416 f.fastAccessCoeff(k) = 2.0*(i+1); \
417 x[i] = FadVecType(p, f); \
418 for (int j=0; j<p; j++) { \
419 VecType g(setup.sz, 0.0); \
420 for (int k=0; k<setup.sz; k++) \
421 g.fastAccessCoeff(k) = 2.0*(i+1); \
422 x[i].fastAccessDx(j) = g; \
425 for (int i=0; i<n; i++) { \
426 VecType f(setup.sz, 0.0); \
427 for (int k=0; k<setup.sz; k++) \
428 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
429 sums[i] = FadVecType(p, f); \
430 for (int j=0; j<p; j++) { \
431 VecType g(setup.sz, 0.0); \
432 for (int k=0; k<setup.sz; k++) \
433 g.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
434 sums[i].fastAccessDx(j) = g; \
437 Teuchos::reduceAll(*comm, *setup.fad_vec_serializer, \
438 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
439 success = checkVecArrays(sums, sums2, \
440 std::string(#FAD)+"<"+#Vec+"> Sum All", out); \
441 success = checkResultOnAllProcs(*comm, out, success); \
444 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_MaxAll ) { \
445 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
446 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
447 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
451 int rank = comm->getRank(); \
452 int num_proc = comm->getSize(); \
454 Teuchos::Array<FadVecType> x(n), maxs(n), maxs2(n); \
455 for (int i=0; i<n; i++) { \
456 VecType f(setup.sz, 0.0); \
457 for (int k=0; k<setup.sz; k++) \
458 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
459 x[i] = FadVecType(p, f); \
460 for (int j=0; j<p; j++) { \
461 x[i].fastAccessDx(j) = f; \
464 for (int i=0; i<n; i++) { \
465 VecType f(setup.sz, 0.0); \
466 for (int k=0; k<setup.sz; k++) \
467 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
468 maxs[i] = FadVecType(p, f); \
469 for (int j=0; j<p; j++) \
470 maxs[i].fastAccessDx(j) = f; \
472 Teuchos::reduceAll(*comm, *setup.fad_vec_serializer, \
473 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
474 success = checkVecArrays(maxs, maxs2, \
475 std::string(#FAD)+"<"+#Vec+"> Max All", out); \
476 success = checkResultOnAllProcs(*comm, out, success); \
479 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_MinAll ) { \
480 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
481 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
482 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
486 int rank = comm->getRank(); \
488 Teuchos::Array<FadVecType> x(n), mins(n), mins2(n); \
489 for (int i=0; i<n; i++) { \
490 VecType f(setup.sz, 0.0); \
491 for (int k=0; k<setup.sz; k++) \
492 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
493 x[i] = FadVecType(p, f); \
494 for (int j=0; j<p; j++) { \
495 x[i].fastAccessDx(j) = f; \
498 for (int i=0; i<n; i++) { \
499 VecType f(setup.sz, 0.0); \
500 for (int k=0; k<setup.sz; k++) \
501 f.fastAccessCoeff(k) = 2.0*(i+1); \
502 mins[i] = FadVecType(p, f); \
503 for (int j=0; j<p; j++) \
504 mins[i].fastAccessDx(j) = f; \
506 Teuchos::reduceAll(*comm, *setup.fad_vec_serializer, \
507 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
508 success = checkVecArrays(mins, mins2, \
509 std::string(#FAD)+"<"+#Vec+"> Min All", out); \
510 success = checkResultOnAllProcs(*comm, out, success); \
513 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_ScanSum ) { \
514 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
515 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
516 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
520 int rank = comm->getRank(); \
522 Teuchos::Array<FadVecType> x(n), sums(n), sums2(n); \
523 for (int i=0; i<n; i++) { \
524 VecType f(setup.sz, 0.0); \
525 for (int k=0; k<setup.sz; k++) \
526 f.fastAccessCoeff(k) = 2.0*(i+1); \
527 x[i] = FadVecType(p, f); \
528 for (int j=0; j<p; j++) { \
529 x[i].fastAccessDx(j) = f; \
532 for (int i=0; i<n; i++) { \
533 VecType f(setup.sz, 0.0); \
534 for (int k=0; k<setup.sz; k++) \
535 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
536 sums[i] = FadVecType(p, f); \
537 for (int j=0; j<p; j++) \
538 sums[i].fastAccessDx(j) = f; \
540 Teuchos::scan(*comm, *setup.fad_vec_serializer, \
541 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
542 success = checkVecArrays(sums, sums2, \
543 std::string(#FAD)+"<"+#Vec+"> Scan Sum", out); \
544 success = checkResultOnAllProcs(*comm, out, success); \
547 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_ScanMax ) { \
548 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
549 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
550 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
554 int rank = comm->getRank(); \
556 Teuchos::Array<FadVecType> x(n), maxs(n), maxs2(n); \
557 for (int i=0; i<n; i++) { \
558 VecType f(setup.sz, 0.0); \
559 for (int k=0; k<setup.sz; k++) \
560 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
561 x[i] = FadVecType(p, f); \
562 for (int j=0; j<p; j++) { \
563 x[i].fastAccessDx(j) = f; \
566 for (int i=0; i<n; i++) { \
567 VecType f(setup.sz, 0.0); \
568 for (int k=0; k<setup.sz; k++) \
569 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
570 maxs[i] = FadVecType(p, f); \
571 for (int j=0; j<p; j++) \
572 maxs[i].fastAccessDx(j) = f; \
574 Teuchos::scan(*comm, *setup.fad_vec_serializer, \
575 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
576 success = checkVecArrays(maxs, maxs2, \
577 std::string(#FAD)+"<"+#Vec+"> Scan Max", out); \
578 success = checkResultOnAllProcs(*comm, out, success); \
581 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_ScanMin ) { \
582 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
583 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
584 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
588 int rank = comm->getRank(); \
590 Teuchos::Array<FadVecType> x(n), mins(n), mins2(n); \
591 for (int i=0; i<n; i++) { \
592 VecType f(setup.sz, 0.0); \
593 for (int k=0; k<setup.sz; k++) \
594 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
595 x[i] = FadVecType(p, f); \
596 for (int j=0; j<p; j++) { \
597 x[i].fastAccessDx(j) = f; \
600 for (int i=0; i<n; i++) { \
601 VecType f(setup.sz, 0.0); \
602 for (int k=0; k<setup.sz; k++) \
603 f.fastAccessCoeff(k) = 2.0*(i+1); \
604 mins[i] = FadVecType(p, f); \
605 for (int j=0; j<p; j++) \
606 mins[i].fastAccessDx(j) = f; \
608 Teuchos::scan(*comm, *setup.fad_vec_serializer, \
609 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
610 success = checkVecArrays(mins, mins2, \
611 std::string(#FAD)+"<"+#Vec+"> Scan Min", out); \
612 success = checkResultOnAllProcs(*comm, out, success); \
615 TEUCHOS_UNIT_TEST( Vec##_Comm, FadVec_SendReceive ) { \
616 typedef Sacado::mpl::apply<FadType,VecType>::type FadVecType; \
617 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
618 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
620 int num_proc = comm->getSize(); \
621 if (num_proc > 1) { \
622 int rank = comm->getRank(); \
625 Teuchos::Array<FadVecType> x(n), x2(n); \
626 for (int i=0; i<n; i++) { \
627 VecType f(setup.sz, 0.0); \
628 for (int k=0; k<setup.sz; k++) \
629 f.fastAccessCoeff(k) = 2.0*(i+1)*(k+1); \
630 x[i] = FadVecType(p, f); \
631 for (int j=0; j<p; j++) \
632 x[i].fastAccessDx(j) = f; \
636 if (rank == 0) Teuchos::send(*comm, *setup.fad_vec_serializer, \
638 if (rank == 1) Teuchos::receive(*comm, *setup.fad_vec_serializer, \
640 success = checkVecArrays(x, x2, \
641 std::string(#FAD)+"<"+#Vec+"> Send/Receive", out); \
642 success = checkResultOnAllProcs(*comm, out, success); \
648 namespace DynamicVecTest {
649 Sacado::Random<double>
rnd;
659 namespace DynamicStridedVecTest {
660 Sacado::Random<double>
rnd;
670 namespace StaticVecTest {
671 Sacado::Random<double>
rnd;
681 namespace StaticFixedVecTest {
682 Sacado::Random<double>
rnd;
Sacado::Fad::DFad< double > fad_type
UnitTestSetup< vec_type, fad_type > setup
Stokhos::StaticFixedStorage< int, double, 8, execution_space > storage_type
Kokkos::DefaultExecutionSpace execution_space
Sacado::Random< double > rnd
Statically allocated storage class.
Sacado::Fad::DFad< double > fad_type
#define VEC_COMM_TESTS(VecType, FadType, Vec, FAD)
Kokkos::DefaultExecutionSpace execution_space
UnitTestSetup< vec_type, fad_type > setup
Teuchos::ValueTypeSerializer< int, VecType > VecSerializerT
Sacado::Fad::DFad< double > fad_type
Stokhos::DynamicStorage< int, double, execution_space > storage_type
UnitTestSetup< vec_type, fad_type > setup
Stokhos::DynamicStridedStorage< int, double, execution_space > storage_type
Stokhos::StaticStorage< int, double, 8, execution_space > storage_type
Sacado::MP::Vector< storage_type > vec_type
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< VecSerializerT > vec_serializer
Sacado::Random< double > rnd
Teuchos::ValueTypeSerializer< int, FadVecType > FadVecSerializerT
UnitTestSetup< vec_type, fad_type > setup
Kokkos::DefaultExecutionSpace execution_space
Sacado::Random< double > rnd
int main(int argc, char **argv)
Kokkos::DefaultExecutionSpace execution_space
Sacado::MP::Vector< storage_type > vec_type
Sacado::MP::Vector< storage_type > vec_type
Sacado::mpl::apply< FadType, VecType >::type FadVecType
bool checkResultOnAllProcs(const Teuchos::Comm< Ordinal > &comm, Teuchos::FancyOStream &out, const bool result)
Sacado::MP::Vector< storage_type > vec_type
Sacado::Random< double > rnd
Statically allocated storage class.
bool checkVecArrays(const Teuchos::Array< VecType > &x, const Teuchos::Array< VecType > &x2, const std::string &tag, Teuchos::FancyOStream &out)
Sacado::Fad::DFad< double > fad_type
RCP< FadVecSerializerT > fad_vec_serializer