OmniSciDB  21ac014ffc
 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 
48  CUdeviceptr dst,
49  const void* src,
50  const size_t num_bytes,
51  const int device_id);
52 
54  void* dst,
55  const CUdeviceptr src,
56  const size_t num_bytes,
57  const int device_id);
58 
60  CUdeviceptr ptrs; // ptrs for individual outputs
61  CUdeviceptr data; // ptr to data allocation
62  size_t entry_count;
64 };
65 
67 class DeviceAllocator;
68 class Allocator;
69 
71  DeviceAllocator* device_allocator,
72  const std::vector<int64_t*>& group_by_buffers,
73  const QueryMemoryDescriptor&,
74  const unsigned block_size_x,
75  const unsigned grid_size_x,
76  const int device_id,
77  const ExecutorDispatchMode dispatch_mode,
78  const int64_t num_input_rows,
79  const bool prepend_index_buffer,
80  const bool always_init_group_by_on_host,
81  const bool use_bump_allocator,
82  const bool has_varlen_output,
83  Allocator* insitu_allocator);
84 
86  const std::vector<int64_t*>& group_by_buffers,
87  const size_t groups_buffer_size,
88  const CUdeviceptr group_by_dev_buffers_mem,
90  const unsigned block_size_x,
91  const unsigned grid_size_x,
92  const int device_id,
93  const bool prepend_index_buffer,
94  const bool has_varlen_output);
95 
97  CUdeviceptr projection_size_gpu,
98  const int device_id);
99 
101  const GpuGroupByBuffers& gpu_query_buffers,
103  int8_t* projection_buffer,
104  const size_t projection_count,
105  const int device_id);
106 
107 #endif // QUERYENGINE_GPUMEMUTILS_H
CUdeviceptr ptrs
Definition: GpuMemUtils.h:60
CUdeviceptr data
Definition: GpuMemUtils.h:61
unsigned long long CUdeviceptr
Definition: nocuda.h:27
CUdeviceptr varlen_output_buffer
Definition: GpuMemUtils.h:63
ExecutorDispatchMode
void copy_group_by_buffers_from_gpu(Data_Namespace::DataMgr *data_mgr, const std::vector< int64_t * > &group_by_buffers, const size_t groups_buffer_size, const CUdeviceptr 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)
void copy_to_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_from_gpu(Data_Namespace::DataMgr *data_mgr, void *dst, const CUdeviceptr src, const size_t num_bytes, const int device_id)
size_t get_num_allocated_rows_from_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr projection_size_gpu, const int device_id)
GpuGroupByBuffers create_dev_group_by_buffers(DeviceAllocator *cuda_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
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)