36#if defined(FZGMOD_BACKEND_SYCL)
38#error "FZGMOD_BACKEND=SYCL is not implemented yet"
42#include <thrust/device_ptr.h>
43#include <thrust/execution_policy.h>
44#include <thrust/scan.h>
54inline auto parOn(fz::stream_t stream) {
55#if defined(FZGMOD_BACKEND_HIP)
56 return thrust::hip::par.on(stream);
58 return thrust::cuda::par.on(stream);
74 bool from_pool =
false;
93 void* d_temp = pool ? pool->
allocate(bytes, stream, tag) :
nullptr;
94 bool from_pool = (d_temp !=
nullptr);
95 if (!d_temp && bytes > 0) {
96 FZ_CUDA_CHECK(cudaMalloc(&d_temp, bytes));
105 if (!temp.ptr)
return;
106 if (temp.from_pool && pool) {
107 pool->
free(temp.ptr, stream);
109 FZ_CUDA_CHECK_WARN(cudaStreamSynchronize(stream));
110 FZ_CUDA_CHECK_WARN(cudaFree(temp.ptr));
117 thrust::device_ptr<T> in_ptr(d_in);
118 thrust::device_ptr<T> out_ptr(d_out);
119 thrust::exclusive_scan(detail::parOn(stream), in_ptr, in_ptr + n, out_ptr);
TempStorage withTempStorage(MemoryPool *pool, fz::stream_t stream, const char *tag, Fn &&fn)
Definition algorithms.h:90
void freeTempStorage(MemoryPool *pool, const TempStorage &temp, fz::stream_t stream)
Definition algorithms.h:104
void exclusiveScan(fz::stream_t stream, T *d_in, T *d_out, size_t n)
Definition algorithms.h:116
auto parOn(fz::stream_t stream)
Definition algorithms.h:54
Backend-neutral spelling of the host-side GPU runtime API.
void free(void *ptr, fz::stream_t stream)
void * allocate(size_t size, fz::stream_t stream, const std::string &tag="", bool persistent=false)
GPU backend API error-checking macros.
Stream-ordered CUDA memory pool for pipeline buffer management.
Definition algorithms.h:48
Definition algorithms.h:72
Backend-neutral GPU type aliases.