Project
Loading...
Searching...
No Matches
GPUInterface.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 DCAFITTER_GPU_INTERFACE
16#define DCAFITTER_GPU_INTERFACE
17
18#include <thread>
19#include <vector>
20#include <atomic>
21
22namespace o2
23{
24namespace vertexing
25{
26namespace device
27{
28
29#if !defined(__HIPCC__) && !defined(__CUDACC__)
30typedef struct _dummyStream {
32#else
33#ifdef __HIPCC__
34typedef hipStream_t Stream;
35#else
36typedef cudaStream_t Stream;
37#endif
38#endif
39
41{
42 public:
44 void operator=(const GPUInterface&) = delete;
45
47
48 // APIs
49 void registerBuffer(void*, size_t);
50 void unregisterBuffer(void* addr);
51 void allocDevice(void**, size_t);
52 void freeDevice(void*);
53 Stream& getStream(unsigned short N = 0);
55
56 protected:
57 GPUInterface(size_t N = 1);
59
60 void resize(size_t);
61
62 std::atomic<unsigned short> mLastUsedStream{0};
64 std::vector<std::thread> mPool{};
65 std::vector<Stream> mStreams{};
66};
67
68} // namespace device
69} // namespace vertexing
70} // namespace o2
71#endif
void allocDevice(void **, size_t)
std::atomic< unsigned short > mLastUsedStream
Stream & getStream(unsigned short N=0)
GPUInterface(GPUInterface &other)=delete
static GPUInterface * sGPUInterface
void operator=(const GPUInterface &)=delete
static GPUInterface * Instance()
std::vector< std::thread > mPool
void registerBuffer(void *, size_t)
struct o2::vertexing::device::_dummyStream Stream
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other