PandaRoot
PndFTSCADef.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 PNDFTSCADEF_H
8 #define PNDFTSCADEF_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::double_m;
21 using ::Vc::float_m;
22 using ::Vc::int_v;
23 using ::Vc::short_v;
24 using ::Vc::uint_v;
25 using ::Vc::ushort_v;
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(FTSCA_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 template <typename T>
55 T rcp(T val)
56 {
57  return reciprocal(val);
58 }
59 
60 #ifdef NDEBUG
61 #define ASSERT(v, msg)
62 #else
63 #define ASSERT(v, msg) \
64  if (v) { \
65  } else { \
66  std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " << #v << " = " << (v) << "\n" << msg << std::endl; \
67  abort(); \
68  }
69 #endif
70 
71 struct float2 {
72  float x;
73  float y;
74 };
75 /*
76  * Helper for compile-time verification of correct API usage
77  */
78 namespace {
79 template <bool>
80 struct FTSCA_STATIC_ASSERT_FAILURE;
81 template <>
82 struct FTSCA_STATIC_ASSERT_FAILURE<true> {
83 };
84 } // namespace
85 
86 #define FTSCA_STATIC_ASSERT_CONCAT_HELPER(a, b) a##b
87 #define FTSCA_STATIC_ASSERT_CONCAT(a, b) FTSCA_STATIC_ASSERT_CONCAT_HELPER(a, b)
88 #define STATIC_ASSERT(cond, msg) \
89  typedef FTSCA_STATIC_ASSERT_FAILURE<cond> FTSCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__); \
90  FTSCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__) Error_##msg; \
91  (void)Error_##msg
92 
93 namespace {
94 template <typename T1>
95 void UNUSED_PARAM1(const T1 &)
96 {
97 }
98 template <typename T1, typename T2>
99 void UNUSED_PARAM2(const T1 &, const T2 &)
100 {
101 }
102 template <typename T1, typename T2, typename T3>
103 void UNUSED_PARAM3(const T1 &, const T2 &, const T3 &)
104 {
105 }
106 template <typename T1, typename T2, typename T3, typename T4>
107 void UNUSED_PARAM4(const T1 &, const T2 &, const T3 &, const T4 &)
108 {
109 }
110 template <typename T1, typename T2, typename T3, typename T4, typename T5>
111 void UNUSED_PARAM5(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)
112 {
113 }
114 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
115 void UNUSED_PARAM6(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)
116 {
117 }
118 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
119 void UNUSED_PARAM7(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)
120 {
121 }
122 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
123 void UNUSED_PARAM8(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)
124 {
125 }
126 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
127 void UNUSED_PARAM9(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &, const T9 &)
128 {
129 }
130 } // namespace
131 
132 #define unrolled_loop4(_type_, _it_, _start_, _end_, _code_) \
133  if (_start_ + 0 < _end_) { \
134  enum { _it_ = (_start_ + 0) < _end_ ? (_start_ + 0) : _start_ }; \
135  _code_ \
136  } \
137  if (_start_ + 1 < _end_) { \
138  enum { _it_ = (_start_ + 1) < _end_ ? (_start_ + 1) : _start_ }; \
139  _code_ \
140  } \
141  if (_start_ + 2 < _end_) { \
142  enum { _it_ = (_start_ + 2) < _end_ ? (_start_ + 2) : _start_ }; \
143  _code_ \
144  } \
145  if (_start_ + 3 < _end_) { \
146  enum { _it_ = (_start_ + 3) < _end_ ? (_start_ + 3) : _start_ }; \
147  _code_ \
148  } \
149  do { \
150  } while (false)
151 
152 #ifdef __GNUC__
153 #define MAY_ALIAS __attribute__((__may_alias__))
154 #else
155 #define MAY_ALIAS
156 #endif
157 
158 #if defined(__GNUC__) && __GNUC__ - 0 >= 3
159 #define ISLIKELY(x) __builtin_expect(!!(x), 1)
160 #define ISUNLIKELY(x) __builtin_expect(!!(x), 0)
161 #else
162 #define ISLIKELY(x) (x)
163 #define ISUNLIKELY(x) (x)
164 #endif
165 
166 #endif
float x
Definition: PndCADef.h:66
int sign(T val)
Definition: PndFTSCADef.h:49
T rcp(T val)
Definition: PndFTSCADef.h:55
float y
Definition: PndCADef.h:67