OmniSciDB  04ee39c94c
udf_sample.cpp
Go to the documentation of this file.
1 #include <cstdint>
2 #if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
3 #define DEVICE __device__
4 #else
5 #define DEVICE
6 #endif
7 
8 #if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
9 #define NEVER_INLINE
10 #else
11 #define NEVER_INLINE __attribute__((noinline))
12 #endif
13 
14 #if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
15 #define ALWAYS_INLINE
16 #else
17 #define ALWAYS_INLINE __attribute__((always_inline))
18 #endif
19 
20 #define EXTENSION_NOINLINE extern "C" NEVER_INLINE DEVICE
21 
22 #define EXTENSION_INLINE extern "C" ALWAYS_INLINE DEVICE
23 
25 double udf_range(const double high_price, const double low_price) {
26  return high_price - low_price;
27 }
28 
30 int64_t udf_range_int(const int64_t high_price, const int64_t low_price) {
31  return high_price - low_price;
32 }
33 
35 double udf_truehigh(const double high_price, const double prev_close_price) {
36  return (high_price < prev_close_price) ? prev_close_price : high_price;
37 }
38 
40 double udf_truelow(const double low_price, const double prev_close_price) {
41  return !(prev_close_price < low_price) ? low_price : prev_close_price;
42 }
43 
45 double udf_truerange(const double high_price,
46  const double low_price,
47  const double prev_close_price) {
48  return (udf_truehigh(high_price, prev_close_price) -
49  udf_truelow(low_price, prev_close_price));
50 }
EXTENSION_NOINLINE double udf_truelow(const double low_price, const double prev_close_price)
Definition: udf_sample.cpp:40
EXTENSION_NOINLINE double udf_truerange(const double high_price, const double low_price, const double prev_close_price)
Definition: udf_sample.cpp:45
EXTENSION_NOINLINE double udf_range(const double high_price, const double low_price)
Definition: udf_sample.cpp:25
#define EXTENSION_NOINLINE
Definition: udf_sample.cpp:20
EXTENSION_NOINLINE int64_t udf_range_int(const int64_t high_price, const int64_t low_price)
Definition: udf_sample.cpp:30
EXTENSION_NOINLINE double udf_truehigh(const double high_price, const double prev_close_price)
Definition: udf_sample.cpp:35