MyraMath


Source: tests/jobgraph/JobID.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // JobGraph bits.
12 #include <myramath/utility/Pack.h>
15 
16 
17 // Reporting.
18 #include <tests/myratest.h>
19 
20 using namespace myra;
21 
22 namespace {
23 
24 void check2(const std::vector<int>& dim)
25  {
26  int I = dim[0];
27  int J = dim[1];
28  auto IJ = pack(I,J);
29  for (int i = 0; i < I; ++i)
30  for (int j = 0; j < J; ++j)
31  {
32  auto ij = pack(i,j);
33  JobID h(IJ,ij);
34  REQUIRE(h.unpack(IJ,0) == i);
35  REQUIRE(h.unpack(IJ,1) == j);
36  }
37  }
38 
39 void check3(const std::vector<int>& dim)
40  {
41  int I = dim[0];
42  int J = dim[1];
43  int K = dim[2];
44  auto IJK = pack(I,J,K);
45  for (int i = 0; i < I; ++i)
46  for (int j = 0; j < J; ++j)
47  for (int k = 0; k < K; ++k)
48  {
49  auto ijk = pack(i,j,k);
50  JobID h(IJK,ijk);
51  REQUIRE(h.unpack(IJK,0) == i);
52  REQUIRE(h.unpack(IJK,1) == j);
53  REQUIRE(h.unpack(IJK,2) == k);
54  }
55  }
56 
57 } // namespace
58 
59 ADD_TEST("JobID","[jobgraph]")
60  {
61  check3({2,3,6});
62  check3({3,2,6});
63  check3({2,6,3});
64  check3({3,6,2});
65  check3({6,2,3});
66  check3({6,3,2});
67 
68  check2({2,5});
69  check2({5,2});
70 
71  check2({2,4});
72  check2({4,2});
73  }
74 
Pack< T, 1 > pack(const T &a)
Factory function to make a Pack<T,1>
Definition: Pack.h:62
Definition: syntax.dox:1
Key type used to identify the Job&#39;s of a JobGraph.
Key type used to identify the Job&#39;s of a JobGraph.
Definition: JobID.h:60
Wraps a fixed size C-array. Think std::array, but before C++11.
Interface class for representing subranges of contiguous int&#39;s.


Results: [PASS]


Go back to Summary of /test programs.