OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BufferEntryUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, 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 
17 /*
18  * @file BufferEntryUtils.h
19  * @author Minggang Yu <miyu@mapd.com>
20  * @brief Utility functions for group by buffer entries
21  *
22  * Copyright (c) 2017 MapD Technologies, Inc. All rights reserved.
23  */
24 #ifndef QUERYENGINE_BUFFERENTRYUTILS_H
25 #define QUERYENGINE_BUFFERENTRYUTILS_H
26 
27 #include "../Shared/funcannotations.h"
28 #include "GpuRtConstants.h"
29 
30 #ifdef FORCE_CPU_VERSION
31 #undef DEVICE
32 #define DEVICE
33 #undef INLINE
34 #define INLINE inline
35 #else
36 #define INLINE
37 #endif
38 
39 namespace {
40 
41 template <class K>
42 INLINE DEVICE bool is_empty_entry(const size_t entry_idx,
43  const int8_t* groupby_buffer,
44  const size_t key_stride);
45 
46 template <>
47 INLINE DEVICE bool is_empty_entry<int32_t>(const size_t entry_idx,
48  const int8_t* groupby_buffer,
49  const size_t key_stride) {
50  const auto key_ptr = groupby_buffer + entry_idx * key_stride;
51  return (*reinterpret_cast<const int32_t*>(key_ptr) == EMPTY_KEY_32);
52 }
53 
54 template <>
55 INLINE DEVICE bool is_empty_entry<int64_t>(const size_t entry_idx,
56  const int8_t* groupby_buffer,
57  const size_t key_stride) {
58  const auto key_ptr = groupby_buffer + entry_idx * key_stride;
59  return (*reinterpret_cast<const int64_t*>(key_ptr) == EMPTY_KEY_64);
60 }
61 
62 } // namespace
63 
64 #undef INLINE
65 #undef DEVICE
66 
67 #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)