OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GpuMemUtils.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 #ifndef QUERYENGINE_GPUMEMUTILS_H
18 #define QUERYENGINE_GPUMEMUTILS_H
19 
20 #include "CompilationOptions.h"
21 
22 #include <cstddef>
23 #include <cstdint>
24 #include <memory>
25 #include <utility>
26 #include <vector>
27 
28 #ifdef HAVE_CUDA
29 #include <cuda.h>
30 #else
31 #include "../Shared/nocuda.h"
32 #endif // HAVE_CUDA
33 
34 namespace CudaMgr_Namespace {
35 
36 class CudaMgr;
37 
38 } // namespace CudaMgr_Namespace
39 
40 namespace Data_Namespace {
41 
42 class AbstractBuffer;
43 class DataMgr;
44 
45 } // namespace Data_Namespace
46 
47 class DeviceAllocator;
48 
50  CUdeviceptr dst,
51  const void* src,
52  const size_t num_bytes,
53  const int device_id);
54 
56  int8_t* ptrs; // ptrs for individual outputs
57  int8_t* data; // ptr to data allocation
58  size_t entry_count;
60 };
61 
63 class DeviceAllocator;
64 class Allocator;
65 
67  DeviceAllocator* device_allocator,
68  const std::vector<int64_t*>& group_by_buffers,
69  const QueryMemoryDescriptor&,
70  const unsigned block_size_x,
71  const unsigned grid_size_x,
72  const int device_id,
73  const ExecutorDispatchMode dispatch_mode,
74  const int64_t num_input_rows,
75  const bool prepend_index_buffer,
76  const bool always_init_group_by_on_host,
77  const bool use_bump_allocator,
78  const bool has_varlen_output,
79  Allocator* insitu_allocator);
80 
81 void copy_group_by_buffers_from_gpu(DeviceAllocator& device_allocator,
82  const std::vector<int64_t*>& group_by_buffers,
83  const size_t groups_buffer_size,
84  const int8_t* group_by_dev_buffers_mem,
86  const unsigned block_size_x,
87  const unsigned grid_size_x,
88  const int device_id,
89  const bool prepend_index_buffer,
90  const bool has_varlen_output);
91 
92 size_t get_num_allocated_rows_from_gpu(DeviceAllocator& device_allocator,
93  int8_t* projection_size_gpu,
94  const int device_id);
95 
97  const GpuGroupByBuffers& gpu_query_buffers,
99  int8_t* projection_buffer,
100  const size_t projection_count,
101  const int device_id);
102 
103 #endif // QUERYENGINE_GPUMEMUTILS_H
GpuGroupByBuffers create_dev_group_by_buffers(DeviceAllocator *device_allocator, const std::vector< int64_t * > &group_by_buffers, const QueryMemoryDescriptor &query_mem_desc, const unsigned block_size_x, const unsigned grid_size_x, const int device_id, const ExecutorDispatchMode dispatch_mode, const int64_t num_input_rows, const bool prepend_index_buffer, const bool always_init_group_by_on_host, const bool use_bump_allocator, const bool has_varlen_output, Allocator *insitu_allocator)
Definition: GpuMemUtils.cpp:60
size_t get_num_allocated_rows_from_gpu(DeviceAllocator &device_allocator, int8_t *projection_size_gpu, const int device_id)
unsigned long long CUdeviceptr
Definition: nocuda.h:27
ExecutorDispatchMode
void copy_to_nvidia_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr dst, const void *src, const size_t num_bytes, const int device_id)
Definition: GpuMemUtils.cpp:30
void copy_projection_buffer_from_gpu_columnar(Data_Namespace::DataMgr *data_mgr, const GpuGroupByBuffers &gpu_group_by_buffers, const QueryMemoryDescriptor &query_mem_desc, int8_t *projection_buffer, const size_t projection_count, const int device_id)
void copy_group_by_buffers_from_gpu(DeviceAllocator &device_allocator, const std::vector< int64_t * > &group_by_buffers, const size_t groups_buffer_size, const int8_t *group_by_dev_buffers_mem, const QueryMemoryDescriptor &query_mem_desc, const unsigned block_size_x, const unsigned grid_size_x, const int device_id, const bool prepend_index_buffer, const bool has_varlen_output)
int8_t * varlen_output_buffer
Definition: GpuMemUtils.h:59