Project
Loading...
Searching...
No Matches
CUDAThrustHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef GPU_CUDATHRUSTHELPERS_H
16#define GPU_CUDATHRUSTHELPERS_H
17
18#include "GPULogging.h"
19#include <vector>
20#include <memory>
21
22namespace o2::gpu
23{
24
26{
27 public:
28 typedef char value_type;
29
31 char* allocate(std::ptrdiff_t n) { return (char*)mRec->AllocateVolatileDeviceMemory(n); }
32
33 void deallocate(char* ptr, size_t) {}
34
35 private:
37};
38
39} // namespace o2::gpu
40
41#ifndef __HIPCC__
42// Override synchronize call at end of thrust algorithm running on stream, just don't run cudaStreamSynchronize
44{
45
46typedef thrust::cuda_cub::execution_policy<typeof(thrust::cuda::par(*(o2::gpu::ThrustVolatileAsyncAllocator*)nullptr).on(*(cudaStream_t*)nullptr))> thrustStreamPolicy;
47template <>
48__host__ __device__ inline cudaError_t synchronize<thrustStreamPolicy>(thrustStreamPolicy& policy)
49{
50#ifndef GPUCA_GPUCODE_DEVICE
51 // Do not synchronize!
52 return cudaSuccess;
53#else
54 return synchronize_stream(derived_cast(policy));
55#endif
56}
57
58} // namespace thrust::cuda_cub
59#endif // __HIPCC__
60
61#endif // GPU_CUDATHRUSTHELPERS_H
TBranch * ptr
void * AllocateVolatileDeviceMemory(size_t size)
ThrustVolatileAsyncAllocator(GPUReconstruction *r)
GLdouble n
Definition glcorearb.h:1982
GLboolean r
Definition glcorearb.h:1233