17 #ifndef QUERYENGINE_JOINHASHTABLE_GPUUTILS_H
18 #define QUERYENGINE_JOINHASHTABLE_GPUUTILS_H
26 static_assert(std::is_trivially_copyable<T>::value && std::is_standard_layout<T>::value,
27 "Transferring a vector to GPU only works for flat object elements");
28 const auto vec_bytes = vec.size() *
sizeof(
T);
29 auto gpu_vec = allocator.
alloc(vec_bytes);
30 allocator.
copyToDevice(gpu_vec, reinterpret_cast<const int8_t*>(vec.data()), vec_bytes);
31 return reinterpret_cast<T*
>(gpu_vec);
36 static_assert(std::is_standard_layout<T>::value,
37 "Transferring an object to GPU only works for standard layout elements");
38 const auto bytes =
sizeof(
T);
39 auto gpu_ptr = allocator.
alloc(bytes);
40 allocator.
copyToDevice(gpu_ptr, reinterpret_cast<const int8_t*>(&
object), bytes);
41 return reinterpret_cast<T*
>(gpu_ptr);
44 #endif // QUERYENGINE_JOINHASHTABLE_GPUUTILS_H
T * transfer_flat_object_to_gpu(const T &object, DeviceAllocator &allocator)
virtual int8_t * alloc(const size_t num_bytes)=0
virtual void copyToDevice(void *device_dst, const void *host_src, const size_t num_bytes) const =0
Abstract class for managing device memory allocations.
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, DeviceAllocator &allocator)