38#ifdef __cpp_lib_format
45#ifdef ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLED
49 template<
typename TDim,
typename TIdx,
typename TKernelFnObj,
typename... TArgs>
50 class TaskKernelCpuThreads;
56 template<
typename TDim,
typename TIdx>
71# ifdef ALPAKA_DISABLE_VENDOR_RNG
80 sizeof(TIdx) >=
sizeof(
int),
81 "Index type is not supported, consider using int or a larger type.");
85 template<
typename TDim2,
typename TIdx2,
typename TKernelFnObj,
typename... TArgs>
86 friend class ::alpaka::TaskKernelCpuThreads;
94 template<
typename TWorkDiv>
97 , gb::
IdxGbRef<TDim, TIdx>(m_gridBlockIdx)
104 [
this]()
noexcept {
return (m_idMasterThread == std::this_thread::get_id()); })
105 , BlockSyncBarrierThread<TIdx>(getWorkDiv<Block, Threads>(workDiv).prod())
106 , m_gridBlockIdx(Vec<TDim, TIdx>::zeros())
112 std::mutex
mutable m_mtxMapInsert;
113 typename bt::IdxBtRefThreadIdMap<TDim, TIdx>::
114 ThreadIdToIdxMap
mutable m_threadToIndexMap;
115 Vec<TDim, TIdx>
mutable m_gridBlockIdx;
118 std::thread::id
mutable m_idMasterThread;
124 template<
typename TDim,
typename TIdx>
125 struct AccType<AccCpuThreads<TDim, TIdx>>
127 using type = AccCpuThreads<TDim, TIdx>;
131 template<
typename TDim,
typename TIdx>
132 struct IsSingleThreadAcc<AccCpuThreads<TDim, TIdx>> : std::false_type
137 template<
typename TDim,
typename TIdx>
138 struct IsMultiThreadAcc<AccCpuThreads<TDim, TIdx>> : std::true_type
143 template<
typename TDim,
typename TIdx>
144 struct GetAccDevProps<AccCpuThreads<TDim, TIdx>>
149 auto const blockThreadCountMax =
static_cast<TIdx
>(8);
154 auto const blockThreadCountMax = std::max(
155 static_cast<TIdx
>(1),
160 static_cast<TIdx
>(1),
162 Vec<TDim, TIdx>::all(std::numeric_limits<TIdx>::max()),
164 std::numeric_limits<TIdx>::max(),
172 std::numeric_limits<TIdx>::max(),
181 template<
typename TDim,
typename TIdx>
182 struct GetAccName<AccCpuThreads<TDim, TIdx>>
186# if ALPAKA_COMP_CLANG
187# pragma clang diagnostic push
188# pragma clang diagnostic ignored "-Wexit-time-destructors"
190 using namespace std::literals;
191 static std::string
const accName =
192# ifdef __cpp_lib_format
198# if ALPAKA_COMP_CLANG
199# pragma clang diagnostic pop
205 template<
typename TDim,
typename TIdx>
206 struct DevType<AccCpuThreads<TDim, TIdx>>
212 template<
typename TDim,
typename TIdx>
213 struct DimType<AccCpuThreads<TDim, TIdx>>
219 template<
typename TDim,
typename TIdx,
typename TWorkDiv,
typename TKernelFnObj,
typename... TArgs>
220 struct CreateTaskKernel<AccCpuThreads<TDim, TIdx>, TWorkDiv, TKernelFnObj, TArgs...>
223 TWorkDiv
const& workDiv,
224 TKernelFnObj
const& kernelFnObj,
227 return TaskKernelCpuThreads<TDim, TIdx, TKernelFnObj, TArgs...>(
230 std::forward<TArgs>(args)...);
235 template<
typename TDim,
typename TIdx>
236 struct PlatformType<AccCpuThreads<TDim, TIdx>>
238 using type = PlatformCpu;
242 template<
typename TDim,
typename TIdx>
243 struct IdxType<AccCpuThreads<TDim, TIdx>>
248 template<
typename TDim,
typename TIdx>
254 template<
typename TDim,
typename TIdx>
The CPU threads accelerator.
auto operator=(AccCpuThreads const &) -> AccCpuThreads &=delete
AccCpuThreads(AccCpuThreads &&)=delete
AccCpuThreads(AccCpuThreads const &)=delete
auto operator=(AccCpuThreads &&) -> AccCpuThreads &=delete
Dynamic block shared memory provider using fixed-size member array to allocate memory on the stack or...
auto staticMemBegin() const -> uint8_t *
auto staticMemCapacity() const -> std::uint32_t
The thread id map barrier block synchronization.
The default CPU memory fence.
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST_ACC constexpr auto all(TVal const &val) -> Vec< TDim, TVal >
Single value constructor.
A basic class holding the work division as grid block extent, block thread and thread element extent.
The threads accelerator index provider.
ALPAKA_FN_HOST IdxBtRefThreadIdMap(ThreadIdToIdxMap const &mThreadToIndices)
A IdxGbRef grid block index.
IdxGbRef(Vec< TDim, TIdx > const &gridBlockIdx)
The standard library math trait specializations.
"Tiny" state mersenne twister implementation
The single-threaded warp to emulate it on CPUs.
auto clipCast(V const &val) -> T
The alpaka accelerator library.
ALPAKA_FN_HOST auto getAccDevProps(TDev const &dev) -> AccDevProps< Dim< TAcc >, Idx< TAcc > >
ALPAKA_FN_HOST auto createTaskKernel(TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args)
Creates a kernel execution task.
ALPAKA_FN_HOST auto getMemBytes(TDev const &dev) -> std::size_t
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto syncBlockThreads(TBlockSync const &blockSync) -> void
Synchronizes all threads within the current block (independently for all blocks).
typename trait::AccToTag< TAcc >::type AccToTag
maps an acc type to a tag type
typename trait::TagToAcc< TTag, TDim, TIdx >::type TagToAcc
maps a tag type to an acc type
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
static ALPAKA_FN_HOST auto getAccName() -> std::string