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-2025 Zuse Institute Berlin (ZIB) */
    7/* */
    8/* Licensed under the Apache License, Version 2.0 (the "License"); */
    9/* you may not use this file except in compliance with the License. */
    10/* You may obtain a copy of the License at */
    11/* */
    12/* http://www.apache.org/licenses/LICENSE-2.0 */
    13/* */
    14/* Unless required by applicable law or agreed to in writing, software */
    15/* distributed under the License is distributed on an "AS IS" BASIS, */
    16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
    17/* See the License for the specific language governing permissions and */
    18/* limitations under the License. */
    19/* */
    20/* You should have received a copy of the Apache-2.0 license */
    21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
    22/* */
    23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    24
    25/**@file def_openmp.h
    26 * @ingroup TASKINTERFACE
    27 * @brief wrappers for OpenMP defines
    28 * @author Stephen J. Maher
    29 */
    30
    31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    32
    33#ifndef __DEF_OPENMP_H__
    34#define __DEF_OPENMP_H__
    35
    36#define STR(x) #x
    37#define STRINGIFY(x) STR(x)
    38#define CONCATENATE(x, y) x y
    39#define CONCATPARENTH(x, y) x ( y )
    40
    41#define TPI_NULL NULL
    42
    43#ifdef TPI_OMP
    44
    45#define TPI_PRAGMA_CLAUSE(directive, clause) _Pragma( STRINGIFY( CONCATENATE( directive, clause ) ) )
    46#define TPI_PRAGMA(directive) _Pragma( STRINGIFY( directive ) )
    47#define TPI_PRAGMA_PARENTH(directive, var) _Pragma( STRINGIFY( CONCATPARENTH( directive, var ) ) )
    48
    49#else
    50
    51#define TPI_PRAGMA_CLAUSE(directive, clause)
    52#define TPI_PRAGMA(directive)
    53#define TPI_PRAGMA_PARENTH(directive, var)
    54
    55#endif
    56
    57
    58#define TPI_FOR_CLAUSE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_FOR, clause )
    59#define TPI_FOR TPI_PRAGMA( TPI_DIR_FOR )
    60#define TPI_PARA_CLAUSE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, clause )
    61
    62#define TPI_PARA_CLAUSE_SHARED(priv, clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
    63 TPI_CLAUSE_DEFAULT( shared ) \
    64 TPI_CLAUSE_PRIVATE( (priv) ) clause )
    65
    66#define TPI_PARA_SHARED TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
    67 TPI_CLAUSE_DEFAULT( shared ) )
    68
    69#define TPI_PARA_SHARED_PRIVATE(priv) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
    70 TPI_CLAUSE_DEFAULT( shared ) \
    71 TPI_CLAUSE_PRIVATE( ( priv ) ) )
    72
    73#define TPI_PARA_CLAUSE_NONE(share, priv, clause) TPI_PRAGMA_CLAUSE( TPI_DIR_PARA, \
    74 TPI_CLAUSE_DEFAULT( (none) ) \
    75 TPI_CLAUSE_SHARED( (share) ) \
    76 TPI_CLAUSE_PRIVATE( (priv) ) clause )
    77
    78#define TPI_PARA TPI_PRAGMA( TPI_DIR_PARA )
    79#define TPI_CRITICAL(var) TPI_PRAGMA_PARENTH( TPI_DIR_CRITICAL, var)
    80#define TPI_MASTER TPI_PRAGMA( TPI_DIR_MASTER )
    81#define TPI_WAIT TPI_PRAGMA( TPI_DIR_WAIT )
    82#define TPI_ORDERED TPI_PRAGMA( TPI_DIR_ORDERED )
    83#define TPI_SINGLE TPI_PRAGMA( TPI_DIR_SINGLE )
    84#define TPI_CLAUSE_SINGLE(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_SINGLE, clause )
    85#define TPI_TASK TPI_PRAGMA( TPI_DIR_TASK )
    86#define TPI_TASK_SHARED TPI_PRAGMA_CLAUSE( TPI_DIR_TASK, \
    87 TPI_CLAUSE_DEFAULT(shared) )
    88#define TPI_CLAUSE_TASK(clause) TPI_PRAGMA_CLAUSE( TPI_DIR_TASK, clause )
    89#define TPI_TASKWAIT TPI_PRAGMA( TPI_DIR_TASKWAIT )
    90
    91
    92/* OpenMP pragma directives */
    93#define TPI_DIR_PARA omp parallel
    94#define TPI_DIR_FOR omp for
    95#define TPI_DIR_CRITICAL omp critical
    96#define TPI_DIR_MASTER omp master
    97#define TPI_DIR_WAIT omp barrier
    98#define TPI_DIR_ORDERED omp ordered
    99#define TPI_DIR_TASK omp task
    100#define TPI_DIR_SINGLE omp single
    101#define TPI_DIR_TASKWAIT omp taskwait
    102
    103
    104/* OpenMP clauses */
    105#define TPI_CLAUSE_PRIVATE(var) CONCATENATE( private, var )
    106#define TPI_CLAUSE_FSTPRIVATE(var) CONCATENATE( firstprivate, var )
    107#define TPI_CLAUSE_LSTPRIVATE(var) CONCATENATE( lastprivate, var )
    108#define TPI_CLAUSE_CPYPRIVATE(var) CONCATENATE( copyprivate, var )
    109#define TPI_CLAUSE_NOWAIT nowait
    110#define TPI_CLAUSE_SHARED(var) CONCATENATE( shared, var )
    111#define TPI_CLAUSE_DEFAULT(var) CONCATPARENTH( default, var )
    112/* The reduce clause requires op as either an operator or intrinsic procedure.
    113 * Operators: +, *, .and., .or., .eqv., .neqv.
    114 * intrinsic procedures: max, min, iand, ior, or ieor*/
    115#define TPI_CLAUSE_REDUCE(op, var) CONCATENATE( reduction, CONCATENATE( CONCATENATE( op, : ), var ) )
    116#define TPI_CLAUSE_ORDERED ordered
    117#define TPI_CLAUSE_IF(var) CONCATENATE( if, var )
    118#define TPI_CLAUSE_NUMTHREADS(var) CONCATENATE( num_threads, var )
    119#define TPI_CLAUSE_SCHEDULE(type) CONCATENATE( schedule, type )
    120#define TPI_CLAUSE_SCHEDULE_CHUNK(type, chunk) CONCATENATE( schedule, CONCATPARENTH( type, chunk ) )
    121#define TPI_CLAUSE_COPYIN(var) CONCATENATE( copyin, var )
    122#define TPI_CLAUSE_FINAL(var) CONCATENATE( final, var )
    123#define TPI_CLAUSE_UNTIED untied
    124#define TPI_CLAUSE_MERGEABLE mergeable
    125#define TPI_CLAUSE_DEPEND(type, var) CONCATENATE( depend, CONCATENATE( CONCATENATE( type, : ), var ) )
    126#define TPI_CLAUSE_PRIORITY(var) CONCATENATE( priority, var )
    127
    128
    129
    130#define TPI_SHARED_DATA(name, members) struct TPI_Shared_Data { \
    131 members \
    132 } name;
    133
    134#define TPI_PRIVATE_DATA(name, members) struct TPI_Private_Data { \
    135 members \
    136 } name;
    137
    138#define TPI_FSTPRIVATE_DATA(name, members) struct TPI_FirstPrivate_Data { \
    139 members \
    140 } name;
    141
    142#define TPI_LSTPRIVATE_DATA(name, members) struct TPI_LastPrivate_Data { \
    143 members \
    144 } name;
    145
    146#define TPI_COPYIN_DATA(name, members) struct TPI_CopyIn_Data { \
    147 members \
    148 } name;
    149
    150
    151#endif