StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCADef.h
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 ALIHLTTPCCADEF_H
8 #define ALIHLTTPCCADEF_H
9 
10 
16 // ----- Vc -----
17 
18 #include <Vc/Vc>
19 #include <Vc/limits>
20 
21 using ::Vc::double_v;
22 using ::Vc::float_v;
23 using ::Vc::sfloat_v;
24 using ::Vc::int_v;
25 using ::Vc::uint_v;
26 using ::Vc::short_v;
27 using ::Vc::ushort_v;
28 using ::Vc::VectorAlignment;
29 using ::Vc::double_m;
30 using ::Vc::float_m;
31 using ::Vc::sfloat_m;
32 using ::Vc::int_m;
33 using ::Vc::uint_m;
34 using ::Vc::short_m;
35 using ::Vc::ushort_m;
36 using ::Vc::atan2;
37 using ::Vc::asin;
38 using ::Vc::round;
39 using ::Vc::isfinite;
40 
41 static inline ushort_m validHitIndexes( const ushort_v &v )
42 {
43  return static_cast<short_v>( v ) >= short_v( Vc::Zero );
44 }
45 
46 #ifdef USE_TBB
47 // static void AtomicMax( unsigned int volatile *addr, uint_v val ) {
48 // for ( int i = 0; i < uint_v::Size; ++i ) {
49 // AtomicMax( &addr[i], val[i] );
50 // }
51 // }
52 #endif //USE_TBB
53 
54 
55 #if defined(HLTCA_STANDALONE)
56 typedef unsigned char UChar_t;
57 typedef UChar_t Byte_t;
58 typedef int Int_t;
59 typedef double Double_t;
60 #else
61 #include "Rtypes.h"
62 #endif
63 
64 
65 #ifdef NDEBUG
66 #define ASSERT(v, msg)
67 #else
68 #define ASSERT(v, msg) \
69 if (v) {} else { \
70  std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " \
71  << #v << " = " << (v) << "\n" << msg << std::endl; \
72  abort(); \
73 }
74 #endif
75 
76 
77 struct float2 { float x; float y; };
78 /*
79  * Helper for compile-time verification of correct API usage
80  */
81 namespace
82 {
83  template<bool> struct HLTTPCCA_STATIC_ASSERT_FAILURE;
84  template<> struct HLTTPCCA_STATIC_ASSERT_FAILURE<true> {};
85 }
86 
87 #define HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b) a##b
88 #define HLTTPCCA_STATIC_ASSERT_CONCAT(a, b) HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b)
89 #define STATIC_ASSERT(cond, msg) \
90  typedef HLTTPCCA_STATIC_ASSERT_FAILURE<cond> HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__); \
91  HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__) Error_##msg; \
92  (void) Error_##msg
93 
94 namespace
95 {
96  template<typename T1>
97  void UNUSED_PARAM1( const T1 & ) {}
98  template<typename T1, typename T2>
99  void UNUSED_PARAM2( const T1 &, const T2 & ) {}
100  template<typename T1, typename T2, typename T3>
101  void UNUSED_PARAM3( const T1 &, const T2 &, const T3 & ) {}
102  template<typename T1, typename T2, typename T3, typename T4>
103  void UNUSED_PARAM4( const T1 &, const T2 &, const T3 &, const T4 & ) {}
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  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
107  void UNUSED_PARAM6( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 & ) {}
108  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
109  void UNUSED_PARAM7( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 & ) {}
110  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
111  void UNUSED_PARAM8( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 & ) {}
112  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
113  void UNUSED_PARAM9( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &, const T9 & ) {}
114 }
115 
116 #define unrolled_loop4( _type_, _it_, _start_, _end_, _code_ ) \
117 if (_start_ + 0 < _end_) { enum { _it_ = (_start_ + 0) < _end_ ? (_start_ + 0) : _start_ }; _code_ } \
118 if (_start_ + 1 < _end_) { enum { _it_ = (_start_ + 1) < _end_ ? (_start_ + 1) : _start_ }; _code_ } \
119 if (_start_ + 2 < _end_) { enum { _it_ = (_start_ + 2) < _end_ ? (_start_ + 2) : _start_ }; _code_ } \
120 if (_start_ + 3 < _end_) { enum { _it_ = (_start_ + 3) < _end_ ? (_start_ + 3) : _start_ }; _code_ } \
121 do {} while ( false )
122 
123 #ifdef __GNUC__
124 #define MAY_ALIAS __attribute__((__may_alias__))
125 #else
126 #define MAY_ALIAS
127 #endif
128 
129 #if defined( __GNUC__ ) && __GNUC__ - 0 >= 3
130 # define ISLIKELY( x ) __builtin_expect( !!( x ),1 )
131 # define ISUNLIKELY( x ) __builtin_expect( !!( x ),0 )
132 #else
133 # define ISLIKELY( x ) ( x )
134 # define ISUNLIKELY( x ) ( x )
135 #endif
136 
137 #endif