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