llvm/openmp/runtime/src/kmp_sched.cpp

/*
 * kmp_sched.cpp -- static scheduling -- iteration initialization
 */

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

/* Static scheduling initialization.

  NOTE: team->t.t_nproc is a constant inside of any dispatch loop, however
        it may change values between parallel regions.  __kmp_max_nth
        is the largest value __kmp_nth may take, 1 is the smallest. */

#include "kmp.h"
#include "kmp_error.h"
#include "kmp_i18n.h"
#include "kmp_itt.h"
#include "kmp_stats.h"
#include "kmp_str.h"

#if OMPT_SUPPORT
#include "ompt-specific.h"
#endif

#ifdef KMP_DEBUG
//-------------------------------------------------------------------------
// template for debug prints specification ( d, u, lld, llu )
char const *traits_t<int>::spec = "d";
char const *traits_t<unsigned int>::spec = "u";
char const *traits_t<long long>::spec = "lld";
char const *traits_t<unsigned long long>::spec = "llu";
char const *traits_t<long>::spec = "ld";
//-------------------------------------------------------------------------
#endif

#if KMP_STATS_ENABLED
#define KMP_STATS_LOOP_END
#else
#define KMP_STATS_LOOP_END(stat)
#endif

#if USE_ITT_BUILD || defined KMP_DEBUG
static ident_t loc_stub =;
static inline void check_loc(ident_t *&loc) {}
#endif

template <typename T>
static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
                                  kmp_int32 schedtype, kmp_int32 *plastiter,
                                  T *plower, T *pupper,
                                  typename traits_t<T>::signed_t *pstride,
                                  typename traits_t<T>::signed_t incr,
                                  typename traits_t<T>::signed_t chunk
#if OMPT_SUPPORT && OMPT_OPTIONAL
                                  ,
                                  void *codeptr
#endif
) {}

template <typename T>
static void __kmp_dist_for_static_init(ident_t *loc, kmp_int32 gtid,
                                       kmp_int32 schedule, kmp_int32 *plastiter,
                                       T *plower, T *pupper, T *pupperDist,
                                       typename traits_t<T>::signed_t *pstride,
                                       typename traits_t<T>::signed_t incr,
                                       typename traits_t<T>::signed_t chunk
#if OMPT_SUPPORT && OMPT_OPTIONAL
                                       ,
                                       void *codeptr
#endif
) {}

template <typename T>
static void __kmp_team_static_init(ident_t *loc, kmp_int32 gtid,
                                   kmp_int32 *p_last, T *p_lb, T *p_ub,
                                   typename traits_t<T>::signed_t *p_st,
                                   typename traits_t<T>::signed_t incr,
                                   typename traits_t<T>::signed_t chunk) {}

//------------------------------------------------------------------------------
extern "C" {
/*!
@ingroup WORK_SHARING
@param    loc       Source code location
@param    gtid      Global thread id of this thread
@param    schedtype  Scheduling type
@param    plastiter Pointer to the "last iteration" flag
@param    plower    Pointer to the lower bound
@param    pupper    Pointer to the upper bound
@param    pstride   Pointer to the stride
@param    incr      Loop increment
@param    chunk     The chunk size

Each of the four functions here are identical apart from the argument types.

The functions compute the upper and lower bounds and stride to be used for the
set of iterations to be executed by the current thread from the statically
scheduled loop that is described by the initial values of the bounds, stride,
increment and chunk size.

@{
*/
void __kmpc_for_static_init_4(ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype,
                              kmp_int32 *plastiter, kmp_int32 *plower,
                              kmp_int32 *pupper, kmp_int32 *pstride,
                              kmp_int32 incr, kmp_int32 chunk) {}

/*!
 See @ref __kmpc_for_static_init_4
 */
void __kmpc_for_static_init_4u(ident_t *loc, kmp_int32 gtid,
                               kmp_int32 schedtype, kmp_int32 *plastiter,
                               kmp_uint32 *plower, kmp_uint32 *pupper,
                               kmp_int32 *pstride, kmp_int32 incr,
                               kmp_int32 chunk) {}

/*!
 See @ref __kmpc_for_static_init_4
 */
void __kmpc_for_static_init_8(ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype,
                              kmp_int32 *plastiter, kmp_int64 *plower,
                              kmp_int64 *pupper, kmp_int64 *pstride,
                              kmp_int64 incr, kmp_int64 chunk) {}

/*!
 See @ref __kmpc_for_static_init_4
 */
void __kmpc_for_static_init_8u(ident_t *loc, kmp_int32 gtid,
                               kmp_int32 schedtype, kmp_int32 *plastiter,
                               kmp_uint64 *plower, kmp_uint64 *pupper,
                               kmp_int64 *pstride, kmp_int64 incr,
                               kmp_int64 chunk) {}
/*!
@}
*/

#if OMPT_SUPPORT && OMPT_OPTIONAL
#define OMPT_CODEPTR_ARG
#else
#define OMPT_CODEPTR_ARG
#endif

/*!
@ingroup WORK_SHARING
@param    loc       Source code location
@param    gtid      Global thread id of this thread
@param    schedule  Scheduling type for the parallel loop
@param    plastiter Pointer to the "last iteration" flag
@param    plower    Pointer to the lower bound
@param    pupper    Pointer to the upper bound of loop chunk
@param    pupperD   Pointer to the upper bound of dist_chunk
@param    pstride   Pointer to the stride for parallel loop
@param    incr      Loop increment
@param    chunk     The chunk size for the parallel loop

Each of the four functions here are identical apart from the argument types.

The functions compute the upper and lower bounds and strides to be used for the
set of iterations to be executed by the current thread from the statically
scheduled loop that is described by the initial values of the bounds, strides,
increment and chunks for parallel loop and distribute constructs.

@{
*/
void __kmpc_dist_for_static_init_4(ident_t *loc, kmp_int32 gtid,
                                   kmp_int32 schedule, kmp_int32 *plastiter,
                                   kmp_int32 *plower, kmp_int32 *pupper,
                                   kmp_int32 *pupperD, kmp_int32 *pstride,
                                   kmp_int32 incr, kmp_int32 chunk) {}

/*!
 See @ref __kmpc_dist_for_static_init_4
 */
void __kmpc_dist_for_static_init_4u(ident_t *loc, kmp_int32 gtid,
                                    kmp_int32 schedule, kmp_int32 *plastiter,
                                    kmp_uint32 *plower, kmp_uint32 *pupper,
                                    kmp_uint32 *pupperD, kmp_int32 *pstride,
                                    kmp_int32 incr, kmp_int32 chunk) {}

/*!
 See @ref __kmpc_dist_for_static_init_4
 */
void __kmpc_dist_for_static_init_8(ident_t *loc, kmp_int32 gtid,
                                   kmp_int32 schedule, kmp_int32 *plastiter,
                                   kmp_int64 *plower, kmp_int64 *pupper,
                                   kmp_int64 *pupperD, kmp_int64 *pstride,
                                   kmp_int64 incr, kmp_int64 chunk) {}

/*!
 See @ref __kmpc_dist_for_static_init_4
 */
void __kmpc_dist_for_static_init_8u(ident_t *loc, kmp_int32 gtid,
                                    kmp_int32 schedule, kmp_int32 *plastiter,
                                    kmp_uint64 *plower, kmp_uint64 *pupper,
                                    kmp_uint64 *pupperD, kmp_int64 *pstride,
                                    kmp_int64 incr, kmp_int64 chunk) {}
/*!
@}
*/

//------------------------------------------------------------------------------
// Auxiliary routines for Distribute Parallel Loop construct implementation
//    Transfer call to template< type T >
//    __kmp_team_static_init( ident_t *loc, int gtid,
//        int *p_last, T *lb, T *ub, ST *st, ST incr, ST chunk )

/*!
@ingroup WORK_SHARING
@{
@param loc Source location
@param gtid Global thread id
@param p_last pointer to last iteration flag
@param p_lb  pointer to Lower bound
@param p_ub  pointer to Upper bound
@param p_st  Step (or increment if you prefer)
@param incr  Loop increment
@param chunk The chunk size to block with

The functions compute the upper and lower bounds and stride to be used for the
set of iterations to be executed by the current team from the statically
scheduled loop that is described by the initial values of the bounds, stride,
increment and chunk for the distribute construct as part of composite distribute
parallel loop construct. These functions are all identical apart from the types
of the arguments.
*/

void __kmpc_team_static_init_4(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
                               kmp_int32 *p_lb, kmp_int32 *p_ub,
                               kmp_int32 *p_st, kmp_int32 incr,
                               kmp_int32 chunk) {}

/*!
 See @ref __kmpc_team_static_init_4
 */
void __kmpc_team_static_init_4u(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
                                kmp_uint32 *p_lb, kmp_uint32 *p_ub,
                                kmp_int32 *p_st, kmp_int32 incr,
                                kmp_int32 chunk) {}

/*!
 See @ref __kmpc_team_static_init_4
 */
void __kmpc_team_static_init_8(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
                               kmp_int64 *p_lb, kmp_int64 *p_ub,
                               kmp_int64 *p_st, kmp_int64 incr,
                               kmp_int64 chunk) {}

/*!
 See @ref __kmpc_team_static_init_4
 */
void __kmpc_team_static_init_8u(ident_t *loc, kmp_int32 gtid, kmp_int32 *p_last,
                                kmp_uint64 *p_lb, kmp_uint64 *p_ub,
                                kmp_int64 *p_st, kmp_int64 incr,
                                kmp_int64 chunk) {}
/*!
@}
*/

} // extern "C"