• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ KMP_DEBUG_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中KMP_DEBUG_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ KMP_DEBUG_ASSERT函数的具体用法?C++ KMP_DEBUG_ASSERT怎么用?C++ KMP_DEBUG_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了KMP_DEBUG_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: __kmp_common_initialize

/* we are called from __kmp_serial_initialize() with __kmp_initz_lock held. */
void
__kmp_common_initialize( void )
{
    if( ! TCR_4(__kmp_init_common) ) {
        int q;
#ifdef KMP_DEBUG
        int gtid;
#endif

        __kmp_threadpriv_cache_list = NULL;

#ifdef KMP_DEBUG
        /* verify the uber masters were initialized */
        for(gtid = 0 ; gtid < __kmp_threads_capacity; gtid++ )
            if( __kmp_root[gtid] ) {
                KMP_DEBUG_ASSERT( __kmp_root[gtid]->r.r_uber_thread );
                for ( q = 0; q< KMP_HASH_TABLE_SIZE; ++q)
                    KMP_DEBUG_ASSERT( !__kmp_root[gtid]->r.r_uber_thread->th.th_pri_common->data[q] );
/*                    __kmp_root[ gitd ]-> r.r_uber_thread -> th.th_pri_common -> data[ q ] = 0;*/
            }
#endif /* KMP_DEBUG */

        for (q = 0; q < KMP_HASH_TABLE_SIZE; ++q)
            __kmp_threadprivate_d_table.data[ q ] = 0;

        TCW_4(__kmp_init_common, TRUE);
    }
}
开发者ID:clang-ykt,项目名称:openmp,代码行数:29,代码来源:kmp_threadprivate.c


示例2: __kmp_str_buf_cat

void
__kmp_str_buf_cat(
    kmp_str_buf_t * buffer,
    char const *    str,
    int             len
) {
    KMP_STR_BUF_INVARIANT( buffer );
    KMP_DEBUG_ASSERT( str != NULL );
    KMP_DEBUG_ASSERT( len >= 0 );
    __kmp_str_buf_reserve( buffer, buffer->used + len + 1 );
    memcpy( buffer->str + buffer->used, str, len );
    buffer->str[ buffer->used + len ] = 0;
    buffer->used += len;
    KMP_STR_BUF_INVARIANT( buffer );
} // __kmp_str_buf_cat
开发者ID:niober123,项目名称:ompt-intel-openmp,代码行数:15,代码来源:kmp_str.c


示例3: __kmp_env_free

void __kmp_env_free(char const **value) {

  KMP_DEBUG_ASSERT(value != NULL);
  KMP_INTERNAL_FREE(CCAST(char *, *value));
  *value = NULL;

} // func __kmp_env_free
开发者ID:hfinkel,项目名称:openmp-bgq,代码行数:7,代码来源:kmp_environment.cpp


示例4: kmp_threadprivate_insert_private_data

void
kmp_threadprivate_insert_private_data( int gtid, void *pc_addr, void *data_addr, size_t pc_size )
{
    struct shared_common **lnk_tn, *d_tn;
    KMP_DEBUG_ASSERT( __kmp_threads[ gtid ] &&
            __kmp_threads[ gtid ] -> th.th_root -> r.r_active == 0 );

    d_tn = __kmp_find_shared_task_common( &__kmp_threadprivate_d_table,
                                          gtid, pc_addr );

    if (d_tn == 0) {
        d_tn = (struct shared_common *) __kmp_allocate( sizeof( struct shared_common ) );

        d_tn->gbl_addr = pc_addr;
        d_tn->pod_init = __kmp_init_common_data( data_addr, pc_size );
/*
        d_tn->obj_init = 0;  // AC: commented out because __kmp_allocate zeroes the memory
        d_tn->ct.ctor = 0;
        d_tn->cct.cctor = 0;;
        d_tn->dt.dtor = 0;
        d_tn->is_vec = FALSE;
        d_tn->vec_len = 0L;
*/
        d_tn->cmn_size = pc_size;

        __kmp_acquire_lock( &__kmp_global_lock, gtid );

        lnk_tn = &(__kmp_threadprivate_d_table.data[ KMP_HASH(pc_addr) ]);

        d_tn->next = *lnk_tn;
        *lnk_tn = d_tn;

        __kmp_release_lock( &__kmp_global_lock, gtid );
    }
}
开发者ID:clang-ykt,项目名称:openmp,代码行数:35,代码来源:kmp_threadprivate.c


示例5: ___kmp_env_blk_parse_string

static
void
___kmp_env_blk_parse_string(
    kmp_env_blk_t * block,   // M: Env block to fill.
    char const *    env      // I: String to parse.
) {

    char const chr_delimiter   = '|';
    char const str_delimiter[] = { chr_delimiter, 0 };

    char *          bulk       = NULL;
    kmp_env_var_t * vars       = NULL;
    int             count      = 0;  // Number of used elements in vars array.
    int             delimiters = 0;  // Number of delimiters in input string.

    // Copy original string, we will modify the copy.
    bulk = __kmp_str_format( "%s", env );

    // Loop thru all the vars in environment block. Count delimiters (maximum number of variables
    // is number of delimiters plus one).
    {
        char const * ptr = bulk;
        for ( ; ; ) {
            ptr = strchr( ptr, chr_delimiter );
            if ( ptr == NULL ) {
                break;
            }; // if
            ++ delimiters;
            ptr += 1;
        }; // forever
    }

    // Allocate vars array.
    vars = (kmp_env_var_t *) allocate( ( delimiters + 1 ) * sizeof( kmp_env_var_t ) );

    // Loop thru all the variables.
    {
        char * var;     // Pointer to variable (both name and value).
        char * name;    // Pointer to name of variable.
        char * value;   // Pointer to value.
        char * buf;     // Buffer for __kmp_str_token() function.
        var = __kmp_str_token( bulk, str_delimiter, & buf );      // Get the first var.
        while ( var != NULL ) {
            // Save found variable in vars array.
            __kmp_str_split( var, '=', & name, & value );
            KMP_DEBUG_ASSERT( count < delimiters + 1 );
            vars[ count ].name  = name;
            vars[ count ].value = value;
            ++ count;
            // Get the next var.
            var = __kmp_str_token( NULL, str_delimiter, & buf );
        }; // while
    }

    // Fill out result.
    block->bulk  = bulk;
    block->vars  = vars;
    block->count = count;

}; // ___kmp_env_blk_parse_string
开发者ID:haraldservat,项目名称:LLVM-openmp,代码行数:60,代码来源:kmp_environment.c


示例6: __kmp_pragma

// NOTE: Function returns allocated memory, caller must free it!
static char const *
__kmp_pragma(
    int              ct,
    ident_t const *  ident
) {
    char const * cons = NULL;  // Construct name.
    char * file = NULL;  // File name.
    char * func = NULL;  // Function (routine) name.
    char * line = NULL;  // Line number.
    kmp_str_buf_t buffer;
    kmp_msg_t     prgm;
    __kmp_str_buf_init( & buffer );
    if ( 0 < ct && ct < cons_text_c_num ) {
        cons = cons_text_c[ ct ];
    } else {
        KMP_DEBUG_ASSERT( 0 );
    };
    if ( ident != NULL && ident->psource != NULL ) {
        char * tail = NULL;
        __kmp_str_buf_print( & buffer, "%s", ident->psource ); // Copy source to buffer.
        // Split string in buffer to file, func, and line.
        tail = buffer.str;
        __kmp_str_split( tail, ';', NULL,   & tail );
        __kmp_str_split( tail, ';', & file, & tail );
        __kmp_str_split( tail, ';', & func, & tail );
        __kmp_str_split( tail, ';', & line, & tail );
    }; // if
    prgm = __kmp_msg_format( kmp_i18n_fmt_Pragma, cons, file, func, line );
    __kmp_str_buf_free( & buffer );
    return prgm.str;
} // __kmp_pragma
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:32,代码来源:kmp_error.cpp


示例7: __kmp_str_free

void
__kmp_str_free(
    char const * * str
) {
    KMP_DEBUG_ASSERT( str != NULL );
    KMP_INTERNAL_FREE( (void *) * str );
    * str = NULL;
} // func __kmp_str_free
开发者ID:niober123,项目名称:ompt-intel-openmp,代码行数:8,代码来源:kmp_str.c


示例8: __kmpc_team_static_init_8u

/*!
 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 )
{
    KMP_DEBUG_ASSERT( __kmp_init_serial );
    __kmp_team_static_init< kmp_uint64 >( loc, gtid, p_last, p_lb, p_ub, p_st, incr, chunk );
}
开发者ID:haraldservat,项目名称:LLVM-openmp,代码行数:11,代码来源:kmp_sched.cpp


示例9: __kmp_common_destroy_gtid

/* Call all destructors for threadprivate data belonging to this thread */
void
__kmp_common_destroy_gtid( int gtid )
{
    struct private_common *tn;
    struct shared_common *d_tn;

    KC_TRACE( 10, ("__kmp_common_destroy_gtid: T#%d called\n", gtid ) );
    if( (__kmp_foreign_tp) ? (! KMP_INITIAL_GTID (gtid)) :
                             (! KMP_UBER_GTID (gtid)) ) {

        if( TCR_4(__kmp_init_common) ) {

#if KMP_THREADPRIVATE_TLS

            for(d_tn = kmpc_threadprivate_d_table_data_head_local;
                d_tn != NULL;
                d_tn = d_tn->next) {
                // call destructor
                if (d_tn->dt.dtor) d_tn->dt.dtor(NULL);
            }

#else


            /* Cannot do this here since not all threads have destroyed their data */
            /* TCW_4(__kmp_init_common, FALSE); */

            for (tn = __kmp_threads[ gtid ]->th.th_pri_head; tn; tn = tn->link) {

                d_tn = __kmp_find_shared_task_common( &__kmp_threadprivate_d_table,
                                                      gtid, tn->gbl_addr );

                KMP_DEBUG_ASSERT( d_tn );

                if (d_tn->is_vec) {
                    if (d_tn->dt.dtorv != 0) {
                        (void) (*d_tn->dt.dtorv) (tn->par_addr, d_tn->vec_len);
                    }
                    if (d_tn->obj_init != 0) {
                        (void) (*d_tn->dt.dtorv) (d_tn->obj_init, d_tn->vec_len);
                    }
                } else {
                    if (d_tn->dt.dtor != 0) {
                        (void) (*d_tn->dt.dtor) (tn->par_addr);
                    }
                    if (d_tn->obj_init != 0) {
                        (void) (*d_tn->dt.dtor) (d_tn->obj_init);
                    }
                }
            }
#endif
            KC_TRACE( 30, ("__kmp_common_destroy_gtid: T#%d threadprivate destructors complete\n",
                           gtid ) );
        }
    }
}
开发者ID:clang-ykt,项目名称:openmp,代码行数:57,代码来源:kmp_threadprivate.c


示例10: __kmp_i18n_catclose

void
__kmp_i18n_catclose(
) {
    if ( status == KMP_I18N_OPENED ) {
        KMP_DEBUG_ASSERT( cat != KMP_I18N_NULLCAT );
        catclose( cat );
        cat = KMP_I18N_NULLCAT;
    }; // if
    status = KMP_I18N_CLOSED;
} // func __kmp_i18n_catclose
开发者ID:PRUNER,项目名称:openmp,代码行数:10,代码来源:kmp_i18n.c


示例11: __kmp_str_to_uint

void
__kmp_str_to_uint(         // R: Error code.
    char const *   str,    // I: String of characters, unsigned number.
    kmp_uint64 *   out,    // O: Parsed number.
    char const * * error   // O: Null if everything is ok, error message otherwise.
) {

    size_t value    = 0;
    int    overflow = 0;
    int    i        = 0;
    int    digit;


    KMP_DEBUG_ASSERT( str != NULL );

    // Skip spaces.
    while ( str[ i ] == ' ' || str[ i ] == '\t' ) {
        ++ i;
    }; // while

    // Parse number.
    if ( str[ i ] < '0' || str[ i ] > '9' ) {
        * error = KMP_I18N_STR( NotANumber );
        return;
    }; // if
    do {
        digit = str[ i ] - '0';
        overflow = overflow || ( value > ( KMP_SIZE_T_MAX - digit ) / 10 );
        value = ( value * 10 ) + digit;
        ++ i;
    } while ( str[ i ] >= '0' && str[ i ] <= '9' );

    // Skip spaces.
    while ( str[ i ] == ' ' || str[ i ] == '\t' ) {
        ++ i;
    }; // while

    if ( str[ i ] != 0 ) {
        * error = KMP_I18N_STR( IllegalCharacters );
        return;
    }; // if

    if ( overflow ) {
        * error = KMP_I18N_STR( ValueTooLarge );
        * out = (kmp_uint64) -1;
        return;
    }; // if

    * error = NULL;
    * out = value;

} // __kmp_str_to_unit
开发者ID:niober123,项目名称:ompt-intel-openmp,代码行数:52,代码来源:kmp_str.c


示例12: KMP_DEBUG_ASSERT

// stop/save the current timer, and start the new timer (timer_pair)
// There is a special condition where if the current timer is equal to
// the one you are trying to push, then it only manipulates the stack,
// and it won't stop/start the currently running timer.
void partitionedTimers::push(timerPair timer_pair) {
  // get the current timer
  // stop current timer
  // push new timer
  // start the new timer
  KMP_DEBUG_ASSERT(this->timer_stack.size() > 0);
  timerPair current_timer = timer_stack.back();
  timer_stack.push_back(timer_pair);
  if (current_timer != timer_pair) {
    timers[current_timer.get_index()]->pause();
    timers[timer_pair.get_index()]->start(timer_pair.get_timer());
  }
}
开发者ID:hfinkel,项目名称:openmp-bgq,代码行数:17,代码来源:kmp_stats.cpp


示例13: __kmp_str_buf_reserve

void
__kmp_str_buf_reserve(
    kmp_str_buf_t * buffer,
    int             size
) {

    KMP_STR_BUF_INVARIANT( buffer );
    KMP_DEBUG_ASSERT( size >= 0 );

    if ( buffer->size < size ) {

        // Calculate buffer size.
        do {
            buffer->size *= 2;
        } while ( buffer->size < size );

        // Enlarge buffer.
        if ( buffer->str == & buffer->bulk[ 0 ] ) {
            buffer->str = (char *) KMP_INTERNAL_MALLOC( buffer->size );
            if ( buffer->str == NULL ) {
		KMP_FATAL( MemoryAllocFailed );
            }; // if
            memcpy( buffer->str, buffer->bulk, buffer->used + 1 );
        } else {
            buffer->str = (char *) KMP_INTERNAL_REALLOC( buffer->str, buffer->size );
            if ( buffer->str == NULL ) {
		KMP_FATAL( MemoryAllocFailed );
            }; // if
        }; // if

    }; // if

    KMP_DEBUG_ASSERT( buffer->size > 0 );
    KMP_DEBUG_ASSERT( buffer->size >= size );
    KMP_STR_BUF_INVARIANT( buffer );

} // __kmp_str_buf_reserve
开发者ID:niober123,项目名称:ompt-intel-openmp,代码行数:37,代码来源:kmp_str.c


示例14: __kmpc_cancel_barrier

/*!
@ingroup CANCELLATION
@param loc_ref location of the original task directive
@param gtid Global thread ID of encountering thread

@return returns true if a matching cancellation request has been flagged in the
RTL and the encountering thread has to cancel..

Barrier with cancellation point to send threads from the barrier to the
end of the parallel region.  Needs a special code pattern as documented
in the design document for the cancellation feature.
*/
kmp_int32 __kmpc_cancel_barrier(ident_t *loc, kmp_int32 gtid) {
  int ret = 0 /* false */;
  kmp_info_t *this_thr = __kmp_threads[gtid];
  kmp_team_t *this_team = this_thr->th.th_team;

  KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);

  // call into the standard barrier
  __kmpc_barrier(loc, gtid);

  // if cancellation is active, check cancellation flag
  if (__kmp_omp_cancellation) {
    // depending on which construct to cancel, check the flag and
    // reset the flag
    switch (KMP_ATOMIC_LD_RLX(&(this_team->t.t_cancel_request))) {
    case cancel_parallel:
      ret = 1;
      // ensure that threads have checked the flag, when
      // leaving the above barrier
      __kmpc_barrier(loc, gtid);
      this_team->t.t_cancel_request = cancel_noreq;
      // the next barrier is the fork/join barrier, which
      // synchronizes the threads leaving here
      break;
    case cancel_loop:
    case cancel_sections:
      ret = 1;
      // ensure that threads have checked the flag, when
      // leaving the above barrier
      __kmpc_barrier(loc, gtid);
      this_team->t.t_cancel_request = cancel_noreq;
      // synchronize the threads again to make sure we do not have any run-away
      // threads that cause a race on the cancellation flag
      __kmpc_barrier(loc, gtid);
      break;
    case cancel_taskgroup:
      // this case should not occur
      KMP_ASSERT(0 /* false */);
      break;
    case cancel_noreq:
      // do nothing
      break;
    default:
      KMP_ASSERT(0 /* false */);
    }
  }

  return ret;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:61,代码来源:kmp_cancel.cpp


示例15: __kmp_push_parallel

void
__kmp_push_parallel( int gtid, ident_t const * ident )
{
    int tos;
    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;

    KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
    KE_TRACE( 10, ("__kmp_push_parallel (%d %d)\n", gtid, __kmp_get_gtid() ) );
    KE_TRACE( 100, ( PUSH_MSG( ct_parallel, ident ) ) );
    if ( p->stack_top >= p->stack_size ) {
        __kmp_expand_cons_stack( gtid, p );
    }; // if
    tos = ++p->stack_top;
    p->stack_data[ tos ].type = ct_parallel;
    p->stack_data[ tos ].prev = p->p_top;
    p->stack_data[ tos ].ident = ident;
    p->stack_data[ tos ].name = NULL;
    p->p_top = tos;
    KE_DUMP( 1000, dump_cons_stack( gtid, p ) );
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:20,代码来源:kmp_error.cpp


示例16: __kmp_check_workshare

void
__kmp_check_workshare( int gtid, enum cons_type ct, ident_t const * ident )
{
    struct cons_header *p = __kmp_threads[ gtid ]->th.th_cons;

    KMP_DEBUG_ASSERT( __kmp_threads[ gtid ]-> th.th_cons );
    KE_TRACE( 10, ("__kmp_check_workshare (%d %d)\n", gtid, __kmp_get_gtid() ) );


    if ( p->stack_top >= p->stack_size ) {
        __kmp_expand_cons_stack( gtid, p );
    }; // if
    if ( p->w_top > p->p_top &&
        !(IS_CONS_TYPE_TASKQ(p->stack_data[ p->w_top ].type) && IS_CONS_TYPE_TASKQ(ct))) {
        // We are already in a WORKSHARE construct for this PARALLEL region.
        __kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->w_top ] );
    }; // if
    if ( p->s_top > p->p_top ) {
        // We are already in a SYNC construct for this PARALLEL region.
        __kmp_error_construct2( kmp_i18n_msg_CnsInvalidNesting, ct, ident, & p->stack_data[ p->s_top ] );
    }; // if
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:22,代码来源:kmp_error.cpp


示例17: __kmp_str_buf_vprint

void
__kmp_str_buf_vprint(
    kmp_str_buf_t *  buffer,
    char const *     format,
    va_list          args
) {

    KMP_STR_BUF_INVARIANT( buffer );

    for ( ; ; ) {

        int const free = buffer->size - buffer->used;
        int       rc;
        int       size;

        // Try to format string.
        {
            /*
                On Linux* OS Intel(R) 64, vsnprintf() modifies args argument, so vsnprintf() crashes if it
                is called for the second time with the same args. To prevent the crash, we have to
                pass a fresh intact copy of args to vsnprintf() on each iteration.

                Unfortunately, standard va_copy() macro is not available on Windows* OS. However, it
                seems vsnprintf() does not modify args argument on Windows* OS.
            */

            #if ! KMP_OS_WINDOWS
                va_list _args;
                __va_copy( _args, args );  // Make copy of args.
                #define args _args         // Substitute args with its copy, _args.
            #endif // KMP_OS_WINDOWS
            rc = vsnprintf( buffer->str + buffer->used, free, format, args );
            #if ! KMP_OS_WINDOWS
                #undef args                // Remove substitution.
                va_end( _args );
            #endif // KMP_OS_WINDOWS
        }

        // No errors, string has been formatted.
        if ( rc >= 0 && rc < free ) {
            buffer->used += rc;
            break;
        }; // if

        // Error occured, buffer is too small.
        if ( rc >= 0 ) {
            // C99-conforming implementation of vsnprintf returns required buffer size.
            size = buffer->used + rc + 1;
        } else {
            // Older implementations just return -1. Double buffer size.
            size = buffer->size * 2;
        }; // if

        // Enlarge buffer.
        __kmp_str_buf_reserve( buffer, size );

        // And try again.

    }; // forever

    KMP_DEBUG_ASSERT( buffer->size > 0 );
    KMP_STR_BUF_INVARIANT( buffer );

} // __kmp_str_buf_vprint
开发者ID:niober123,项目名称:ompt-intel-openmp,代码行数:64,代码来源:kmp_str.c


示例18: __kmp_team_static_init

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
) {
    // The routine returns the first chunk distributed to the team and
    // stride for next chunks calculation.
    // Last iteration flag set for the team that will execute
    // the last iteration of the loop.
    // The routine is called for dist_schedue(static,chunk) only.
    typedef typename traits_t< T >::unsigned_t  UT;
    typedef typename traits_t< T >::signed_t    ST;
    kmp_uint32  team_id;
    kmp_uint32  nteams;
    UT          trip_count;
    T           lower;
    T           upper;
    ST          span;
    kmp_team_t *team;
    kmp_info_t *th;

    KMP_DEBUG_ASSERT( p_last && p_lb && p_ub && p_st );
    KE_TRACE( 10, ("__kmp_team_static_init called (%d)\n", gtid));
    #ifdef KMP_DEBUG
    {
        const char * buff;
        // create format specifiers before the debug output
        buff = __kmp_str_format( "__kmp_team_static_init enter: T#%%d liter=%%d "\
            "iter=(%%%s, %%%s, %%%s) chunk %%%s; signed?<%s>\n",
            traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec,
            traits_t< ST >::spec, traits_t< T >::spec );
        KD_TRACE(100, ( buff, gtid, *p_last, *p_lb, *p_ub, *p_st, chunk ) );
        __kmp_str_free( &buff );
    }
    #endif

    lower = *p_lb;
    upper = *p_ub;
    if( __kmp_env_consistency_check ) {
        if( incr == 0 ) {
            __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc );
        }
        if( incr > 0 ? (upper < lower) : (lower < upper) ) {
            // The loop is illegal.
            // Some zero-trip loops maintained by compiler, e.g.:
            //   for(i=10;i<0;++i) // lower >= upper - run-time check
            //   for(i=0;i>10;--i) // lower <= upper - run-time check
            //   for(i=0;i>10;++i) // incr > 0       - compile-time check
            //   for(i=10;i<0;--i) // incr < 0       - compile-time check
            // Compiler does not check the following illegal loops:
            //   for(i=0;i<10;i+=incr) // where incr<0
            //   for(i=10;i>0;i-=incr) // where incr<0
            __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrIllegal, ct_pdo, loc );
        }
    }
    th = __kmp_threads[gtid];
    KMP_DEBUG_ASSERT(th->th.th_teams_microtask);   // we are in the teams construct
    team = th->th.th_team;
    #if OMP_40_ENABLED
    nteams = th->th.th_teams_size.nteams;
    #endif
    team_id = team->t.t_master_tid;
    KMP_DEBUG_ASSERT(nteams == team->t.t_parent->t.t_nproc);

    // compute trip count
    if( incr == 1 ) {
        trip_count = upper - lower + 1;
    } else if(incr == -1) {
        trip_count = lower - upper + 1;
    } else {
        trip_count = (ST)(upper - lower) / incr + 1; // cast to signed to cover incr<0 case
    }
    if( chunk < 1 )
        chunk = 1;
    span = chunk * incr;
    *p_st = span * nteams;
    *p_lb = lower + (span * team_id);
    *p_ub = *p_lb + span - incr;
    if ( p_last != NULL )
        *p_last = (team_id == ((trip_count - 1)/(UT)chunk) % nteams);
    // Correct upper bound if needed
    if( incr > 0 ) {
        if( *p_ub < *p_lb ) // overflow?
            *p_ub = i_maxmin< T >::mx;
        if( *p_ub > upper )
            *p_ub = upper; // tracker C73258
    } else {   // incr < 0
        if( *p_ub > *p_lb )
            *p_ub = i_maxmin< T >::mn;
        if( *p_ub < upper )
            *p_ub = upper; // tracker C73258
    }
    #ifdef KMP_DEBUG
    {
//.........这里部分代码省略.........
开发者ID:haraldservat,项目名称:LLVM-openmp,代码行数:101,代码来源:kmp_sched.cpp


示例19: __kmp_for_static_init

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
) {
    KMP_COUNT_BLOCK(OMP_FOR_static);
    typedef typename traits_t< T >::unsigned_t  UT;
    typedef typename traits_t< T >::signed_t    ST;
    /*  this all has to be changed back to TID and such.. */
    register kmp_int32   gtid = global_tid;
    register kmp_uint32  tid;
    register kmp_uint32  nth;
    register UT          trip_count;
    register kmp_team_t *team;
    register kmp_info_t *th = __kmp_threads[ gtid ];

#if OMPT_SUPPORT && OMPT_TRACE
    ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
    ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
#endif

    KMP_DEBUG_ASSERT( plastiter && plower && pupper && pstride );
    KE_TRACE( 10, ("__kmpc_for_static_init called (%d)\n", global_tid));
    #ifdef KMP_DEBUG
    {
        const char * buff;
        // create format specifiers before the debug output
        buff = __kmp_str_format(
            "__kmpc_for_static_init: T#%%d sched=%%d liter=%%d iter=(%%%s," \
            " %%%s, %%%s) incr=%%%s chunk=%%%s signed?<%s>\n",
            traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec,
            traits_t< ST >::spec, traits_t< ST >::spec, traits_t< T >::spec );
        KD_TRACE(100, ( buff, global_tid, schedtype, *plastiter,
            *plower, *pupper, *pstride, incr, chunk ) );
        __kmp_str_free( &buff );
    }
    #endif

    if ( __kmp_env_consistency_check ) {
        __kmp_push_workshare( global_tid, ct_pdo, loc );
        if ( incr == 0 ) {
            __kmp_error_construct( kmp_i18n_msg_CnsLoopIncrZeroProhibited, ct_pdo, loc );
        }
    }
    /* special handling for zero-trip loops */
    if ( incr > 0 ? (*pupper < *plower) : (*plower < *pupper) ) {
        if( plastiter != NULL )
            *plastiter = FALSE;
        /* leave pupper and plower set to entire iteration space */
        *pstride = incr;   /* value should never be used */
	//        *plower = *pupper - incr;   // let compiler bypass the illegal loop (like for(i=1;i<10;i--))  THIS LINE CAUSED shape2F/h_tests_1.f TO HAVE A FAILURE ON A ZERO-TRIP LOOP (lower=1,\
	  upper=0,stride=1) - JPH June 23, 2009.
        #ifdef KMP_DEBUG
        {
            const char * buff;
            // create format specifiers before the debug output
            buff = __kmp_str_format(
                "__kmpc_for_static_init:(ZERO TRIP) liter=%%d lower=%%%s upper=%%%s stride = %%%s signed?<%s>, loc = %%s\n",
                traits_t< T >::spec, traits_t< T >::spec, traits_t< ST >::spec, traits_t< T >::spec );
            KD_TRACE(100, ( buff, *plastiter, *plower, *pupper, *pstride, loc->psource ) );
            __kmp_str_free( &buff );
        }
        #endif
        KE_TRACE( 10, ("__kmpc_for_static_init: T#%d return\n", global_tid ) );

#if OMPT_SUPPORT && OMPT_TRACE
        if ((ompt_status == ompt_status_track_callback) &&
            ompt_callbacks.ompt_callback(ompt_event_loop_begin)) {
            ompt_callbacks.ompt_callback(ompt_event_loop_begin)(
                team_info->parallel_id, task_info->task_id,
                team_info->microtask);
        }
#endif
        return;
    }

    #if OMP_40_ENABLED
    if ( schedtype > kmp_ord_upper ) {
        // we are in DISTRIBUTE construct
        schedtype += kmp_sch_static - kmp_distribute_static;      // AC: convert to usual schedule type
        tid  = th->th.th_team->t.t_master_tid;
        team = th->th.th_team->t.t_parent;
    } else
    #endif
    {
        tid  = __kmp_tid_from_gtid( global_tid );
        team = th->th.th_team;
    }

    /* determine if "for" loop is an active worksharing construct */
    if ( team -> t.t_serialized ) {
        /* serialized parallel, each thread executes whole iteration space */
        if( plastiter != NULL )
//.........这里部分代码省略.........
开发者ID:haraldservat,项目名称:LLVM-openmp,代码行数:101,代码来源:kmp_sched.cpp


示例20: kind

/*!
@ingroup CANCELLATION
@param loc_ref location of the original task directive
@param gtid Global thread ID of encountering thread
@param cncl_kind Cancellation kind (parallel, for, sections, taskgroup)

@return returns true if the cancellation request has been activated and the
execution thread needs to proceed to the end of the canceled region.

Request cancellation of the binding OpenMP region.
*/
kmp_int32 __kmpc_cancel(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
  kmp_info_t *this_thr = __kmp_threads[gtid];

  KC_TRACE(10, ("__kmpc_cancel: T#%d request %d OMP_CANCELLATION=%d\n", gtid,
                cncl_kind, __kmp_omp_cancellation));

  KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
  KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
                   cncl_kind == cancel_sections ||
                   cncl_kind == cancel_taskgroup);
  KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);

  if (__kmp_omp_cancellation) {
    switch (cncl_kind) {
    case cancel_parallel:
    case cancel_loop:
    case cancel_sections:
      // cancellation requests for parallel and worksharing constructs
      // are handled through the team structure
      {
        kmp_team_t *this_team = this_thr->th.th_team;
        KMP_DEBUG_ASSERT(this_team);
        kmp_int32 old = cancel_noreq;
        this_team->t.t_cancel_request.compare_exchange_strong(old, cncl_kind);
        if (old == cancel_noreq || old == cncl_kind) {
// we do not have a cancellation request in this team or we do have
// one that matches the current request -> cancel
#if OMPT_SUPPORT && OMPT_OPTIONAL
          if (ompt_enabled.ompt_callback_cancel) {
            ompt_data_t *task_data;
            __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL,
                                          NULL);
            ompt_cancel_flag_t type = ompt_cancel_parallel;
            if (cncl_kind == cancel_parallel)
              type = ompt_cancel_parallel;
            else if (cncl_kind == cancel_loop)
              type = ompt_cancel_loop;
            else if (cncl_kind == cancel_sections)
              type = ompt_cancel_sections;
            ompt_callbacks.ompt_callback(ompt_callback_cancel)(
                task_data, type | ompt_cancel_activated,
                OMPT_GET_RETURN_ADDRESS(0));
          }
#endif
          return 1 /* true */;
        }
        break;
      }
    case cancel_taskgroup:
      // cancellation requests for a task group
      // are handled through the taskgroup structure
      {
        kmp_taskdata_t *task;
        kmp_taskgroup_t *taskgroup;

        task = this_thr->th.th_current_task;
        KMP_DEBUG_ASSERT(task);

        taskgroup = task->td_taskgroup;
        if (taskgroup) {
          kmp_int32 old = cancel_noreq;
          taskgroup->cancel_request.compare_exchange_strong(old, cncl_kind);
          if (old == cancel_noreq || old == cncl_kind) {
// we do not have a cancellation request in this taskgroup or we do
// have one that matches the current request -> cancel
#if OMPT_SUPPORT && OMPT_OPTIONAL
            if (ompt_enabled.ompt_callback_cancel) {
              ompt_data_t *task_data;
              __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL,
                                            NULL);
              ompt_callbacks.ompt_callback(ompt_callback_cancel)(
                  task_data, ompt_cancel_taskgroup | ompt_cancel_activated,
                  OMPT_GET_RETURN_ADDRESS(0));
            }
#endif
            return 1 /* true */;
          }
        } else {
          // TODO: what needs to happen here?
          // the specification disallows cancellation w/o taskgroups
          // so we might do anything here, let's abort for now
          KMP_ASSERT(0 /* false */);
        }
      }
      break;
    default:
      KMP_ASSERT(0 /* false */);
    }
  }
//.........这里部分代码省略.........
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:101,代码来源:kmp_cancel.cpp



注:本文中的KMP_DEBUG_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ KMS_ELEMENT函数代码示例发布时间:2022-05-30
下一篇:
C++ KMEM_CACHE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap