PandaRoot
PndCADef.h
Go to the documentation of this file.
1 //-*- Mode: C++ -*-
2 
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
5 //* See cxx source for full Copyright notice *
6 
7 #ifndef PNDCADEF_H
8 #define PNDCADEF_H
9 
10 #include <iostream>
11 using std::cout;
12 using std::endl;
13 
14 #include <Vc/Vc>
15 #include <Vc/limits>
16 
17 using ::Vc::double_v;
18 using ::Vc::float_v;
19 // using ::Vc::sfloat_v;
20 using ::Vc::int_v;
21 using ::Vc::uint_v;
22 // using ::Vc::short_v;
23 // using ::Vc::ushort_v;
24 using ::Vc::double_m;
25 using ::Vc::float_m;
26 using ::Vc::VectorAlignment;
27 // using ::Vc::sfloat_m;
28 using ::Vc::int_m;
29 using ::Vc::uint_m;
30 // using ::Vc::short_m;
31 // using ::Vc::ushort_m;
32 
38 #if defined(HLTCA_STANDALONE)
39 typedef unsigned char UChar_t;
40 typedef UChar_t Byte_t;
41 typedef int Int_t;
42 typedef double Double_t;
43 #else
44 #include "Rtypes.h"
45 #endif
46 
47 // according to http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c
48 template <typename T>
49 int sign(T val)
50 {
51  return (T(0) < val) - (val < T(0));
52 }
53 
54 #ifdef NDEBUG
55 #define ASSERT(v, msg)
56 #else
57 #define ASSERT(v, msg) \
58  if (v) { \
59  } else { \
60  std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " << #v << " = " << (v) << "\n" << msg << std::endl; \
61  abort(); \
62  }
63 #endif
64 
65 struct float2 {
66  float x;
67  float y;
68 };
69 /*
70  * Helper for compile-time verification of correct API usage
71  */
72 namespace {
73 template <bool>
74 struct HLTTPCCA_STATIC_ASSERT_FAILURE;
75 template <>
76 struct HLTTPCCA_STATIC_ASSERT_FAILURE<true> {
77 };
78 } // namespace
79 
80 #define HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b) a##b
81 #define HLTTPCCA_STATIC_ASSERT_CONCAT(a, b) HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b)
82 #define STATIC_ASSERT(cond, msg) \
83  typedef HLTTPCCA_STATIC_ASSERT_FAILURE<cond> HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__); \
84  HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__) Error_##msg; \
85  (void)Error_##msg
86 
87 namespace {
88 template <typename T1>
89 void UNUSED_PARAM1(const T1 &)
90 {
91 }
92 template <typename T1, typename T2>
93 void UNUSED_PARAM2(const T1 &, const T2 &)
94 {
95 }
96 template <typename T1, typename T2, typename T3>
97 void UNUSED_PARAM3(const T1 &, const T2 &, const T3 &)
98 {
99 }
100 template <typename T1, typename T2, typename T3, typename T4>
101 void UNUSED_PARAM4(const T1 &, const T2 &, const T3 &, const T4 &)
102 {
103 }
104 template <typename T1, typename T2, typename T3, typename T4, typename T5>
105 void UNUSED_PARAM5(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)
106 {
107 }
108 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
109 void UNUSED_PARAM6(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)
110 {
111 }
112 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
113 void UNUSED_PARAM7(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)
114 {
115 }
116 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
117 void UNUSED_PARAM8(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)
118 {
119 }
120 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
121 void UNUSED_PARAM9(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &, const T9 &)
122 {
123 }
124 } // namespace
125 
126 #define unrolled_loop4(_type_, _it_, _start_, _end_, _code_) \
127  if (_start_ + 0 < _end_) { \
128  enum { _it_ = (_start_ + 0) < _end_ ? (_start_ + 0) : _start_ }; \
129  _code_ \
130  } \
131  if (_start_ + 1 < _end_) { \
132  enum { _it_ = (_start_ + 1) < _end_ ? (_start_ + 1) : _start_ }; \
133  _code_ \
134  } \
135  if (_start_ + 2 < _end_) { \
136  enum { _it_ = (_start_ + 2) < _end_ ? (_start_ + 2) : _start_ }; \
137  _code_ \
138  } \
139  if (_start_ + 3 < _end_) { \
140  enum { _it_ = (_start_ + 3) < _end_ ? (_start_ + 3) : _start_ }; \
141  _code_ \
142  } \
143  do { \
144  } while (false)
145 
146 #ifdef __GNUC__
147 #define MAY_ALIAS __attribute__((__may_alias__))
148 #else
149 #define MAY_ALIAS
150 #endif
151 
152 #if defined(__GNUC__) && __GNUC__ - 0 >= 3
153 #define ISLIKELY(x) __builtin_expect(!!(x), 1)
154 #define ISUNLIKELY(x) __builtin_expect(!!(x), 0)
155 #else
156 #define ISLIKELY(x) (x)
157 #define ISUNLIKELY(x) (x)
158 #endif
159 
160 #endif
float x
Definition: PndCADef.h:66
float y
Definition: PndCADef.h:67
int sign(T val)
Definition: PndCADef.h:49