github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/query/memory.hpp (about)

     1  //  Copyright (c) 2017-2018 Uber Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  #ifndef QUERY_MEMORY_HPP_
    16  #define QUERY_MEMORY_HPP_
    17  
    18  #include <thrust/device_vector.h>
    19  #include <thrust/host_vector.h>
    20  #ifdef USE_RMM
    21  #include "query/thrust_rmm_allocator.hpp"
    22  #endif
    23  
    24  namespace ares {
    25  template<typename V>
    26  #ifdef RUN_ON_DEVICE
    27  # ifdef USE_RMM
    28  using device_vector = rmm::device_vector<V>;
    29  # else
    30  using device_vector = thrust::device_vector<V>;
    31  # endif
    32  #else
    33  using device_vector = thrust::host_vector<V>;
    34  #endif
    35  
    36  // Wrappers over memutils/memory.h but will raise exceptions if error happens.
    37  void deviceMalloc(void **devPtr, size_t size);
    38  void deviceFree(void *devPtr);
    39  void deviceMemset(void *devPtr, int value, size_t count);
    40  void asyncCopyHostToDevice(void* dst, const void* src, size_t count,
    41      cudaStream_t stream);
    42  }  // namespace ares
    43  #endif  // QUERY_MEMORY_HPP_