alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
BlockSyncBarrierThread.hpp
Go to the documentation of this file.
1/* Copyright 2022 Benjamin Worpitz, Bernhard Manfred Gruber
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
10
11#include <map>
12#include <mutex>
13#include <thread>
14
15#ifdef ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLED
16
17namespace alpaka
18{
19 //! The thread id map barrier block synchronization.
20 template<typename TIdx>
21 class BlockSyncBarrierThread : public interface::Implements<ConceptBlockSync, BlockSyncBarrierThread<TIdx>>
22 {
23 public:
26
27 ALPAKA_FN_HOST BlockSyncBarrierThread(TIdx const& blockThreadCount)
28 : m_barrier(blockThreadCount)
29 , m_barrierWithPredicate(blockThreadCount)
30 {
31 }
32
35 };
36
37 namespace trait
38 {
39 template<typename TIdx>
41 {
42 ALPAKA_FN_HOST static auto syncBlockThreads(BlockSyncBarrierThread<TIdx> const& blockSync) -> void
43 {
44 blockSync.m_barrier.wait();
45 }
46 };
47
48 template<typename TOp, typename TIdx>
50 {
53 BlockSyncBarrierThread<TIdx> const& blockSync,
54 int predicate) -> int
55 {
56 return blockSync.m_barrierWithPredicate.template wait<TOp>(predicate);
57 }
58 };
59 } // namespace trait
60} // namespace alpaka
61
62#endif
The thread id map barrier block synchronization.
ALPAKA_FN_HOST BlockSyncBarrierThread(TIdx const &blockThreadCount)
A self-resetting barrier with barrier.
#define ALPAKA_FN_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
Definition Common.hpp:38
#define ALPAKA_FN_HOST
Definition Common.hpp:40
#define ALPAKA_NO_HOST_ACC_WARNING
Disable nvcc warning: 'calling a host function from host device function.' Usage: ALPAKA_NO_HOST_ACC_...
Definition Common.hpp:82
The alpaka accelerator library.
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition Interface.hpp:15
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_ACC auto syncBlockThreadsPredicate(BlockSyncBarrierThread< TIdx > const &blockSync, int predicate) -> int
The block synchronization and predicate operation trait.
Definition Traits.hpp:27
static ALPAKA_FN_HOST auto syncBlockThreads(BlockSyncBarrierThread< TIdx > const &blockSync) -> void
The block synchronization operation trait.
Definition Traits.hpp:23