Loading...
Searching...
No Matches
ThrustUtils.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_THRUST_UTILS_HPP
12#define CUBBYFLOW_THRUST_UTILS_HPP
13
14#ifdef CUBBYFLOW_USE_CUDA
15
17
18#include <cuda_runtime.h>
19
20#include <thrust/device_ptr.h>
21
22#include <algorithm>
23#include <cstdint>
24
25namespace CubbyFlow
26{
27template <typename T, size_t N, typename D>
28thrust::device_ptr<T> thrustBegin(CUDAArrayBase<T, N, D>& arr)
29{
30 return thrust::device_ptr<T>(arr.data());
31}
32
33template <typename T, size_t N, typename D>
34thrust::device_ptr<const T> thrustCBegin(const CUDAArrayBase<T, N, D>& arr)
35{
36 return thrust::device_ptr<const T>(arr.data());
37}
38
39template <typename T, size_t N, typename D>
40thrust::device_ptr<T> thrustEnd(CUDAArrayBase<T, N, D>& arr)
41{
42 return thrust::device_ptr<T>(arr.data() + arr.Length());
43}
44
45template <typename T, size_t N, typename D>
46thrust::device_ptr<const T> thrustCEnd(const CUDAArrayBase<T, N, D>& arr)
47{
48 return thrust::device_ptr<const T>(arr.data() + arr.Length());
49}
50} // namespace CubbyFlow
51
52#endif
53
54#endif
ValueType Length() const
Definition MatrixExpression-Impl.hpp:278
Pointer data()
Definition Matrix-Impl.hpp:298
Definition pybind11Utils.hpp:21
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738