Example #1
0
CILK_API_INT __cilkrts_bump_worker_rank_internal(__cilkrts_worker *w)
{
    __cilkrts_pedigree *pedigree;
    pedigree = (w ? &w->pedigree : __cilkrts_get_tls_pedigree_leaf(1));
    pedigree->rank++;
    return 0;
}
Example #2
0
CILK_API_PEDIGREE
__cilkrts_get_pedigree_internal(__cilkrts_worker *w)
{
    if (NULL != w) {
        return w->pedigree;
    }
    else {
        const __cilkrts_pedigree *pedigree =
            __cilkrts_get_tls_pedigree_leaf(1);
        return *pedigree;
    }
}
Example #3
0
CILK_API_INT
__cilkrts_get_pedigree_info(__cilkrts_pedigree_context_t *external_context,
                            uint64_t *sf_birthrank)
{
    pedigree_context_t *context = (pedigree_context_t *)external_context;

    CILK_ASSERT(sizeof(__cilkrts_pedigree_context_t) ==
                sizeof(pedigree_context_t));
    if (context->size != sizeof(pedigree_context_t))
        return -3;  // Invalid size

    // If the pointer to the last __cilkrts_pedigree is -1, we've
    // finished the walk.  We're still done.
    if (PEDIGREE_WALK_COMPLETE == context->pedigree)
        return 1;

    // The passed in context value contains a pointer to the last
    // __cilkrts_pedigree returned, or NULL if we're starting a
    // new walk
    if (NULL == context->pedigree)
    {
        __cilkrts_worker *w = __cilkrts_get_tls_worker();
        __cilkrts_pedigree* pedigree_node;
        if (NULL != w) {
            pedigree_node = &w->pedigree;
        }
        else {
            pedigree_node = __cilkrts_get_tls_pedigree_leaf(1);
        }
        context->pedigree = pedigree_node->parent;
    }
    else
        context->pedigree = context->pedigree->parent;

    // Note: If we want to omit the user root node,
    // stop at context->pedigree->parent instead.
    if (NULL == context->pedigree)
    {
        context->pedigree = PEDIGREE_WALK_COMPLETE;
        return 1;
    }

    *sf_birthrank = context->pedigree->rank;
    return 0;
}
Example #4
0
void load_pedigree_leaf_into_user_worker(__cilkrts_worker *w)
{
    __cilkrts_pedigree *pedigree_leaf;
    CILK_ASSERT(w->l->type == WORKER_USER);
    pedigree_leaf = __cilkrts_get_tls_pedigree_leaf(1);
    w->pedigree = *pedigree_leaf;

    // Save a pointer to the old leaf.
    // We'll need to restore it later.
    CILK_ASSERT(w->l->original_pedigree_leaf == NULL);
    w->l->original_pedigree_leaf = pedigree_leaf;
    
    __cilkrts_set_tls_pedigree_leaf(&w->pedigree);
    
    // Check that this new pedigree root has at least two values.
    CILK_ASSERT(w->pedigree.parent);
    CILK_ASSERT(w->pedigree.parent->parent == NULL);
}