Project
Loading...
Searching...
No Matches
GPUReconstructionThreading.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.
11
14
15#if !defined(GPURECONSTRUCTIONTHREADING_H)
16#define GPURECONSTRUCTIONTHREADING_H
17
18#if !defined(GPUCA_GPUCODE)
19#include "GPUReconstruction.h"
20
21#include <memory>
22#include <oneapi/tbb.h>
23
24namespace o2::gpu
25{
26
28 std::unique_ptr<tbb::global_control> control;
29 std::unique_ptr<tbb::task_arena> allThreads;
30 std::unique_ptr<tbb::task_arena> activeThreads;
31 std::unique_ptr<tbb::task_arena> outerThreads;
32};
33
34} // namespace o2::gpu
35
36#endif
37
38#define GPUCA_TBB_KERNEL_LOOP_HOST(rec, vartype, varname, iEnd, code) \
39 for (vartype varname = get_global_id(0); varname < iEnd; varname += get_global_size(0)) { \
40 code \
41 }
42
43#ifdef GPUCA_GPUCODE
44#define GPUCA_TBB_KERNEL_LOOP GPUCA_TBB_KERNEL_LOOP_HOST
45#else
46#define GPUCA_TBB_KERNEL_LOOP(rec, vartype, varname, iEnd, code) \
47 if (!rec.GetProcessingSettings().inKernelParallel) { \
48 rec.mThreading->activeThreads->execute([&] { \
49 tbb::parallel_for(tbb::blocked_range<vartype>(get_global_id(0), iEnd, get_global_size(0)), [&](const tbb::blocked_range<vartype>& _r_internal) { \
50 for (vartype varname = _r_internal.begin(); varname < _r_internal.end(); varname += get_global_size(0)) { \
51 code \
52 } \
53 }); \
54 }); \
55 } else { \
56 GPUCA_TBB_KERNEL_LOOP_HOST(rec, vartype, varname, iEnd, code) \
57 }
58#endif
59
60#endif
std::unique_ptr< tbb::global_control > control
std::unique_ptr< tbb::task_arena > activeThreads
std::unique_ptr< tbb::task_arena > outerThreads
std::unique_ptr< tbb::task_arena > allThreads