LBANN
0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
omp_pragma.hpp
Go to the documentation of this file.
1
// Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3
// Produced at the Lawrence Livermore National Laboratory.
4
// Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5
// the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6
//
7
// LLNL-CODE-697807.
8
// All rights reserved.
9
//
10
// This file is part of LBANN: Livermore Big Artificial Neural Network
11
// Toolkit. For details, see http://software.llnl.gov/LBANN or
12
// https://github.com/LLNL/LBANN.
13
//
14
// Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15
// may not use this file except in compliance with the License. You may
16
// obtain a copy of the License at:
17
//
18
// http://www.apache.org/licenses/LICENSE-2.0
19
//
20
// Unless required by applicable law or agreed to in writing, software
21
// distributed under the License is distributed on an "AS IS" BASIS,
22
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23
// implied. See the License for the specific language governing
24
// permissions and limitations under the license.
26
27
#ifndef LBANN_OMP_PRAGMA_HPP
28
#define LBANN_OMP_PRAGMA_HPP
29
30
#include "lbann_config.hpp"
31
#include <omp.h>
32
35
36
#ifndef LBANN_DETERMINISTIC
37
38
#if defined(LBANN_HAVE_OMP_TASKLOOP)
39
#pragma message "Using OpenMP taskloops instead of parallel for loops"
40
#define LBANN_OMP_PARALLEL_FOR_HELPER(arg) #arg
41
#define LBANN_OMP_PARALLEL_FOR_TEXT(arg) \
42
LBANN_OMP_PARALLEL_FOR_HELPER(omp taskloop default(shared) \
43
num_tasks(omp_get_num_threads()) arg)
44
#define LBANN_OMP_PARALLEL_FOR_ARGS(arg) \
45
_Pragma(LBANN_OMP_PARALLEL_FOR_TEXT(arg))
46
47
#define LBANN_OMP_PARALLEL_FOR \
48
_Pragma("omp taskloop default(shared) num_tasks(omp_get_num_threads())")
49
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE2 \
50
_Pragma("omp taskloop collapse(2) default(shared) " \
51
"num_tasks(omp_get_num_threads())")
52
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE3 \
53
_Pragma("omp taskloop collapse(3) default(shared) " \
54
"num_tasks(omp_get_num_threads())")
55
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE4 \
56
_Pragma("omp taskloop collapse(4) default(shared) " \
57
"num_tasks(omp_get_num_threads())")
58
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE5 \
59
_Pragma("omp taskloop collapse(5) default(shared) " \
60
"num_tasks(omp_get_num_threads())")
61
#else
62
#define LBANN_OMP_PARALLEL_FOR_HELPER(arg) #arg
63
#define LBANN_OMP_PARALLEL_FOR_TEXT(arg) LBANN_OMP_PARALLEL_FOR_HELPER(omp parallel for arg)
64
#define LBANN_OMP_PARALLEL_FOR_ARGS(arg) \
65
_Pragma(LBANN_OMP_PARALLEL_FOR_TEXT(arg))
66
67
#define LBANN_OMP_PARALLEL_FOR _Pragma("omp parallel for")
68
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE2 _Pragma("omp parallel for collapse(2)")
69
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE3 _Pragma("omp parallel for collapse(3)")
70
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE4 _Pragma("omp parallel for collapse(4)")
71
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE5 _Pragma("omp parallel for collapse(5)")
72
#endif
73
74
#define LBANN_OMP_PARALLEL_HELPER(arg) #arg
75
#define LBANN_OMP_PARALLEL_TEXT(arg) LBANN_OMP_PARALLEL_HELPER(omp parallel arg)
76
#define LBANN_OMP_PARALLEL_ARGS(arg) _Pragma(LBANN_OMP_PARALLEL_TEXT(arg))
77
78
#define LBANN_OMP_PARALLEL _Pragma("omp parallel")
79
#define LBANN_OMP_ATOMIC _Pragma("omp atomic")
80
#define OMP_CRITICAL _Pragma("omp critical")
81
82
#else // LBANN_DETERMINISTIC
83
84
#define LBANN_OMP_PARALLEL_FOR_HELPER(arg)
85
#define LBANN_OMP_PARALLEL_FOR_TEXT(arg)
86
#define LBANN_OMP_PARALLEL_FOR_ARGS(arg)
87
#define LBANN_OMP_PARALLEL_FOR
88
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE2
89
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE3
90
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE4
91
#define LBANN_OMP_PARALLEL_FOR_COLLAPSE5
92
#define LBANN_OMP_PARALLEL_HELPER(arg)
93
#define LBANN_OMP_PARALLEL_TEXT(arg)
94
#define LBANN_OMP_PARALLEL_ARGS(arg)
95
#define LBANN_OMP_PARALLEL
96
#define LBANN_OMP_ATOMIC
97
#define OMP_CRITICAL
98
99
#endif // LBANN_DETERMINISTIC
100
#endif // LBANN_OMP_PRAGMA_HPP
include
lbann
utils
omp_pragma.hpp
Generated on Wed Oct 11 2023 20:49:37 for LBANN by
1.8.13