Project
Loading...
Searching...
No Matches
ExternalAllocator.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.
15
16#ifndef TRACKINGITSU_INCLUDE_EXTERNALALLOCATOR_H_
17#define TRACKINGITSU_INCLUDE_EXTERNALALLOCATOR_H_
18
19#include <memory_resource>
20#include "GPUO2ExternalUser.h"
22
23namespace o2::its
24{
25
27{
28 using Type = std::underlying_type_t<o2::gpu::GPUMemoryResource::MemoryType>;
29
30 public:
31 virtual void deallocate(char*, size_t) = 0;
32 virtual void* allocate(size_t) = 0;
33 void* allocate(size_t s, Type type)
34 {
35 auto old = mType;
36 mType = type;
37 void* p = allocate(s);
38 mType = old;
39 return p;
40 }
41
46 virtual void pushTagOnStack(uint64_t) = 0;
47 virtual void popTagOffStack(uint64_t) = 0;
48
49 void setType(Type t) noexcept { mType = t; }
50 Type getType() const noexcept { return mType; }
51
52 protected:
53 Type mType;
54};
55
57{
58 public:
59 explicit ExternalAllocatorAdaptor(ExternalAllocator* alloc) : mAlloc(alloc) {}
60
61 protected:
62 void* do_allocate(size_t bytes, size_t alignment) override
63 {
65 if (!p) {
66 throw std::bad_alloc();
67 }
68 return p;
69 }
70
71 void do_deallocate(void* p, size_t bytes, size_t) override
72 {
73 mAlloc->deallocate(static_cast<char*>(p), bytes);
74 }
75
76 bool do_is_equal(const std::pmr::memory_resource& other) const noexcept override
77 {
78 return this == &other;
79 }
80
81 private:
82 ExternalAllocator* mAlloc;
83};
84
85} // namespace o2::its
86
87#endif
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
size_t bytes
void * do_allocate(size_t bytes, size_t alignment) override
ExternalAllocatorAdaptor(ExternalAllocator *alloc)
void do_deallocate(void *p, size_t bytes, size_t) override
bool do_is_equal(const std::pmr::memory_resource &other) const noexcept override
virtual void pushTagOnStack(uint64_t)=0
virtual void deallocate(char *, size_t)=0
void * allocate(size_t s, Type type)
void setType(Type t) noexcept
Type getType() const noexcept
virtual void * allocate(size_t)=0
virtual void popTagOffStack(uint64_t)=0
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
VectorOfTObjectPtrs other