Project
Loading...
Searching...
No Matches
Array.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 ITSTRACKINGGPU_ARRAY_H_
17#define ITSTRACKINGGPU_ARRAY_H_
18
19#include "GPUCommonDef.h"
20
21namespace o2
22{
23namespace its
24{
25namespace gpu
26{
27template <typename T, size_t Size>
28struct ArrayTraits final {
29 typedef T InternalArray[Size];
30
31 GPUhd() static constexpr T& getReference(const InternalArray& internalArray, size_t index) noexcept
32 {
33 return const_cast<T&>(internalArray[index]);
34 }
35
36 GPUhd() static constexpr T* getPointer(const InternalArray& internalArray) noexcept
37 {
38 return const_cast<T*>(internalArray);
39 }
40};
41
42template <typename T, size_t Size>
43struct Array final {
44
45 void copy(const Array<T, Size>& t)
46 {
47 memcpy(InternalArray, t.data(), Size * sizeof(T));
48 }
49
50 GPUhd() T* data() noexcept { return const_cast<T*>(InternalArray); }
51 GPUhd() const T* data() const noexcept { return const_cast<T*>(InternalArray); }
52 GPUhd() T& operator[](const int index) noexcept { return const_cast<T&>(InternalArray[index]); }
53 GPUhd() constexpr T& operator[](const int index) const noexcept { return const_cast<T&>(InternalArray[index]); }
54 GPUhd() size_t size() const noexcept { return Size; }
55
57};
58} // namespace gpu
59} // namespace its
60} // namespace o2
61
62#endif
GLsizeiptr size
Definition glcorearb.h:659
GLuint index
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
GPUhd() static const expr T &getReference(const InternalArray &internalArray
size_t index noexcept
Definition Array.h:32
GPUhd() static const expr T *getPointer(const InternalArray &internalArray) noexcept
Definition Array.h:36
GPUhd() T *data() noexcept
Definition Array.h:50
GPUhd() T &operator[](const int index) noexcept
Definition Array.h:52
GPUhd() size_t size() const noexcept
Definition Array.h:54
void copy(const Array< T, Size > &t)
Definition Array.h:45
T InternalArray[Size]
Definition Array.h:56
GPUhd() const T *data() const noexcept
Definition Array.h:51
GPUhd() const expr T &operator[](const int index) const noexcept
Definition Array.h:53