Project
Loading...
Searching...
No Matches
GPUMemoryResource.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 GPUMEMORYRESOURCE_H
16#define GPUMEMORYRESOURCE_H
17
18#include "GPUCommonDef.h"
19#include "GPUProcessor.h"
20
21namespace o2::gpu
22{
23
25 enum Type : int32_t {
26 NONE = 0,
27 REUSE_1TO1 = 1
28 };
36 using ID = uint32_t;
37
38 GPUMemoryReuse(Type t, Group g, uint16_t i) : type(t), id(((uint32_t)g << 16) | ((uint32_t)i & 0xFFFF)) {}
39 GPUMemoryReuse(bool condition, Type t, Group g, uint16_t i) : GPUMemoryReuse()
40 {
41 if (condition) {
42 *this = GPUMemoryReuse{t, g, i};
43 }
44 }
45 constexpr GPUMemoryReuse() = default;
46
48 ID id = 0;
49};
50
52{
53 friend class GPUReconstruction;
55
56 public:
76
77 GPUMemoryResource(GPUProcessor* proc, void* (GPUProcessor::*setPtr)(void*), MemoryType type, const char* name = "") : mProcessor(proc), mPtr(nullptr), mPtrDevice(nullptr), mSetPointers(setPtr), mName(name), mSize(0), mOverrideSize(0), mReuse(-1), mType(type)
78 {
79 }
81
82 void* SetPointers(void* ptr)
83 {
84 return (mProcessor->*mSetPointers)(ptr);
85 }
86 void* SetDevicePointers(void* ptr) { return (mProcessor->mLinkedProcessor->*mSetPointers)(ptr); }
87 void* Ptr() { return mPtr; }
88 void* PtrDevice() { return mPtrDevice; }
89 size_t Size() const { return mSize; }
90 const char* Name() const { return mName; }
91 MemoryType Type() const { return mType; }
92
93 private:
94 GPUProcessor* mProcessor;
95 void* mPtr;
96 void* mPtrDevice;
97 void* (GPUProcessor::*mSetPointers)(void*);
98 const char* mName;
99 size_t mSize;
100 size_t mOverrideSize;
101 int32_t mReuse;
102 MemoryType mType;
103};
104} // namespace o2::gpu
105
106#endif
int32_t i
TBranch * ptr
void * SetDevicePointers(void *ptr)
GPUMemoryResource(const GPUMemoryResource &)=default
const char * Name() const
GPUMemoryResource(GPUProcessor *proc, void *(GPUProcessor::*setPtr)(void *), MemoryType type, const char *name="")
GPUProcessor * mLinkedProcessor
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean GLboolean g
Definition glcorearb.h:1233
GLuint id
Definition glcorearb.h:650
GPUMemoryReuse(Type t, Group g, uint16_t i)
GPUMemoryReuse(bool condition, Type t, Group g, uint16_t i)
constexpr GPUMemoryReuse()=default