blitz  Version 1.0.2
bounds.h
Go to the documentation of this file.
1 #ifndef BZ_BOUNDS_H
2 #define BZ_BOUNDS_H
3 
4 #include <blitz/blitz.h>
5 
6 namespace blitz {
7 
8 struct bounds {
9  static int compute_ascending(const int BZ_DEBUG_PARAM(rank),
10  const int ascending1, const int ascending2)
11  {
12  // The value INT_MIN indicates that there are no arrays
13  // in a subtree of the expression. This logic returns
14  // whichever ascending is available. If there are two
15  // conflicting ascending values, this is an error.
16 
17  if (ascending1 == ascending2)
18  return ascending1;
19  else if (ascending1 == INT_MIN)
20  return ascending2;
21  else if (ascending2 == INT_MIN)
22  return ascending1;
23 
24  BZ_DEBUG_MESSAGE("Two array operands have different"
25  << endl << "ascending flags: for rank " << rank
26  << ", the flags are " << ascending1 << " and "
27  << ascending2 << endl);
28  BZ_PRE_FAIL;
29  return 0;
30  }
31 
32  static int compute_ordering(const int BZ_DEBUG_PARAM(rank),
33  const int order1, const int order2)
34  {
35  // The value INT_MIN indicates that there are no arrays
36  // in a subtree of the expression. This logic returns
37  // whichever ordering is available. If there are two
38  // conflicting ordering values, this is an error.
39 
40  if (order1 == order2)
41  return order1;
42  else if (order1 == INT_MIN)
43  return order2;
44  else if (order2 == INT_MIN)
45  return order1;
46 
47  BZ_DEBUG_MESSAGE("Two array operands have different"
48  << endl << "orders: for rank " << rank << ", the orders are "
49  << order1 << " and " << order2 << endl);
50  BZ_PRE_FAIL;
51  return 0;
52  }
53 
54  static int compute_lbound(const int BZ_DEBUG_PARAM(rank),
55  const int lbound1, const int lbound2)
56  {
57  // The value INT_MIN indicates that there are no arrays
58  // in a subtree of the expression. This logic returns
59  // whichever lbound is available. If there are two
60  // conflicting lbound values, this is an error.
61 
62  if (lbound1 == lbound2)
63  return lbound1;
64  else if (lbound1 == INT_MIN)
65  return lbound2;
66  else if (lbound2 == INT_MIN)
67  return lbound1;
68 
69  BZ_DEBUG_MESSAGE("Two array operands have different"
70  << endl << "lower bounds: in rank " << rank << ", the bounds are "
71  << lbound1 << " and " << lbound2 << endl);
72  BZ_PRE_FAIL;
73  return 0;
74  }
75 
76  static int compute_ubound(const int BZ_DEBUG_PARAM(rank),
77  const int ubound1, const int ubound2)
78  {
79  // The value INT_MAX indicates that there are no arrays
80  // in a subtree of the expression. This logic returns
81  // whichever ubound is available. If there are two
82  // conflicting ubound values, this is an error.
83 
84  if (ubound1 == ubound2)
85  return ubound1;
86  else if (ubound1 == INT_MAX)
87  return ubound2;
88  else if (ubound2 == INT_MAX)
89  return ubound1;
90 
91  BZ_DEBUG_MESSAGE("Two array operands have different"
92  << endl << "upper bounds: in rank " << rank << ", the bounds are "
93  << ubound1 << " and " << ubound2 << endl);
94  BZ_PRE_FAIL;
95  return 0;
96  }
97 };
98 
99 }
100 
101 #endif
static int compute_ubound(const int BZ_DEBUG_PARAM(rank), const int ubound1, const int ubound2)
Definition: bounds.h:76
Definition: bounds.h:8
Definition: array-impl.h:66
static int compute_ordering(const int BZ_DEBUG_PARAM(rank), const int order1, const int order2)
Definition: bounds.h:32
static int compute_lbound(const int BZ_DEBUG_PARAM(rank), const int lbound1, const int lbound2)
Definition: bounds.h:54
static int compute_ascending(const int BZ_DEBUG_PARAM(rank), const int ascending1, const int ascending2)
Definition: bounds.h:9