Scippy

SCIP

Solving Constraint Integer Programs

def_openmp.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2018 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file def_openmp.h
17  * @ingroup TASKINTERFACE
18  * @brief wrappers for OpenMP defines
19  * @author Stephen J. Maher
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __DEF_OPENMP_H__
25 #define __DEF_OPENMP_H__
26 
27 #define STR(x) #x
28 #define STRINGIFY(x) STR(x)
29 #define CONCATENATE(x, y) x y
30 #define CONCATPARENTH(x, y) x ( y )
31 
32 #define TPI_NULL NULL
33 
34 #ifdef TPI_OMP
35 
36 #define TPI_PRAGMA_CLAUSE(directive, clause) _Pragma( STRINGIFY( CONCATENATE( directive, clause ) ) )
37 #define TPI_PRAGMA(directive) _Pragma( STRINGIFY( directive ) )
38 #define TPI_PRAGMA_PARENTH(directive, var) _Pragma( STRINGIFY( CONCATPARENTH( directive, var ) ) )
39 
40 #else
41 
42 #define TPI_PRAGMA_CLAUSE(directive, clause)
43 #define TPI_PRAGMA(directive)
44 #define TPI_PRAGMA_PARENTH(directive, var)
45 
46 #endif
47 
48 
49 #define TPI_FOR_CLAUSE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_FOR, clause )
50 #define TPI_FOR TPI_PRAGMA( TPI_DIR_FOR )
51 #define TPI_PARA_CLAUSE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, clause )
52 
53 #define TPI_PARA_CLAUSE_SHARED(priv, clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
54  TPI_CLAUSE_DEFAULT( shared ) \
55  TPI_CLAUSE_PRIVATE( (priv) ) clause )
56 
57 #define TPI_PARA_SHARED TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
58  TPI_CLAUSE_DEFAULT( shared ) )
59 
60 #define TPI_PARA_SHARED_PRIVATE(priv) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
61  TPI_CLAUSE_DEFAULT( shared ) \
62  TPI_CLAUSE_PRIVATE( ( priv ) ) )
63 
64 #define TPI_PARA_CLAUSE_NONE(share, priv, clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
65  TPI_CLAUSE_DEFAULT( (none) ) \
66  TPI_CLAUSE_SHARED( (share) ) \
67  TPI_CLAUSE_PRIVATE( (priv) ) clause )
68 
69 #define TPI_PARA TPI_PRAGMA( TPI_DIR_PARA )
70 #define TPI_CRITICAL(var) TPI_PRAGMA_PARENTH( TPI_DIR_CRITICAL, var)
71 #define TPI_MASTER TPI_PRAGMA( TPI_DIR_MASTER )
72 #define TPI_WAIT TPI_PRAGMA( TPI_DIR_WAIT )
73 #define TPI_ORDERED TPI_PRAGMA( TPI_DIR_ORDERED )
74 #define TPI_SINGLE TPI_PRAGMA( TPI_DIR_SINGLE )
75 #define TPI_CLAUSE_SINGLE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_SINGLE, clause )
76 #define TPI_TASK TPI_PRAGMA( TPI_DIR_TASK )
77 #define TPI_TASK_SHARED TPI_PRAGMA_CLAUSE( TPI_DIR_TASK, \
78  TPI_CLAUSE_DEFAULT(shared) )
79 #define TPI_CLAUSE_TASK(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_TASK, clause )
80 #define TPI_TASKWAIT TPI_PRAGMA( TPI_DIR_TASKWAIT )
81 
82 
83 /* OpenMP pragma directives */
84 #define TPI_DIR_PARA omp parallel
85 #define TPI_DIR_FOR omp for
86 #define TPI_DIR_CRITICAL omp critical
87 #define TPI_DIR_MASTER omp master
88 #define TPI_DIR_WAIT omp barrier
89 #define TPI_DIR_ORDERED omp ordered
90 #define TPI_DIR_TASK omp task
91 #define TPI_DIR_SINGLE omp single
92 #define TPI_DIR_TASKWAIT omp taskwait
93 
94 
95 /* OpenMP clauses */
96 #define TPI_CLAUSE_PRIVATE(var) CONCATENATE( private, var )
97 #define TPI_CLAUSE_FSTPRIVATE(var) CONCATENATE( firstprivate, var )
98 #define TPI_CLAUSE_LSTPRIVATE(var) CONCATENATE( lastprivate, var )
99 #define TPI_CLAUSE_CPYPRIVATE(var) CONCATENATE( copyprivate, var )
100 #define TPI_CLAUSE_NOWAIT nowait
101 #define TPI_CLAUSE_SHARED(var) CONCATENATE( shared, var )
102 #define TPI_CLAUSE_DEFAULT(var) CONCATPARENTH( default, var )
103 /* The reduce clause requires op as either an operator or intrinsic procedure.
104  * Operators: +, *, .and., .or., .eqv., .neqv.
105  * intrinsic procedures: max, min, iand, ior, or ieor*/
106 #define TPI_CLAUSE_REDUCE(op, var) CONCATENATE( reduction, CONCATENATE( CONCATENATE( op, : ), var ) )
107 #define TPI_CLAUSE_ORDERED ordered
108 #define TPI_CLAUSE_IF(var) CONCATENATE( if, var )
109 #define TPI_CLAUSE_NUMTHREADS(var) CONCATENATE( num_threads, var )
110 #define TPI_CLAUSE_SCHEDULE(type) CONCATENATE( schedule, type )
111 #define TPI_CLAUSE_SCHEDULE_CHUNK(type, chunk) CONCATENATE( schedule, CONCATPARENTH( type, chunk ) )
112 #define TPI_CLAUSE_COPYIN(var) CONCATENATE( copyin, var )
113 #define TPI_CLAUSE_FINAL(var) CONCATENATE( final, var )
114 #define TPI_CLAUSE_UNTIED untied
115 #define TPI_CLAUSE_MERGEABLE mergeable
116 #define TPI_CLAUSE_DEPEND(type, var) CONCATENATE( depend, CONCATENATE( CONCATENATE( type, : ), var ) )
117 #define TPI_CLAUSE_PRIORITY(var) CONCATENATE( priority, var )
118 
119 
120 
121 #define TPI_SHARED_DATA(name, members) struct TPI_Shared_Data { \
122  members \
123  } name;
124 
125 #define TPI_PRIVATE_DATA(name, members) struct TPI_Private_Data { \
126  members \
127  } name;
128 
129 #define TPI_FSTPRIVATE_DATA(name, members) struct TPI_FirstPrivate_Data { \
130  members \
131  } name;
132 
133 #define TPI_LSTPRIVATE_DATA(name, members) struct TPI_LastPrivate_Data { \
134  members \
135  } name;
136 
137 #define TPI_COPYIN_DATA(name, members) struct TPI_CopyIn_Data { \
138  members \
139  } name;
140 
141 
142 #endif