OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BufferEntryUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 #ifndef QUERYENGINE_BUFFERENTRYUTILS_H
24 #define QUERYENGINE_BUFFERENTRYUTILS_H
25 
26 #include "../Shared/funcannotations.h"
27 #include "GpuRtConstants.h"
28 
29 #ifdef FORCE_CPU_VERSION
30 #undef DEVICE
31 #define DEVICE
32 #undef INLINE
33 #define INLINE inline
34 #else
35 #define INLINE
36 #endif
37 
38 namespace {
39 
40 template <class K>
41 INLINE DEVICE bool is_empty_entry(const size_t entry_idx,
42  const int8_t* groupby_buffer,
43  const size_t key_stride);
44 
45 template <>
46 INLINE DEVICE bool is_empty_entry<int32_t>(const size_t entry_idx,
47  const int8_t* groupby_buffer,
48  const size_t key_stride) {
49  const auto key_ptr = groupby_buffer + entry_idx * key_stride;
50  return (*reinterpret_cast<const int32_t*>(key_ptr) == EMPTY_KEY_32);
51 }
52 
53 template <>
54 INLINE DEVICE bool is_empty_entry<int64_t>(const size_t entry_idx,
55  const int8_t* groupby_buffer,
56  const size_t key_stride) {
57  const auto key_ptr = groupby_buffer + entry_idx * key_stride;
58  return (*reinterpret_cast<const int64_t*>(key_ptr) == EMPTY_KEY_64);
59 }
60 
61 } // namespace
62 
63 #undef INLINE
64 #undef DEVICE
65 
66 #endif // QUERYENGINE_BUFFERENTRYUTILS_H
#define EMPTY_KEY_64
#define DEVICE
INLINE DEVICE bool is_empty_entry< int32_t >(const size_t entry_idx, const int8_t *groupby_buffer, const size_t key_stride)
#define INLINE
INLINE DEVICE bool is_empty_entry(const size_t entry_idx, const int8_t *groupby_buffer, const size_t key_stride)
#define EMPTY_KEY_32
INLINE DEVICE bool is_empty_entry< int64_t >(const size_t entry_idx, const int8_t *groupby_buffer, const size_t key_stride)