OmniSciDB  04ee39c94c
CompareKeysInl.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 #pragma once
18 
19 #ifdef __CUDACC__
20 #include "GpuRtConstants.h"
21 #else
22 #include "RuntimeFunctions.h"
23 #endif // __CUDACC__
24 #include <cstdlib>
25 #include "../Shared/funcannotations.h"
26 
27 template <typename T = int64_t>
29  return EMPTY_KEY_64;
30 }
31 
32 template <>
33 inline DEVICE int32_t SUFFIX(get_invalid_key)() {
34  return EMPTY_KEY_32;
35 }
36 
37 #ifdef __CUDACC__
38 template <typename T>
39 inline __device__ bool keys_are_equal(const T* key1,
40  const T* key2,
41  const size_t key_component_count) {
42  for (size_t i = 0; i < key_component_count; ++i) {
43  if (key1[i] != key2[i]) {
44  return false;
45  }
46  }
47  return true;
48 }
49 #else
50 #include <cstring>
51 
52 template <typename T>
53 inline bool keys_are_equal(const T* key1,
54  const T* key2,
55  const size_t key_component_count) {
56  return memcmp(key1, key2, key_component_count * sizeof(T)) == 0;
57 }
58 #endif // __CUDACC__
#define EMPTY_KEY_64
bool keys_are_equal(const T *key1, const T *key2, const size_t key_component_count)
#define SUFFIX(name)
#define DEVICE
DEVICE T SUFFIX() get_invalid_key()
#define EMPTY_KEY_32