OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TableFunctions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, 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 #include "../../Shared/funcannotations.h"
18 
19 #define EXTENSION_INLINE extern "C" ALWAYS_INLINE DEVICE
20 #define EXTENSION_NOINLINE extern "C" NEVER_INLINE DEVICE
21 
22 #ifdef __CUDACC__
23 
24 EXTENSION_INLINE int32_t row_copier_kernel(double* input_col,
25  int* copy_multiplier,
26  const int64_t input_row_count,
27  int64_t* output_row_count,
28  double* output_buffer) {
29  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
30  int32_t step = blockDim.x * gridDim.x;
31  for (int32_t i = start; i < static_cast<int32_t>(input_row_count); i += step) {
32  for (int c = 0; c < *copy_multiplier; c++) {
33  output_buffer[i + (c * input_row_count)] = input_col[i];
34  }
35  }
36  return 0;
37 }
38 
39 #endif
40 
41 EXTENSION_NOINLINE int32_t row_copier(double* input_col,
42  int* copy_multiplier,
43  const int64_t* input_row_count_ptr,
44  int64_t* output_row_count,
45  double* output_buffer) {
46 #ifdef __CUDACC__
47  return row_copier_kernel(
48  input_col, copy_multiplier, *input_row_count_ptr, output_row_count, output_buffer);
49 #else
50  // Copy the input buffer to the output, duplicating according to copy_multiplier
51  const auto input_row_count = *input_row_count_ptr;
52 
53  for (auto i = 0; i < input_row_count; i++) {
54  for (int c = 0; c < *copy_multiplier; c++) {
55  output_buffer[i + (c * input_row_count)] = input_col[i];
56  }
57  }
58 
59  *output_row_count = (*copy_multiplier) * input_row_count;
60  return 0;
61 #endif
62 }
#define EXTENSION_INLINE
EXTENSION_NOINLINE int32_t row_copier(double *input_col, int *copy_multiplier, const int64_t *input_row_count_ptr, int64_t *output_row_count, double *output_buffer)
#define EXTENSION_NOINLINE