Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Common/MathUtils/include/MathUtils/detail/Bracket.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#ifndef ALICEO2_BRACKET_H
#define ALICEO2_BRACKET_H

#include "GPUCommonDef.h"

#include <GPUCommonRtypes.h>
#ifndef GPUCA_GPUCODE_DEVICE
#include <string>
Expand Down Expand Up @@ -53,9 +55,9 @@ class Bracket
bool operator==(const Bracket<T>& other) const;
bool operator!=(const Bracket<T>& other) const;

void setMax(T v) noexcept;
void setMin(T v) noexcept;
void set(T minv, T maxv) noexcept;
void setMax(T v) GPUnoexcept();
void setMin(T v) GPUnoexcept();
void set(T minv, T maxv) GPUnoexcept();

T& getMax();
T& getMin();
Expand Down Expand Up @@ -129,19 +131,19 @@ inline bool Bracket<T>::operator!=(const Bracket<T>& rhs) const
}

template <typename T>
inline void Bracket<T>::setMax(T v) noexcept
inline void Bracket<T>::setMax(T v) GPUnoexcept()
{
mMax = v;
}

template <typename T>
inline void Bracket<T>::setMin(T v) noexcept
inline void Bracket<T>::setMin(T v) GPUnoexcept()
{
mMin = v;
}

template <typename T>
inline void Bracket<T>::set(T minv, T maxv) noexcept
inline void Bracket<T>::set(T minv, T maxv) GPUnoexcept()
{
this->setMin(minv);
this->setMax(maxv);
Expand Down
24 changes: 12 additions & 12 deletions GPU/Common/GPUCommonAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,40 @@ class GPUCommonAlgorithm
private:
// Quicksort implementation
template <typename I>
GPUd() static void QuickSort(I f, I l) noexcept;
GPUd() static void QuickSort(I f, I l) GPUnoexcept();

// Quicksort implementation
template <typename I, typename Cmp>
GPUd() static void QuickSort(I f, I l, Cmp cmp) noexcept;
GPUd() static void QuickSort(I f, I l, Cmp cmp) GPUnoexcept();

// Insertionsort implementation
template <typename I, typename Cmp>
GPUd() static void InsertionSort(I f, I l, Cmp cmp) noexcept;
GPUd() static void InsertionSort(I f, I l, Cmp cmp) GPUnoexcept();

// Helper for Quicksort implementation
template <typename I, typename Cmp>
GPUd() static I MedianOf3Select(I f, I l, Cmp cmp) noexcept;
GPUd() static I MedianOf3Select(I f, I l, Cmp cmp) GPUnoexcept();

// Helper for Quicksort implementation
template <typename I, typename T, typename Cmp>
GPUd() static I UnguardedPartition(I f, I l, T piv, Cmp cmp) noexcept;
GPUd() static I UnguardedPartition(I f, I l, T piv, Cmp cmp) GPUnoexcept();

// Helper
template <typename I>
GPUd() static void IterSwap(I a, I b) noexcept;
GPUd() static void IterSwap(I a, I b) GPUnoexcept();
};

#ifndef GPUCA_ALGORITHM_STD
template <typename I>
GPUdi() void GPUCommonAlgorithm::IterSwap(I a, I b) noexcept
GPUdi() void GPUCommonAlgorithm::IterSwap(I a, I b) GPUnoexcept()
{
auto tmp = *a;
*a = *b;
*b = tmp;
}

template <typename I, typename Cmp>
GPUdi() void GPUCommonAlgorithm::InsertionSort(I f, I l, Cmp cmp) noexcept
GPUdi() void GPUCommonAlgorithm::InsertionSort(I f, I l, Cmp cmp) GPUnoexcept()
{
auto it0{f};
while (it0 != l) {
Expand All @@ -102,7 +102,7 @@ GPUdi() void GPUCommonAlgorithm::InsertionSort(I f, I l, Cmp cmp) noexcept
}

template <typename I, typename Cmp>
GPUdi() I GPUCommonAlgorithm::MedianOf3Select(I f, I l, Cmp cmp) noexcept
GPUdi() I GPUCommonAlgorithm::MedianOf3Select(I f, I l, Cmp cmp) GPUnoexcept()
{
auto m = f + (l - f) / 2;

Expand All @@ -126,7 +126,7 @@ GPUdi() I GPUCommonAlgorithm::MedianOf3Select(I f, I l, Cmp cmp) noexcept
}

template <typename I, typename T, typename Cmp>
GPUdi() I GPUCommonAlgorithm::UnguardedPartition(I f, I l, T piv, Cmp cmp) noexcept
GPUdi() I GPUCommonAlgorithm::UnguardedPartition(I f, I l, T piv, Cmp cmp) GPUnoexcept()
{
do {
while (cmp(*f, piv)) {
Expand All @@ -146,7 +146,7 @@ GPUdi() I GPUCommonAlgorithm::UnguardedPartition(I f, I l, T piv, Cmp cmp) noexc
}

template <typename I, typename Cmp>
GPUdi() void GPUCommonAlgorithm::QuickSort(I f, I l, Cmp cmp) noexcept
GPUdi() void GPUCommonAlgorithm::QuickSort(I f, I l, Cmp cmp) GPUnoexcept()
{
if (f == l) {
return;
Expand Down Expand Up @@ -204,7 +204,7 @@ GPUdi() void GPUCommonAlgorithm::QuickSort(I f, I l, Cmp cmp) noexcept
}

template <typename I>
GPUdi() void GPUCommonAlgorithm::QuickSort(I f, I l) noexcept
GPUdi() void GPUCommonAlgorithm::QuickSort(I f, I l) GPUnoexcept()
{
QuickSort(f, l, [](auto&& x, auto&& y) { return x < y; });
}
Expand Down
7 changes: 6 additions & 1 deletion GPU/Common/GPUCommonDefAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define GPUconstant() // constant memory variable declaraion
#define GPUconstexpr() static constexpr // constexpr on GPU that needs to be instantiated for dynamic access (e.g. arrays), becomes __constant on GPU
#define GPUglobalconstexpr() constexpr // constexpr variable at program scope, needs the constant address space in MSL
#define GPUnoexcept() noexcept // noexcept where the backend supports it
#define GPUprivate() // private memory variable declaration
#define GPUgeneric() // reference / ptr to generic address space
#define GPUbarrier() // synchronize all GPU threads in block
Expand Down Expand Up @@ -162,6 +163,7 @@
#define GPUconstant() constant // TODO: possibly add const __restrict where possible later!
#define GPUconstexpr() constant
#define GPUglobalconstexpr() constant constexpr
#define GPUnoexcept()
#define GPUprivate() thread
#define GPUgeneric()
#define GPUglobalref() device
Expand Down Expand Up @@ -259,6 +261,9 @@
#ifndef GPUglobalconstexpr
#define GPUglobalconstexpr() constexpr
#endif
#ifndef GPUnoexcept
#define GPUnoexcept() noexcept
#endif

#define GPUrestrict() __restrict__

Expand All @@ -281,5 +286,5 @@
#define get_group_id(dim) iBlock
#endif

// clang-format on
// clang-format on
#endif
Loading