Beispiel #1
0
static inline int
mca_btl_ugni_progress_wait_list (mca_btl_ugni_module_t *ugni_module)
{
    int rc = OPAL_SUCCESS;
    mca_btl_base_endpoint_t *endpoint = NULL;
    int count;

    if (0 == opal_list_get_size(&ugni_module->ep_wait_list)) {
        return 0;
    }

    /* check the count before taking the lock to avoid unnecessary locking */
    count = opal_list_get_size(&ugni_module->ep_wait_list);
    if (0 == count) {
        return 0;
    }

    OPAL_THREAD_LOCK(&ugni_module->ep_wait_list_lock);
    count = opal_list_get_size(&ugni_module->ep_wait_list);
    do {
        endpoint = (mca_btl_base_endpoint_t *) opal_list_remove_first (&ugni_module->ep_wait_list);
        if (endpoint != NULL) {
            rc = mca_btl_ugni_progress_send_wait_list (endpoint);

            if (OPAL_SUCCESS != rc) {
                opal_list_append (&ugni_module->ep_wait_list, &endpoint->super);
            } else {
                endpoint->wait_listed = false;
            }
        }
    } while (endpoint != NULL && --count > 0) ;
    OPAL_THREAD_UNLOCK(&ugni_module->ep_wait_list_lock);

    return rc;
}
/* returns 1 iff two lists contain the same entries */
static inline int mca_rcache_vma_compare_reg_lists(mca_rcache_vma_t *vma1,
        mca_rcache_vma_t *vma2)
{
    mca_rcache_vma_reg_list_item_t *i1, *i2;

    if (!vma1 || !vma2)
        return 0;

    if(opal_list_get_size(&vma1->reg_list) !=
            opal_list_get_size(&vma2->reg_list))
        return 0;

    i1 = (mca_rcache_vma_reg_list_item_t*)opal_list_get_first(&vma1->reg_list);
    i2 = (mca_rcache_vma_reg_list_item_t*)opal_list_get_first(&vma2->reg_list);

    do {
        if(i1  == (mca_rcache_vma_reg_list_item_t*)opal_list_get_end(&vma1->reg_list) || 
            i2 == (mca_rcache_vma_reg_list_item_t*)opal_list_get_end(&vma2->reg_list))
            return 1;

        if(i1->reg != i2->reg)
            break;

        i1 = (mca_rcache_vma_reg_list_item_t*)opal_list_get_next(i1);
        i2 = (mca_rcache_vma_reg_list_item_t*)opal_list_get_next(i2);
    } while(1);

    return 0;
}
void mca_btl_udapl_frag_progress_pending(mca_btl_udapl_module_t* udapl_btl,
                                        mca_btl_base_endpoint_t* endpoint,
                                        const int connection)
{
    int len;
    int i;
    int token_avail;
    mca_btl_udapl_frag_t* frag;
    
    if (BTL_UDAPL_EAGER_CONNECTION == connection) {
        len = opal_list_get_size(&endpoint->endpoint_eager_frags);

        /* progress eager frag queue as needed */
	BTL_UDAPL_TOKEN_AVAIL(endpoint, connection, token_avail);
	
        for(i = 0; i < len && token_avail > 0; i++) {

            OPAL_THREAD_LOCK(&endpoint->endpoint_lock);
            frag = (mca_btl_udapl_frag_t*)opal_list_remove_first(&(endpoint->endpoint_eager_frags));
            OPAL_THREAD_UNLOCK(&endpoint->endpoint_lock);
            if(NULL == frag) {
                return;
            }
            if(mca_btl_udapl_frag_progress_one(udapl_btl, frag) !=
                OMPI_SUCCESS) {
                BTL_ERROR(("ERROR: Not able to progress on connection(%d)\n",
                    BTL_UDAPL_EAGER_CONNECTION));
                return;
            }
            BTL_UDAPL_TOKEN_AVAIL(endpoint, connection, token_avail);
        }

    } else if (BTL_UDAPL_MAX_CONNECTION == connection) {
        len = opal_list_get_size(&endpoint->endpoint_max_frags);

        BTL_UDAPL_TOKEN_AVAIL(endpoint, connection, token_avail);
	
        /* progress max frag queue as needed */
        for(i = 0; i < len && token_avail > 0; i++) {

            OPAL_THREAD_LOCK(&endpoint->endpoint_lock);
            frag = (mca_btl_udapl_frag_t*)opal_list_remove_first(&(endpoint->endpoint_max_frags));
            OPAL_THREAD_UNLOCK(&endpoint->endpoint_lock);
            if(NULL == frag) {
                return;
            }
            if(mca_btl_udapl_frag_progress_one(udapl_btl, frag) !=
                OMPI_SUCCESS) {
                BTL_ERROR(("ERROR: Not able to progress on connection(%d)\n",
                    BTL_UDAPL_MAX_CONNECTION));
                return;
            }
	    BTL_UDAPL_TOKEN_AVAIL(endpoint, connection, token_avail);
        }

    } else {
        BTL_ERROR(("ERROR: Can not progress pending fragment on unknown connection\n"));
    }
    return;
}
static int progress_pending_collfrags(mca_bcol_iboffload_module_t *iboffload)
{
    mca_bcol_iboffload_collfrag_t *pending_collfrag;
    int rc, size = opal_list_get_size(&iboffload->collfrag_pending);

    IBOFFLOAD_VERBOSE(10, ("Calling progress_pending_collfrags"));

    do {
        pending_collfrag = (mca_bcol_iboffload_collfrag_t *)
                           opal_list_remove_first(&iboffload->collfrag_pending);

        IBOFFLOAD_VERBOSE(10, ("Get pending_collfrag - %p, iboffload - %p, "
                               "pending list size - %d.", pending_collfrag, iboffload,
                               opal_list_get_size(&iboffload->collfrag_pending)));

        /* Return back coll frag to coll request opal_list */
        opal_list_append(&pending_collfrag->coll_full_req->work_requests,
                         (opal_list_item_t *) pending_collfrag);

        rc = pending_collfrag->coll_full_req->progress_fn
             (iboffload, pending_collfrag->coll_full_req);
        if (OPAL_UNLIKELY(BCOL_FN_STARTED != rc && OMPI_SUCCESS != rc)) {
            return OMPI_ERROR;
        }
    } while (--size > 0);

    return OMPI_SUCCESS;
}
Beispiel #5
0
static void opal_free_list_destruct(opal_free_list_t *fl)
{
    opal_list_item_t *item;
    opal_free_list_item_t *fl_item;

#if 0 && OPAL_ENABLE_DEBUG
    if(opal_list_get_size(&fl->super) != fl->fl_num_allocated) {
        opal_output(0, "opal_free_list: %d allocated %d returned: %s:%d\n",
            fl->fl_num_allocated, opal_list_get_size(&fl->super),
            fl->super.super.cls_init_file_name, fl->super.super.cls_init_lineno);
    }
#endif

    while(NULL != (item = opal_lifo_pop(&(fl->super)))) {
        fl_item = (opal_free_list_item_t*)item;

        /* destruct the item (we constructed it), the underlying memory will be
         * reclaimed when we free the slab (opal_free_list_memory_t ptr)
         * containing it */
        OBJ_DESTRUCT(fl_item);
    }

    while(NULL != (item = opal_list_remove_first(&fl->fl_allocations))) {
        opal_free_list_allocation_release (fl, (opal_free_list_memory_t *) item);
    }

    OBJ_DESTRUCT(&fl->fl_allocations);
    OBJ_DESTRUCT(&fl->fl_condition);
    OBJ_DESTRUCT(&fl->fl_lock);
}
static void ompi_free_list_destruct(ompi_free_list_t* fl)
{
    opal_list_item_t *item;

#if 0 && OMPI_ENABLE_DEBUG
    if(opal_list_get_size(&fl->super) != fl->fl_num_allocated) {
        opal_output(0, "ompi_free_list: %d allocated %d returned: %s:%d\n",
            fl->fl_num_allocated, opal_list_get_size(&fl->super),
            fl->super.super.cls_init_file_name, fl->super.super.cls_init_lineno);
    }
#endif

    if (NULL != fl->fl_mpool) {
        ompi_free_list_memory_t *fl_mem;

        while (NULL != (item = opal_list_remove_first(&(fl->fl_allocations)))) {
            /* destruct the item (we constructed it), then free the memory chunk */
            OBJ_DESTRUCT(item);
            fl_mem = (ompi_free_list_memory_t*) item;
            fl->fl_mpool->mpool_free(fl->fl_mpool, item, fl_mem->registration);
        }
    } else {
        while (NULL != (item = opal_list_remove_first(&(fl->fl_allocations)))) {
            /* destruct the item (we constructed it), then free the memory chunk */
            OBJ_DESTRUCT(item);
            free(item);
        }
    }

    OBJ_DESTRUCT(&fl->fl_allocations);
    OBJ_DESTRUCT(&fl->fl_condition);
    OBJ_DESTRUCT(&fl->fl_lock);
}
Beispiel #7
0
static size_t num_routes(void)
{
    OPAL_OUTPUT_VERBOSE((2, orte_routed_base_framework.framework_output,
                         "%s num routes %d",
                         ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                         (int)opal_list_get_size(&my_children)));
    return opal_list_get_size(&my_children);
}
Beispiel #8
0
int main(int argc, char **argv)
{
    opal_list_t *local_list, *remote_list;
    opal_reachable_t *results;
    uint32_t i, j;
    int successful_connections = 0;
    int local_ifs;
    int remote_ifs;
    opal_if_t *local_if;

    opal_init(&argc, &argv);

    /* List of interfaces generated by opal */
    local_list = &opal_if_list;
    /* Create test interfaces */
    remote_list = build_if_list();

    local_ifs = opal_list_get_size(local_list);
    remote_ifs = opal_list_get_size(remote_list);

    /* Tests reachability by looking up entries in routing table.
     * Tests routes to localhost and google's nameservers.
     */
    results = opal_reachable.reachable(local_list, remote_list);

    printf("Local interfaces:\n");
    i = 0;
    OPAL_LIST_FOREACH(local_if, local_list, opal_if_t) {
        char addr[128];
        char *family;

        switch (local_if->af_family) {
            case AF_INET:
                family = "IPv4";
                inet_ntop(AF_INET, &(((struct sockaddr_in*) &local_if->if_addr))->sin_addr,
                          addr, sizeof(addr));
                break;
            case AF_INET6:
                family = "IPv6";
                inet_ntop(AF_INET6, &(((struct sockaddr_in6*) &local_if->if_addr))->sin6_addr,
                          addr, sizeof(addr));
                break;
            default:
                family = "Unknown";
                strcpy(addr, "Unknown");
                break;
        }

        printf("  %3d: %s\t%s\t%s/%d\n", i, local_if->if_name,
	       family, addr, local_if->if_mask);
        i++;
    }
Beispiel #9
0
static inline int
mca_btl_ugni_post_pending (mca_btl_ugni_module_t *ugni_module, mca_btl_ugni_device_t *device)
{
    int pending_post_count = opal_list_get_size (&device->pending_post);
    mca_btl_ugni_post_descriptor_t *post_desc;
    int rc;

    /* check if there are any posts pending resources */
    if (OPAL_LIKELY(0 == pending_post_count)) {
        return 0;
    }

    BTL_VERBOSE(("progressing %d pending FMA/RDMA operations", pending_post_count));
    for (int i = 0 ; i < pending_post_count ; ++i) {
        mca_btl_ugni_device_lock (device);
        post_desc = (mca_btl_ugni_post_descriptor_t *) opal_list_remove_first (&device->pending_post);
        mca_btl_ugni_device_unlock (device);
        if (NULL == post_desc) {
            break;
        }
        rc = mca_btl_ugni_repost (ugni_module, post_desc);
        if (OPAL_SUCCESS != rc) {
            mca_btl_ugni_device_lock (device);
            opal_list_prepend (&device->pending_post, (opal_list_item_t *) post_desc);
            mca_btl_ugni_device_unlock (device);
            break;
        }
    }

    return 1;
}
int
ompi_osc_base_select(ompi_win_t *win,
                    ompi_info_t *info,
                    ompi_communicator_t *comm)
{
    opal_list_item_t *item;
    ompi_osc_base_component_t *best_component = NULL;
    int best_priority = -1, priority;

    if (opal_list_get_size(&ompi_osc_base_avail_components) <= 0) {
        /* we don't have any components to support us... */
        return OMPI_ERR_NOT_SUPPORTED;
    }

    for (item = opal_list_get_first(&ompi_osc_base_avail_components) ;
         item != opal_list_get_end(&ompi_osc_base_avail_components) ;
         item = opal_list_get_next(item)) {
        ompi_osc_base_component_t *component = (ompi_osc_base_component_t*)
            ((mca_base_component_list_item_t*) item)->cli_component;

        priority = component->osc_query(win, info, comm);
        if (priority < 0) continue;
        if (priority > best_priority) {
            best_component = component;
            best_priority = priority;
        }
    }

    if (NULL == best_component) return OMPI_ERR_NOT_SUPPORTED;

    return best_component->osc_select(win, info, comm);
}
Beispiel #11
0
int
ompi_mtl_portals4_recv_short_link(int count)
{
    int ret = OMPI_SUCCESS;
    int active = ompi_mtl_portals4.active_recv_short_blocks;
    int i;

    if (active < count) {
        for (i = 0 ; i < (count - active) ; ++i) {
            ompi_mtl_portals4_recv_short_block_t *block =
                ompi_mtl_portals4_recv_short_block_alloc(true);
            if (NULL == block) {
                return OMPI_ERR_OUT_OF_RESOURCE;
            }
            OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex);
            opal_list_append(&ompi_mtl_portals4.recv_short_blocks,
                             &block->base);
            OPAL_OUTPUT_VERBOSE((10, ompi_mtl_base_framework.framework_output,
                                 "recv_short_link: total=%d active=%d",
                                 (int) opal_list_get_size(&ompi_mtl_portals4.recv_short_blocks), ompi_mtl_portals4.active_recv_short_blocks));
            OPAL_THREAD_UNLOCK(&ompi_mtl_portals4.short_block_mutex);
            ret = ompi_mtl_portals4_activate_block(block);
        }
    }

    return ret;
}
Beispiel #12
0
/**
 * This graph API returns all the adjacents of a vertex and the
 * distance (weight) of those adjacents and the vertex.
 *
 * @param graph
 * @param vertex The reference vertex
 * @param adjacents An allocated pointer array of vertices and
 *                  their distance from the reference vertex.
 *                  Note that this pointer should be free after
 *                  usage by the user
 *
 * @return int the number of adjacents in the list.
 */
int opal_graph_get_adjacent_vertices(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_array_t *adjacents)
{
    opal_adjacency_list_t *adj_list;
    opal_graph_edge_t *edge;
    int adjacents_number;
    opal_list_item_t *item;
    vertex_distance_from_t distance_from;
    int i;

    /**
     * Verify that the vertex belongs to the graph.
     */
    if (graph != vertex->in_graph) {
        OPAL_OUTPUT((0,"Vertex %p not in the graph %p\n", (void *)vertex, (void *)graph));
        return 0;
    }
    /**
     * find the adjacency list that this vertex belongs to
     */
    adj_list = (opal_adjacency_list_t *) vertex->in_adj_list;
    /* find the number of adjcents of this vertex */
    adjacents_number = opal_list_get_size(adj_list->edges);
    /* Run on all the edges from this vertex */
    for (item = opal_list_get_first(adj_list->edges), i = 0;
         item != opal_list_get_end(adj_list->edges);
         item  = opal_list_get_next(item), i++) {
        edge = (opal_graph_edge_t *)item;
        /* assign vertices and their weight in the adjcents list */
        distance_from.vertex = edge->end;
        distance_from.weight = edge->weight;
        opal_value_array_append_item(adjacents, &distance_from);
    }
    /* return the number of the adjacents in the list */
    return adjacents_number;
}
Beispiel #13
0
/* this function is called when all the local participants have
 * called fence - thus, the collective is already locally
 * complete at this point. We therefore just need to create the
 * signature and pass the collective into grpcomm */
int pmix_server_fencenb_fn(opal_list_t *procs, opal_list_t *info,
                           char *data, size_t ndata,
                           opal_pmix_modex_cbfunc_t cbfunc, void *cbdata)
{
    orte_pmix_mdx_caddy_t *cd=NULL;
    int rc;
    opal_namelist_t *nm;
    size_t i;
    opal_buffer_t *buf=NULL;

    cd = OBJ_NEW(orte_pmix_mdx_caddy_t);
    cd->cbfunc = cbfunc;
    cd->cbdata = cbdata;

   /* compute the signature of this collective */
    if (NULL != procs) {
        cd->sig = OBJ_NEW(orte_grpcomm_signature_t);
        cd->sig->sz = opal_list_get_size(procs);
        cd->sig->signature = (orte_process_name_t*)malloc(cd->sig->sz * sizeof(orte_process_name_t));
        memset(cd->sig->signature, 0, cd->sig->sz * sizeof(orte_process_name_t));
        i=0;
        OPAL_LIST_FOREACH(nm, procs, opal_namelist_t) {
            cd->sig->signature[i].jobid = nm->name.jobid;
            cd->sig->signature[i].vpid = nm->name.vpid;
            ++i;
        }
Beispiel #14
0
int pmix2x_server_init(opal_pmix_server_module_t *module,
                      opal_list_t *info)
{
    pmix_status_t rc;
    int dbg;
    opal_value_t *kv;
    pmix_info_t *pinfo;
    size_t sz, n;
    volatile bool active;

    if (0 < (dbg = opal_output_get_verbosity(opal_pmix_base_framework.framework_output))) {
        asprintf(&dbgvalue, "PMIX_DEBUG=%d", dbg);
        putenv(dbgvalue);
    }

    /* convert the list to an array of pmix_info_t */
    if (NULL != info) {
        sz = opal_list_get_size(info);
        PMIX_INFO_CREATE(pinfo, sz);
        n = 0;
        OPAL_LIST_FOREACH(kv, info, opal_value_t) {
            (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN);
            pmix2x_value_load(&pinfo[n].value, kv);
            ++n;
        }
int 
opal_hash_table_get_first_key_uint64(opal_hash_table_t *ht, uint64_t *key,
                                     void **value, void **node)
{
    size_t i;
    opal_uint64_hash_node_t *list_node;

    /* Go through all the lists and return the first element off the
       first non-empty list */
    
    for (i = 0; i < ht->ht_table_size; ++i) {
        if (opal_list_get_size(ht->ht_table + i) > 0) {
            list_node = (opal_uint64_hash_node_t*)
                opal_list_get_first(ht->ht_table + i);
            *node = list_node;
            *key = list_node->hn_key;
            *value = list_node->hn_value;
            return OPAL_SUCCESS;
        }
    }

    /* The hash table is empty */

    return OPAL_ERROR;
}
int orte_qos_base_pack_attributes (opal_buffer_t * buffer,
                                          opal_list_t * qos_attributes)
{
    int32_t num_attributes;
    int32_t rc= ORTE_SUCCESS;
    orte_attribute_t *kv;
    num_attributes = opal_list_get_size (qos_attributes);
    OPAL_OUTPUT_VERBOSE((1, orte_qos_base_framework.framework_output,
                         "%s orte_qos_base_pack_attributes num_attributes = %d\n",
                         ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                         num_attributes));
    if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, (void*)(&num_attributes), 1, ORTE_STD_CNTR))) {
        ORTE_ERROR_LOG (rc);
        return rc;
    }
    OPAL_LIST_FOREACH(kv, qos_attributes, orte_attribute_t) {
        if (ORTE_ATTR_GLOBAL == kv->local) {
            OPAL_OUTPUT_VERBOSE((1, orte_qos_base_framework.framework_output,
                                 "%s orte_qos_base_pack_attributes attribute key = %d value =%d\n",
                                 ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                                 kv->key, kv->data.uint8));
            if (ORTE_SUCCESS != (rc = opal_dss.pack(buffer, (void*)&kv, 1, ORTE_ATTRIBUTE))) {
                ORTE_ERROR_LOG(rc);
                return rc;
            }
        }
    }
    return rc;
}
Beispiel #17
0
int mca_spml_ikrit_fence(shmem_ctx_t ctx)
{
    mxm_peer_t *peer;
    opal_list_item_t *item;

    SPML_VERBOSE(20,
                 "Into fence with %d active puts on %d pes",
                 mca_spml_ikrit.n_active_puts, (int)opal_list_get_size(&mca_spml_ikrit.active_peers));

    /* puts(unless are send sync) are completed by remote side lazily. That is either when remote decides to
     * ack window which can take hundreds of ms. So speed things up by doing fence */
    while (NULL != (item = opal_list_remove_first(&mca_spml_ikrit.active_peers))) {
        peer = spml_ikrit_container_of(item, mxm_peer_t, link);
        peer->n_active_puts = 0;
        peer->need_fence = 0;
        mca_spml_ikrit_mxm_fence(peer - mca_spml_ikrit.mxm_peers);
    }

    while (0 < mca_spml_ikrit.n_mxm_fences || 0 < mca_spml_ikrit.n_active_gets) {
        opal_progress();
    }

    SPML_VERBOSE(20, "fence completed");
    return OSHMEM_SUCCESS;
}
Beispiel #18
0
int mca_spml_ikrit_fence(void)
{
    mxm_peer_t *peer;
    opal_list_item_t *item;

    SPML_VERBOSE(20,
                 "Into fence with %d active puts on %d pes",
                 mca_spml_ikrit.n_active_puts, (int)opal_list_get_size(&mca_spml_ikrit.active_peers));

    /* puts(unless are send sync) are completed by remote side lazily. That is either when remote decides to
     * ack window which can take hundreds of ms. So speed things up by doing fence */
    while (NULL != (item = opal_list_remove_first(&mca_spml_ikrit.active_peers))) {
        peer = (mxm_peer_t *) item;
        peer->n_active_puts = 0;
        peer->need_fence = 0;
        mca_spml_ikrit_mxm_fence(peer->pe);
    }

    while (0 < mca_spml_ikrit.n_mxm_fences) {
        oshmem_request_wait_any_completion();
    }

    SPML_VERBOSE(20, "fence completed");
    return OSHMEM_SUCCESS;
}
Beispiel #19
0
static size_t num_routes(void)
{
    if (!ORTE_PROC_IS_HNP) {
        return 0;
    }
    return opal_list_get_size(&my_children);
}
int ompi_osc_pt2pt_frag_start (ompi_osc_pt2pt_module_t *module,
                               ompi_osc_pt2pt_frag_t *frag)
{
    ompi_osc_pt2pt_peer_t *peer = ompi_osc_pt2pt_peer_lookup (module, frag->target);
    int ret;

    assert(0 == frag->pending && peer->active_frag != frag);

    /* we need to signal now that a frag is outgoing to ensure the count sent
     * with the unlock message is correct */
    ompi_osc_signal_outgoing (module, frag->target, 1);

    /* if eager sends are not active, can't send yet, so buffer and
       get out... */
    if (!ompi_osc_pt2pt_peer_sends_active (module, frag->target) || opal_list_get_size (&peer->queued_frags)) {
        OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output, "queuing fragment to peer %d",
                             frag->target));
        OPAL_THREAD_SCOPED_LOCK(&peer->lock,
                                opal_list_append(&peer->queued_frags, (opal_list_item_t *) frag));
        return OMPI_SUCCESS;
    }

    OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output, "sending fragment to peer %d",
                         frag->target));

    ret = frag_send(module, frag);

    opal_condition_broadcast(&module->cond);

    return ret;
}
int ompi_osc_pt2pt_frag_flush_target (ompi_osc_pt2pt_module_t *module, int target)
{
    ompi_osc_pt2pt_peer_t *peer = ompi_osc_pt2pt_peer_lookup (module, target);
    ompi_osc_pt2pt_frag_t *frag;
    int ret = OMPI_SUCCESS;

    OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
                         "osc pt2pt: frag flush to target target %d. queue fragments: %lu",
                         target, (unsigned long) opal_list_get_size (&peer->queued_frags)));

    /* walk through the pending list and send */
    OPAL_THREAD_LOCK(&peer->lock);
    while (NULL != (frag = ((ompi_osc_pt2pt_frag_t *) opal_list_remove_first (&peer->queued_frags)))) {
        ret = frag_send(module, frag);
        if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
            break;
        }
    }
    OPAL_THREAD_UNLOCK(&peer->lock);

    /* XXX -- TODO -- better error handling */
    if (OMPI_SUCCESS != ret) {
        return ret;
    }

    /* flush the active frag */
    ret = ompi_osc_pt2pt_flush_active_frag (module, peer);

    OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
                         "osc pt2pt: frag flush target %d finished", target));

    return ret;
}
/*
 * Write a command to the main thread, or queue it up if the pipe is full
 */
static int write_to_main_thread(cmd_t *cmd)
{
    /* Note that if we write too much to the main thread pipe and the
       main thread doesn't check it often, we could fill up the pipe
       and cause this thread to block.  Bad!  So we do some simple
       counting here and ensure that we don't fill the pipe.  If we
       are in danger of that, then queue up the commands here in the
       service thread.  The main thread will ACK every CALL_FUNCTION
       command, so we have a built-in mechanism to wake up the service
       thread to drain any queued-up commands. */
    if (opal_list_get_size(&pending_to_main_thread) > 0 ||
        waiting_for_ack_from_main_thread >= max_outstanding_to_main_thread) {
        cmd_list_item_t *cli = OBJ_NEW(cmd_list_item_t);
        if (NULL == cli) {
            return OMPI_ERR_OUT_OF_RESOURCE;
        }
        memcpy(&cli->cli_cmd, cmd, cmd_size);
        opal_list_append(&pending_to_main_thread, &(cli->super));
    } else {
        OPAL_OUTPUT((-1, "fd: writing to main thread"));
        opal_fd_write(pipe_to_main_thread[1], cmd_size, cmd);
        ++waiting_for_ack_from_main_thread;
    }

    return OMPI_SUCCESS;
}
Beispiel #23
0
mca_mpool_base_module_t *common_sm_mpool_create (mca_common_sm_mpool_resources_t *resources)
{
    mca_common_sm_mpool_module_t *mpool_module;
    mca_allocator_base_component_t* allocator_component;

    /* Make a new mpool module */
    mpool_module = (mca_common_sm_mpool_module_t *) malloc (sizeof (*mpool_module));
    mca_common_sm_mpool_module_init(mpool_module);

    /* set sm_size */
    mpool_module->sm_size = resources->size;

    allocator_component = mca_allocator_component_lookup(resources->allocator);

    /* if specified allocator cannot be loaded - look for an alternative */
    if (NULL == allocator_component) {
        if (opal_list_get_size(&opal_allocator_base_framework.framework_components) == 0) {
            mca_base_component_list_item_t *item =
                (mca_base_component_list_item_t *)
                opal_list_get_first(&opal_allocator_base_framework.framework_components);
            allocator_component =
                (mca_allocator_base_component_t *)item->cli_component;
            opal_output(
                0, "mca_common_sm_mpool_init: "
                "unable to locate allocator: %s - using %s\n",
                resources->allocator,
                allocator_component->allocator_version.mca_component_name);
        } else {
            opal_output(0, "mca_common_sm_mpool_init: "
                        "unable to locate allocator: %s\n",
                        resources->allocator);
            free(mpool_module);
            return NULL;
        }
    }

    mpool_module->mem_node = resources->mem_node;

    if (NULL == (mpool_module->sm_common_module =
        mca_common_sm_module_attach(&resources->bs_meta_buf,
                                    sizeof(mca_common_sm_module_t), 8))) {
        opal_output(0, "mca_common_sm_mpool_init: "
                    "unable to create shared memory mapping (%s)",
                    resources->bs_meta_buf.seg_name);
        free(mpool_module);
        return NULL;
    }

    /* setup allocator */
    mpool_module->sm_allocator =
      allocator_component->allocator_init (true, mca_common_sm_seg_alloc,
                                           NULL, mpool_module->sm_common_module);
    if (NULL == mpool_module->sm_allocator) {
        opal_output(0, "mca_common_sm_mpool_init: unable to initialize allocator");
        free(mpool_module);
        return NULL;
    }

    return &mpool_module->super;
}
Beispiel #24
0
static int mca_bml_r2_add_btls( void )
{
    int i;
    opal_list_t *btls = NULL; 
    mca_btl_base_selected_module_t* selected_btl;
    size_t num_btls = 0; 
    char **btl_names_argv = NULL;
    
    if(true == mca_bml_r2.btls_added) {
        return OMPI_SUCCESS; 
    }

    /* build an array of r2s and r2 modules */
    btls = &mca_btl_base_modules_initialized;
    num_btls = opal_list_get_size(btls);

    mca_bml_r2.num_btl_modules = 0;
    mca_bml_r2.num_btl_progress = 0;
   
    mca_bml_r2.btl_modules = (mca_btl_base_module_t **)malloc(sizeof(mca_btl_base_module_t*) * num_btls);
    mca_bml_r2.btl_progress = (mca_btl_base_component_progress_fn_t*)malloc(sizeof(mca_btl_base_component_progress_fn_t) * num_btls);
   
    if (NULL == mca_bml_r2.btl_modules || 
        NULL == mca_bml_r2.btl_progress) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }

    for(selected_btl =  (mca_btl_base_selected_module_t*)opal_list_get_first(btls);
        selected_btl != (mca_btl_base_selected_module_t*)opal_list_get_end(btls);
        selected_btl =  (mca_btl_base_selected_module_t*)opal_list_get_next(selected_btl)) {
        mca_btl_base_module_t *btl = selected_btl->btl_module;
        mca_bml_r2.btl_modules[mca_bml_r2.num_btl_modules++] = btl;
        for (i = 0; NULL != btl_names_argv && NULL != btl_names_argv[i]; ++i) {
            if (0 == 
                strcmp(btl_names_argv[i],
                       btl->btl_component->btl_version.mca_component_name)) {
                break;
            }
        }
        if (NULL == btl_names_argv || NULL == btl_names_argv[i]) {
            opal_argv_append_nosize(&btl_names_argv, 
                                    btl->btl_component->btl_version.mca_component_name);
        }
    }
    if (NULL != btl_names_argv) {
        btl_names = opal_argv_join(btl_names_argv, ' ');
        opal_argv_free(btl_names_argv);
    } else {
        btl_names = strdup("no devices available");
    }

    /* sort r2 list by exclusivity */
    qsort(mca_bml_r2.btl_modules, 
          mca_bml_r2.num_btl_modules, 
          sizeof(struct mca_btl_base_module_t*), 
          btl_exclusivity_compare);
    mca_bml_r2.btls_added = true; 
    return OMPI_SUCCESS;
}
Beispiel #25
0
Datei: if.c Projekt: IanYXXL/A1
int opal_ifcount(void)
{
    if (OPAL_SUCCESS != mca_base_framework_open(&opal_if_base_framework, 0)) {
        return 0;
    }

    return opal_list_get_size(&opal_if_list);
}
Beispiel #26
0
int mca_pml_ob1_dump(struct ompi_communicator_t* comm, int verbose)
{
    struct mca_pml_comm_t* pml_comm = comm->c_pml_comm;
    int i;

    /* TODO: don't forget to dump mca_pml_ob1.non_existing_communicator_pending */

    opal_output(0, "Communicator %s [%p](%d) rank %d recv_seq %d num_procs %lu last_probed %lu\n",
                comm->c_name, (void*) comm, comm->c_contextid, comm->c_my_rank,
                pml_comm->recv_sequence, pml_comm->num_procs, pml_comm->last_probed);
    if( opal_list_get_size(&pml_comm->wild_receives) ) {
        opal_output(0, "expected MPI_ANY_SOURCE fragments\n");
        mca_pml_ob1_dump_frag_list(&pml_comm->wild_receives, true);
    }

    /* iterate through all procs on communicator */
    for( i = 0; i < (int)pml_comm->num_procs; i++ ) {
        mca_pml_ob1_comm_proc_t* proc = &pml_comm->procs[i];
        mca_bml_base_endpoint_t* ep = (mca_bml_base_endpoint_t*)proc->ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML];
        size_t n;

        opal_output(0, "[Rank %d] expected_seq %d ompi_proc %p send_seq %d\n",
                    i, proc->expected_sequence, (void*) proc->ompi_proc, 
                    proc->send_sequence);
        /* dump all receive queues */
        if( opal_list_get_size(&proc->specific_receives) ) {
            opal_output(0, "expected specific receives\n");
            mca_pml_ob1_dump_frag_list(&proc->specific_receives, true);
        }
        if( opal_list_get_size(&proc->frags_cant_match) ) {
            opal_output(0, "out of sequence\n");
            mca_pml_ob1_dump_frag_list(&proc->frags_cant_match, false);
        }
        if( opal_list_get_size(&proc->unexpected_frags) ) {
            opal_output(0, "unexpected frag\n");
            mca_pml_ob1_dump_frag_list(&proc->unexpected_frags, false);
        }
        /* dump all btls used for eager messages */
        for( n = 0; n < ep->btl_eager.arr_size; n++ ) {
            mca_bml_base_btl_t* bml_btl = &ep->btl_eager.bml_btls[n];
            bml_btl->btl->btl_dump(bml_btl->btl, bml_btl->btl_endpoint, verbose);
        }
    }
    return OMPI_SUCCESS;
}
Beispiel #27
0
static int mca_btl_scif_progress_sends (mca_btl_base_endpoint_t *ep)
{
    /* try sending any wait listed fragments */
    if (OPAL_UNLIKELY(0 != opal_list_get_size (&ep->frag_wait_list))) {
        return mca_btl_scif_progress_send_wait_list (ep);
    }

    return 0;
}
int opal_hash_table_remove_all(opal_hash_table_t* ht)
{
    size_t i;
    for(i=0; i<ht->ht_table_size; i++) {
        opal_list_t* list = ht->ht_table+i;
        while(opal_list_get_size(list)) {
            opal_list_item_t *item = opal_list_remove_first(list);
            OBJ_RELEASE(item);
        }
    }

    while(opal_list_get_size(&ht->ht_nodes)) {
        opal_list_item_t* item = opal_list_remove_first(&ht->ht_nodes);
        OBJ_RELEASE(item);
    }
    ht->ht_size = 0;
    return OPAL_SUCCESS;
}
Beispiel #29
0
static int mca_coll_ml_lmngr_init(mca_coll_ml_lmngr_t *lmngr)
{
    int i, num_blocks;
    int rc;
    unsigned char *addr;
    bcol_base_network_context_t *nc;

    ML_VERBOSE(7, ("List initialization"));

#ifdef HAVE_POSIX_MEMALIGN
    if((errno = posix_memalign(&lmngr->base_addr,
                    lmngr->list_alignment,
                    lmngr->list_size * lmngr->list_block_size)) != 0) {
        ML_ERROR(("Failed to allocate memory: %d [%s]", errno, strerror(errno)));
        return OMPI_ERROR;
    }
    lmngr->alloc_base = lmngr->base_addr;
#else
    lmngr->alloc_base =
        malloc(lmngr->list_size * lmngr->list_block_size + lmngr->list_alignment);
    if(NULL == lmngr->alloc_base) {
        ML_ERROR(("Failed to allocate memory: %d [%s]", errno, strerror(errno)));
        return OMPI_ERROR;
    }

    lmngr->base_addr = (void*)OPAL_ALIGN((uintptr_t)lmngr->alloc_base,
            lmngr->list_alignment, uintptr_t);
#endif

    assert(lmngr->n_resources < MCA_COLL_ML_MAX_REG_INFO);

    for(i= 0 ;i < lmngr->n_resources ;i++) {
        nc = lmngr->net_context[i];
        ML_VERBOSE(7, ("Call registration for resource index %d", i));
        rc = lmngr_register(lmngr, nc);
        if (OMPI_SUCCESS != rc) {
            ML_ERROR(("Failed to lmngr register: %d [%s]", errno, strerror(errno)));
            return rc;
        }
    }

    /* slice the memory to blocks */
    addr = (unsigned char *) lmngr->base_addr;
    for(num_blocks = 0; num_blocks < (int)lmngr->list_size; num_blocks++) {
        mca_bcol_base_lmngr_block_t *item = OBJ_NEW(mca_bcol_base_lmngr_block_t);
        item->base_addr = (void *)addr;
        item->lmngr = lmngr;
        /* ML_VERBOSE(10, ("Appending block # %d %p", num_blocks, (void *)addr)); */
        opal_list_append(&lmngr->blocks_list, (opal_list_item_t *)item);
        /* advance the address */
        addr += lmngr->list_block_size;
    }

    ML_VERBOSE(7, ("List initialization done %d",
                opal_list_get_size(&lmngr->blocks_list)));
    return OMPI_SUCCESS;
}
Beispiel #30
0
void orte_routed_base_xcast_routing(orte_grpcomm_collective_t *coll,
                                    opal_list_t *my_children)
{
    opal_list_item_t *item;
    orte_routed_tree_t *child;
    orte_namelist_t *nm;
    int i;
    orte_proc_t *proc;
    orte_job_t *daemons;

    /* if we are the HNP and an abnormal termination is underway,
     * then send it directly to everyone
     */
    if (ORTE_PROC_IS_HNP) {
        if (orte_abnormal_term_ordered) {
            daemons = orte_get_job_data_object(ORTE_PROC_MY_NAME->jobid);
            for (i=1; i < daemons->procs->size; i++) {
                if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(daemons->procs, i))) {
                    continue;
                }
                /* exclude anyone known not alive */
                if (proc->alive) {
                    nm = OBJ_NEW(orte_namelist_t);
                    nm->name.jobid = ORTE_PROC_MY_NAME->jobid;
                    nm->name.vpid = proc->name.vpid;
                    opal_list_append(&coll->targets, &nm->super);
                }
            }
            /* if nobody is known alive, then we need to die */
            if (0 == opal_list_get_size(&coll->targets)) {
                ORTE_ACTIVATE_JOB_STATE(NULL, ORTE_JOB_STATE_DAEMONS_TERMINATED);
            }
        } else {
            /* the xcast always goes to our children */
            for (item = opal_list_get_first(my_children);
                 item != opal_list_get_end(my_children);
                 item = opal_list_get_next(item)) {
                child = (orte_routed_tree_t*)item;
                nm = OBJ_NEW(orte_namelist_t);
                nm->name.jobid = ORTE_PROC_MY_NAME->jobid;
                nm->name.vpid = child->vpid;
                opal_list_append(&coll->targets, &nm->super);
            }
        }
    } else {
        /* I am a daemon - route to my children */
        for (item = opal_list_get_first(my_children);
             item != opal_list_get_end(my_children);
             item = opal_list_get_next(item)) {
            child = (orte_routed_tree_t*)item;
            nm = OBJ_NEW(orte_namelist_t);
            nm->name.jobid = ORTE_PROC_MY_NAME->jobid;
            nm->name.vpid = child->vpid;
            opal_list_append(&coll->targets, &nm->super);
        }
    }
}