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