コード例 #1
0
static void mca_btl_tcp2_endpoint_send_handler(int sd, short flags, void* user)
{
    mca_btl_tcp2_endpoint_t* btl_endpoint = (mca_btl_tcp2_endpoint_t *)user;
    OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);
    switch(btl_endpoint->endpoint_state) {
    case MCA_BTL_TCP_CONNECTING:
        mca_btl_tcp2_endpoint_complete_connect(btl_endpoint);
        break;
    case MCA_BTL_TCP_CONNECTED:
        /* complete the current send */
        while (NULL != btl_endpoint->endpoint_send_frag) {
            mca_btl_tcp2_frag_t* frag = btl_endpoint->endpoint_send_frag;
            int btl_ownership = (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);

            if(mca_btl_tcp2_frag_send(frag, btl_endpoint->endpoint_sd) == false) {
                break;
            }
            /* progress any pending sends */
            btl_endpoint->endpoint_send_frag = (mca_btl_tcp2_frag_t*)
                opal_list_remove_first(&btl_endpoint->endpoint_frags);

            /* if required - update request status and release fragment */
            OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
            assert( frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK );
            frag->base.des_cbfunc(&frag->btl->super, frag->endpoint, &frag->base, frag->rc);
            if( btl_ownership ) {
                MCA_BTL_TCP_FRAG_RETURN(frag);
            }
            OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);

        }

        /* if nothing else to do unregister for send event notifications */
        if(NULL == btl_endpoint->endpoint_send_frag) {
            opal_event_del(&btl_endpoint->endpoint_send_event);
        }
        break;
    default:
        BTL_ERROR(("invalid connection state (%d)", btl_endpoint->endpoint_state));
        opal_event_del(&btl_endpoint->endpoint_send_event);
        break;
    }
    OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
}
コード例 #2
0
static inline bool mca_mpool_grdma_evict_lru_local (mca_mpool_grdma_pool_t *pool)
{
    mca_mpool_grdma_module_t *mpool_grdma;
    mca_mpool_base_registration_t *old_reg;

    old_reg = (mca_mpool_base_registration_t *)
        opal_list_remove_first (&pool->lru_list);
    if (NULL == old_reg) {
        return false;
    }

    mpool_grdma = (mca_mpool_grdma_module_t *) old_reg->mpool;

    (void) dereg_mem (old_reg);

    mpool_grdma->stat_evicted++;

    return true;
}
コード例 #3
0
static inline int
mca_btl_ugni_post_pending (mca_btl_ugni_module_t *ugni_module)
{
    int count = opal_list_get_size (&ugni_module->pending_descriptors);
    int i;

    for (i = 0 ; i < count ; ++i) {
        OPAL_THREAD_LOCK(&ugni_module->pending_descriptors_lock);
        mca_btl_ugni_post_descriptor_t *post_desc =
            (mca_btl_ugni_post_descriptor_t *) opal_list_remove_first (&ugni_module->pending_descriptors);
        OPAL_THREAD_UNLOCK(&ugni_module->pending_descriptors_lock);

        if (OPAL_SUCCESS != mca_btl_ugni_repost (ugni_module, post_desc)) {
            break;
        }
    }

    return i;
}
コード例 #4
0
static int mca_mpool_base_close(void)
{
  opal_list_item_t *item;
  mca_mpool_base_selected_module_t *sm;
  int32_t modules_length;

  /* Need the initial length in order to know if some of the initializations
   * are done in the open function.
   */
  modules_length = opal_list_get_size(&mca_mpool_base_modules);

  /* Finalize all the mpool components and free their list items */

  while(NULL != (item = opal_list_remove_first(&mca_mpool_base_modules))) {
    sm = (mca_mpool_base_selected_module_t *) item;

    /* Blatently ignore the return code (what would we do to recover,
       anyway?  This component is going away, so errors don't matter
       anymore).  Note that it's legal for the module to have NULL for
       the finalize function. */

    if (NULL != sm->mpool_module->mpool_finalize) {
        sm->mpool_module->mpool_finalize(sm->mpool_module);
    }
    OBJ_RELEASE(sm);
  }

  /* Close all remaining available components (may be one if this is a
     OMPI RTE program, or [possibly] multiple if this is ompi_info) */
  (void) mca_base_framework_components_close(&ompi_mpool_base_framework, NULL);

  /* deregister memory free callback */
  if( (modules_length > 0) && mca_mpool_base_used_mem_hooks && 
     0 != (OPAL_MEMORY_FREE_SUPPORT & opal_mem_hooks_support_level())) {
      opal_mem_hooks_unregister_release(mca_mpool_base_mem_cb);
  }

  mca_mpool_base_tree_fini();
  /* All done */

  return OMPI_SUCCESS;
}
コード例 #5
0
ファイル: oob_tcp_peer.c プロジェクト: aosm/openmpi
void mca_oob_tcp_peer_shutdown(mca_oob_tcp_peer_t* peer)
{
    /* giving up and cleanup any pending messages */
    if(peer->peer_retries++ > mca_oob_tcp_component.tcp_peer_retries) {
        mca_oob_tcp_msg_t *msg;

        opal_output(0, "[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_peer_shutdown: retries exceeded",
                    ORTE_NAME_ARGS(orte_process_info.my_name),
                    ORTE_NAME_ARGS(&(peer->peer_name)));

        /* There are cases during the initial connection setup where
           the peer_send_msg is NULL but there are things in the queue
           -- handle that case */
        if (NULL != (msg = peer->peer_send_msg)) {
            msg->msg_complete = true;
            msg->msg_rc = ORTE_ERR_UNREACH;
            mca_oob_tcp_msg_complete(msg, &peer->peer_name);
        }
        peer->peer_send_msg = NULL;
        while (NULL != 
               (msg = (mca_oob_tcp_msg_t*)opal_list_remove_first(&peer->peer_send_queue))) {
            msg->msg_complete = true;
            msg->msg_rc = ORTE_ERR_UNREACH;
            mca_oob_tcp_msg_complete(msg, &peer->peer_name);
        }

        /* We were unsuccessful in establishing a connection, and are
           not likely to suddenly become successful, so abort the
           whole thing */
        peer->peer_state = MCA_OOB_TCP_FAILED;
    }

    if (peer->peer_sd >= 0) {
        opal_event_del(&peer->peer_recv_event);
        opal_event_del(&peer->peer_send_event);
        CLOSE_THE_SOCKET(peer->peer_sd);
        peer->peer_sd = -1;
    } 
      
    opal_event_del(&peer->peer_timer_event);
    peer->peer_state = MCA_OOB_TCP_CLOSED;
}
コード例 #6
0
ファイル: db_hash.c プロジェクト: IanYXXL/A1
static int remove_data(const opal_identifier_t *uid, const char *key)
{
    proc_data_t *proc_data;
    opal_value_t *kv;
    opal_identifier_t id;

    /* to protect alignment, copy the data across */
    memcpy(&id, uid, sizeof(opal_identifier_t));

    /* lookup the specified proc */
    if (NULL == (proc_data = lookup_opal_proc(&hash_data, id))) {
        /* no data for this proc */
        return OPAL_SUCCESS;
    }

    /* if key is NULL, remove all data for this proc */
    if (NULL == key) {
        while (NULL != (kv = (opal_value_t *) opal_list_remove_first(&proc_data->data))) {
            OBJ_RELEASE(kv);
        }
        /* remove the proc_data object itself from the jtable */
        opal_hash_table_remove_value_uint64(&hash_data, id);
        /* cleanup */
        OBJ_RELEASE(proc_data);
        return OPAL_SUCCESS;
    }

    /* remove this item */
    for (kv = (opal_value_t*) opal_list_get_first(&proc_data->data);
         kv != (opal_value_t*) opal_list_get_end(&proc_data->data);
         kv = (opal_value_t*) opal_list_get_next(kv)) {
        if (0 == strcmp(key, kv->key)) {
            opal_list_remove_item(&proc_data->data, &kv->super);
            if (!(kv->scope & OPAL_SCOPE_REFER)) {
                OBJ_RELEASE(kv);
            }
            break;
        }
    }

    return OPAL_SUCCESS;
}
コード例 #7
0
ファイル: btl_tcp2_endpoint.c プロジェクト: urids/XSCALAMPI
static void mca_btl_tcp2_endpoint_connected(mca_btl_base_endpoint_t* btl_endpoint)
{
    /* setup socket options */
    btl_endpoint->endpoint_state = MCA_BTL_TCP_CONNECTED;
    btl_endpoint->endpoint_retries = 0;

    /* Create the send event in a persistent manner. */
    opal_event_set(opal_event_base, &btl_endpoint->endpoint_send_event, 
                    btl_endpoint->endpoint_sd, 
                    OPAL_EV_WRITE | OPAL_EV_PERSIST,
                    mca_btl_tcp2_endpoint_send_handler,
                    btl_endpoint );

    if(opal_list_get_size(&btl_endpoint->endpoint_frags) > 0) {
        if(NULL == btl_endpoint->endpoint_send_frag)
            btl_endpoint->endpoint_send_frag = (mca_btl_tcp2_frag_t*)
                opal_list_remove_first(&btl_endpoint->endpoint_frags);
        opal_event_add(&btl_endpoint->endpoint_send_event, 0);
    }
}
コード例 #8
0
int
orte_rml_oob_fini(void)
{
    opal_list_item_t *item;

    while (NULL != 
           (item = opal_list_remove_first(&orte_rml_oob_module.exceptions))) {
        OBJ_RELEASE(item);
    }
    OBJ_DESTRUCT(&orte_rml_oob_module.exceptions);
    OBJ_DESTRUCT(&orte_rml_oob_module.exceptions_lock);
    OBJ_DESTRUCT(&orte_rml_oob_module.queued_routing_messages);
    OBJ_DESTRUCT(&orte_rml_oob_module.queued_lock);
    orte_rml_oob_module.active_oob->oob_exception_callback = NULL;

    /* clear the base receive */
    orte_rml_base_comm_stop();
    
    return ORTE_SUCCESS;
}
コード例 #9
0
int orte_iof_base_callback_delete(
    const orte_process_name_t* proc,
    int tag)
{
    orte_iof_base_endpoint_t* endpoint;
    opal_list_item_t* item;

    OPAL_THREAD_LOCK(&orte_iof_base.iof_lock);
    if(NULL == (endpoint = orte_iof_base_endpoint_lookup(proc,ORTE_IOF_SINK, tag))) {
        OPAL_THREAD_UNLOCK(&orte_iof_base.iof_lock);
        return ORTE_ERR_NOT_FOUND;
    }

    while(NULL != (item = opal_list_remove_first(&endpoint->ep_callbacks))) {
        OBJ_RELEASE(item);
    }
    OBJ_RELEASE(endpoint);
    OPAL_THREAD_UNLOCK(&orte_iof_base.iof_lock);
    return ORTE_SUCCESS;
}
コード例 #10
0
static void update_routing_plan(void)
{
    orte_routed_tree_t *child;
    int j;
    opal_list_item_t *item;

    /* if I am anything other than a daemon or the HNP, this
     * is a meaningless command as I am not allowed to route
     */
    if (!ORTE_PROC_IS_DAEMON && !ORTE_PROC_IS_HNP) {
        return;
    }

    /* clear the list of children if any are already present */
    while (NULL != (item = opal_list_remove_first(&my_children))) {
        OBJ_RELEASE(item);
    }
    num_children = 0;

    /* compute my direct children and the bitmap that shows which vpids
     * lie underneath their branch
     */
    ORTE_PROC_MY_PARENT->vpid = binomial_tree(0, 0, ORTE_PROC_MY_NAME->vpid,
                                   orte_process_info.max_procs,
                                   &num_children, &my_children, NULL, true);

    if (0 < opal_output_get_verbosity(orte_routed_base_framework.framework_output)) {
        opal_output(0, "%s: parent %d num_children %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ORTE_PROC_MY_PARENT->vpid, num_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;
            opal_output(0, "%s: \tchild %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), child->vpid);
            for (j=0; j < (int)orte_process_info.max_procs; j++) {
                if (opal_bitmap_is_set_bit(&child->relatives, j)) {
                    opal_output(0, "%s: \t\trelation %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), j);
                }
            }
        }
    }
}
コード例 #11
0
ファイル: oob_tcp_peer.c プロジェクト: aosm/openmpi
/*
 * A file descriptor is available/ready for send. Check the state
 * of the socket and take the appropriate action.
 */
static void mca_oob_tcp_peer_send_handler(int sd, short flags, void* user)
{
    mca_oob_tcp_peer_t* peer = (mca_oob_tcp_peer_t *)user;
    OPAL_THREAD_LOCK(&peer->peer_lock);
    switch(peer->peer_state) {
    case MCA_OOB_TCP_CONNECTING:
        mca_oob_tcp_peer_complete_connect(peer);
        break;
    case MCA_OOB_TCP_CONNECTED:
        {
        while(peer->peer_send_msg != NULL) {

            /* complete the current send */
            mca_oob_tcp_msg_t* msg = peer->peer_send_msg;
            if(mca_oob_tcp_msg_send_handler(msg, peer)) {
                mca_oob_tcp_msg_complete(msg, &peer->peer_name);
            } else {
                break;
            }

            /* if current completed - progress any pending sends */
            peer->peer_send_msg = (mca_oob_tcp_msg_t*)
                opal_list_remove_first(&peer->peer_send_queue);
        }
        
        /* if nothing else to do unregister for send event notifications */
        if(NULL == peer->peer_send_msg) {
            opal_event_del(&peer->peer_send_event);
        }
        break;
        }
    default:
        opal_output(0, "[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_peer_send_handler: invalid connection state (%d)",
            ORTE_NAME_ARGS(orte_process_info.my_name),
            ORTE_NAME_ARGS(&(peer->peer_name)),
            peer->peer_state);
        opal_event_del(&peer->peer_send_event);
        break;
    }
    OPAL_THREAD_UNLOCK(&peer->peer_lock);
}
コード例 #12
0
static void *mca_oob_ud_complete_dispatch(int fd, int flags, void *context)
{
    mca_oob_ud_req_t *req;

    OPAL_THREAD_LOCK(&mca_oob_ud_component.ud_match_lock);
    while (NULL !=
           (req = (mca_oob_ud_req_t *) opal_list_remove_first (&mca_oob_ud_component.ud_event_queued_reqs))) {
        OPAL_THREAD_UNLOCK(&mca_oob_ud_component.ud_match_lock);

        OPAL_OUTPUT_VERBOSE((10, mca_oob_base_output, "%s oob:ud:event_process processing request %p",
                             ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (void *) req));

        req->req_list = NULL;

        switch (req->type) {
        case MCA_OOB_UD_REQ_RECV:
        case MCA_OOB_UD_REQ_UNEX:
            if (req->state == MCA_OOB_UD_REQ_COMPLETE) {
                mca_oob_ud_recv_complete (req);
            } else {
                mca_oob_ud_req_append_to_list (req, &mca_oob_ud_component.ud_active_recvs);
                mca_oob_ud_recv_try (req);
            }
            break;
        case MCA_OOB_UD_REQ_SEND:
            if (req->state == MCA_OOB_UD_REQ_COMPLETE) {
                mca_oob_ud_send_complete (req, ORTE_SUCCESS);
            } else {
                mca_oob_ud_req_append_to_list (req, &mca_oob_ud_component.ud_active_sends);
                mca_oob_ud_send_try (req);
            }
            break;
        default:
            break;
        }

        OPAL_THREAD_LOCK(&mca_oob_ud_component.ud_match_lock);
    }

    return NULL;
}
コード例 #13
0
ファイル: binom.c プロジェクト: 00datman/ompi
int main(int argc, char* argv[])
{
    int i, j;
    int found;
    opal_list_t children;
    opal_list_item_t *item;
    int num_children;
    int num_procs;
    orte_routed_tree_t *child;
    opal_bitmap_t *relations;

    if (2 != argc) {
        printf("usage: binom x, where x=number of procs\n");
        exit(1);
    }

    orte_init(&argc, &argv, ORTE_PROC_TOOL);

    num_procs = atoi(argv[1]);

    for (i=0; i < num_procs; i++) {
        OBJ_CONSTRUCT(&children, opal_list_t);
        num_children = 0;
        printf("i am %d:", i);
        found = down_search(0, 0, i, num_procs, &num_children, &children, NULL);
        printf("\tparent %d num_children %d\n", found, num_children);
        while (NULL != (item = opal_list_remove_first(&children))) {
            child = (orte_routed_tree_t*)item;
            printf("\tchild %d\n", child->vpid);
            for (j=0; j < num_procs; j++) {
                if (opal_bitmap_is_set_bit(&child->relatives, j)) {
                    printf("\t\trelation %d\n", j);
                }
            }
            OBJ_RELEASE(item);
        }
        OBJ_DESTRUCT(&children);
    }

    orte_finalize();
}
コード例 #14
0
static void mca_oob_ud_peer_msg_timeout (int fd, short event, void *ctx)
{
    mca_oob_ud_peer_t *peer = (mca_oob_ud_peer_t *) ctx;
    mca_oob_ud_msg_t  *msg  = (mca_oob_ud_msg_t *) opal_list_get_first (&peer->peer_flying_messages);

    OPAL_THREAD_LOCK(&peer->peer_lock);

    if (false == peer->peer_timer.active) {
        return;
    }

    peer->peer_timer.active = false;

    OPAL_OUTPUT_VERBOSE((10, mca_oob_base_output, "%s oob:ud:peer_msg_timeout timeout sending to peer "
                         "%s. first message = %" PRIu64 " which has length %d" , ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                         ORTE_NAME_PRINT(&peer->peer_name), msg->hdr->msg_id, msg->wr.sg_list[0].length));

    if (peer->peer_timer.tries == 0) {
        opal_list_item_t *item;


        while (NULL != (item = opal_list_remove_first (&peer->peer_flying_messages))) {
            msg = (mca_oob_ud_msg_t *) item;

            mca_oob_ud_msg_status_update (msg, MCA_OOB_UD_MSG_STATUS_TIMEOUT);
            if (msg->req) {
                mca_oob_ud_req_complete (msg->req, ORTE_ERR_TIMEOUT);
            }
        }

        OPAL_THREAD_UNLOCK(&peer->peer_lock);
        mca_oob_ud_peer_lost (peer);
        return;
    }

    peer->peer_timer.tries--;
    mca_oob_ud_peer_post_all (peer);
    mca_oob_ud_peer_start_timer (peer);

    OPAL_THREAD_UNLOCK(&peer->peer_lock);
}
コード例 #15
0
static inline bool mca_rcache_grdma_evict_lru_local (mca_rcache_grdma_cache_t *cache)
{
    mca_rcache_grdma_module_t *rcache_grdma;
    mca_rcache_base_registration_t *old_reg;

    opal_mutex_lock (&cache->vma_module->vma_lock);
    old_reg = (mca_rcache_base_registration_t *)
        opal_list_remove_first (&cache->lru_list);
    opal_mutex_unlock (&cache->vma_module->vma_lock);
    if (NULL == old_reg) {
        return false;
    }

    rcache_grdma = (mca_rcache_grdma_module_t *) old_reg->rcache;

    (void) dereg_mem (old_reg);

    rcache_grdma->stat_evicted++;

    return true;
}
コード例 #16
0
ファイル: btl_ugni_send.c プロジェクト: urids/XSCALAMPI
int mca_btl_ugni_progress_send_wait_list (mca_btl_base_endpoint_t *endpoint)
{
    mca_btl_ugni_base_frag_t *frag;
    int rc;

    while (NULL !=
           (frag = (mca_btl_ugni_base_frag_t *) opal_list_remove_first (&endpoint->frag_wait_list))) {
        rc = mca_btl_ugni_send_frag (endpoint, frag);
        if (OPAL_UNLIKELY(OMPI_SUCCESS > rc)) {
            if (OPAL_LIKELY(OMPI_ERR_OUT_OF_RESOURCE == rc)) {
                opal_list_prepend (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
            } else {
                mca_btl_ugni_frag_complete (frag, rc);
            }

            return rc;
        }
    }

    return OMPI_SUCCESS;
}
コード例 #17
0
int
orte_ess_base_close(void)
{
    opal_list_item_t *item;
    mca_base_component_list_item_t *cli;

    /* unload all remaining components */
    while (NULL != (item = opal_list_remove_first(&orte_ess_base_components_available))) {
        orte_ess_base_component_t* component;
        cli = (mca_base_component_list_item_t *) item;
        component = (orte_ess_base_component_t *) cli->cli_component;
        opal_output_verbose(10, 0,
                            "orte_ess_base_close: module %s unloaded",
                            component->base_version.mca_component_name);
        mca_base_component_repository_release((mca_base_component_t *) component);
        OBJ_RELEASE(item);
    }
    
    OBJ_DESTRUCT(&orte_ess_base_components_available);
    return ORTE_SUCCESS;
}
コード例 #18
0
ファイル: orted.c プロジェクト: aosm/openmpi
static void halt_vm(void)
{
    int ret;
    struct timeval tv = { 1, 0 };
    opal_event_t* event;
    opal_list_t attrs;
    opal_list_item_t *item;
    
    /* terminate the vm - this will also wake us up so we can exit */
    OBJ_CONSTRUCT(&attrs, opal_list_t);
    orte_rmgr.add_attribute(&attrs, ORTE_NS_INCLUDE_DESCENDANTS, ORTE_UNDEF, NULL, ORTE_RMGR_ATTR_OVERRIDE);
    ret = orte_pls.terminate_orteds(0, &orte_abort_timeout, &attrs);
    while (NULL != (item = opal_list_remove_first(&attrs))) OBJ_RELEASE(item);
    OBJ_DESTRUCT(&attrs);
    
    /* setup a delay to give the orteds time to complete their departure */
    if (NULL != (event = (opal_event_t*)malloc(sizeof(opal_event_t)))) {
        opal_evtimer_set(event, exit_callback, NULL);
        opal_evtimer_add(event, &tv);
    }
}
コード例 #19
0
static inline bool mca_mpool_rgpusm_deregister_lru (mca_mpool_base_module_t *mpool) {
    mca_mpool_rgpusm_module_t *mpool_rgpusm = (mca_mpool_rgpusm_module_t *) mpool;
    mca_mpool_base_registration_t *old_reg;
    int rc;

    /* Remove the registration from the cache and list before
       deregistering the memory */
    old_reg = (mca_mpool_base_registration_t*)
        opal_list_remove_first (&mpool_rgpusm->lru_list);
    if (NULL == old_reg) {
        opal_output_verbose(10, mca_mpool_rgpusm_component.output,
                            "RGPUSM: The LRU list is empty. There is nothing to deregister");
        return false;
    }

    mpool->rcache->rcache_delete(mpool->rcache, old_reg);

    /* Drop the rcache lock while we deregister the memory */
    opal_mutex_unlock (&mpool->rcache->lock);
    assert(old_reg->ref_count == 0);
    rc = mpool_rgpusm->resources.deregister_mem(mpool_rgpusm->resources.reg_data,
                                                old_reg);
    opal_mutex_lock (&mpool->rcache->lock);

    /* This introduces a potential leak of registrations if
       the deregistration fails to occur as we no longer have
       a reference to it. Is this possible? */
    if (OPAL_SUCCESS != rc) {
        opal_output_verbose(10, mca_mpool_rgpusm_component.output,
                            "RGPUSM: Failed to deregister the memory addr=%p, size=%d",
                            old_reg->base, (int)(old_reg->bound - old_reg->base + 1));
        return false;
    }

    opal_free_list_return (&mpool_rgpusm->reg_list,
                           (opal_free_list_item_t*)old_reg);
    mpool_rgpusm->stat_evicted++;

    return true;
}
コード例 #20
0
ファイル: btl_tcp2_endpoint.c プロジェクト: 00datman/ompi
static void mca_btl_tcp2_endpoint_send_handler(int sd, short flags, void* user)
{
    mca_btl_tcp_endpoint_t* btl_endpoint = (mca_btl_tcp_endpoint_t *)user;
    opal_mutex_atomic_lock(&btl_endpoint->endpoint_send_lock);
    switch(btl_endpoint->endpoint_state) {
    case MCA_BTL_TCP_CONNECTING:
        mca_btl_tcp2_endpoint_complete_connect(btl_endpoint);
        break;
    case MCA_BTL_TCP_CONNECTED:
        /* complete the current send */
        while (NULL != btl_endpoint->endpoint_send_frag) {
            mca_btl_tcp2_frag_t* frag = btl_endpoint->endpoint_send_frag;
            int btl_ownership = (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);

            if(mca_btl_tcp2_frag_send(frag, btl_endpoint->endpoint_sd) == false) {
                break;
            }
            /* progress any pending sends */
            btl_endpoint->endpoint_send_frag = (mca_btl_tcp2_frag_t*)
                opal_list_remove_first(&btl_endpoint->endpoint_frags);

            /* if required - update request status and release fragment */
            opal_mutex_atomic_unlock(&btl_endpoint->endpoint_send_lock);
            assert( frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK );
            TODO_MCA_BTL_TCP_COMPLETE_FRAG_SEND(frag);
            opal_mutex_atomic_lock(&btl_endpoint->endpoint_send_lock);
        }

        /* if no more data to send unregister the send notifications */
        if(NULL == btl_endpoint->endpoint_send_frag) {
            opal_event_del(&btl_endpoint->endpoint_send_event);
        }
        break;
    default:
        BTL_ERROR(("invalid connection state (%d)", btl_endpoint->endpoint_state));
        opal_event_del(&btl_endpoint->endpoint_send_event);
        break;
    }
    opal_mutex_atomic_unlock(&btl_endpoint->endpoint_send_lock);
}
コード例 #21
0
ファイル: sec_basic.c プロジェクト: intel-ctrlsys/sensys
static int get_my_cred(int dstorehandle,
                       opal_process_name_t *my_id,
                       opal_sec_cred_t *cred)
{
    opal_list_t vals;
    opal_value_t *kv;

    if (!initialized) {
        /* check first if a credential was stored for this job
         * in the database
         */
        OBJ_CONSTRUCT(&vals, opal_list_t);
        if (OPAL_SUCCESS == opal_dstore.fetch(dstorehandle, my_id, OPAL_DSTORE_CREDENTIAL, &vals)) {
            kv = (opal_value_t*)opal_list_remove_first(&vals);
            if (NULL == kv) {
                /* make the default credential 7-bytes long so we hit a nice
                 * 8-byte alignment (including NULL terminator) to keep valgrind
                 * from barking in optimized builds
                 */
                my_cred.credential = strdup("1234567");
                my_cred.size = strlen(my_cred.credential)+1;  // include the NULL
            } else {
                my_cred.credential = strdup(kv->data.string);
                my_cred.size = strlen(kv->data.string)+1;  // include the NULL
                OBJ_RELEASE(kv);
            }
        } else {
            my_cred.credential = strdup("1234567");
            my_cred.size = strlen(my_cred.credential)+1;  // include the NULL
        }
        OPAL_LIST_DESTRUCT(&vals);
    }
    initialized = true;

    cred->method = strdup("basic");
    cred->credential = strdup(my_cred.credential);
    cred->size = my_cred.size;

    return OPAL_SUCCESS;
}
コード例 #22
0
/*
 * Forcibly drain all pending output on an endpoint, without waiting for
 * actual completion.
 */
void
ompi_btl_usnic_flush_endpoint(
    ompi_btl_usnic_endpoint_t *endpoint)
{
    ompi_btl_usnic_send_frag_t *frag;

    /* First, free all pending fragments */
    while (!opal_list_is_empty(&endpoint->endpoint_frag_send_queue)) {
        frag = (ompi_btl_usnic_send_frag_t *)opal_list_remove_first(
                &endpoint->endpoint_frag_send_queue);

        /* _cond still needs to check ownership, but make sure the 
         * fragment is marked as done.
         */
        frag->sf_ack_bytes_left = 0;
        frag->sf_seg_post_cnt = 0;
        ompi_btl_usnic_send_frag_return_cond(endpoint->endpoint_module, frag);
    }

    /* Now, ACK everything that is pending */
    ompi_btl_usnic_handle_ack(endpoint, endpoint->endpoint_next_seq_to_send-1);
}
コード例 #23
0
int opal_hash_table_set_value_ptr(opal_hash_table_t* ht, const void* key,
                                  size_t key_size, void* value)
{
    opal_list_t* list = ht->ht_table + opal_hash_value(ht->ht_mask, key,
                                                       key_size);
    opal_ptr_hash_node_t *node;

#if OPAL_ENABLE_DEBUG
    if(ht->ht_table_size == 0) {
        opal_output(0, "opal_hash_table_set_value_ptr:"
		   "opal_hash_table_init() has not been called");
        return OPAL_ERR_BAD_PARAM;
    }
#endif
    for(node =  (opal_ptr_hash_node_t*)opal_list_get_first(list);
        node != (opal_ptr_hash_node_t*)opal_list_get_end(list);
        node =  (opal_ptr_hash_node_t*)opal_list_get_next(node)) {
        if (node->hn_key_size == key_size &&
            memcmp(node->hn_key, key, key_size) == 0) {
            node->hn_value = value;
            return OPAL_SUCCESS;
        }
    } 

    node = (opal_ptr_hash_node_t*)opal_list_remove_first(&ht->ht_nodes); 
    if(NULL == node) {
        node = OBJ_NEW(opal_ptr_hash_node_t);
        if(NULL == node) {
            return OPAL_ERR_OUT_OF_RESOURCE;
        }
    }
    node->hn_key = malloc(key_size);
    node->hn_key_size = key_size;
    node->hn_value = value;
    memcpy(node->hn_key, key, key_size);
    opal_list_append(list, (opal_list_item_t*)node);
    ht->ht_size++;
    return OPAL_SUCCESS;
}
コード例 #24
0
ファイル: coll_ml_lmngr.c プロジェクト: 00datman/ompi
static void destruct_lmngr(mca_coll_ml_lmngr_t *lmngr)
{
    int max_nc = lmngr->n_resources;
    int rc, i;
    bcol_base_network_context_t *nc;
    opal_list_item_t *item;

    ML_VERBOSE(6, ("Destructing list manager %p", (void *)lmngr));

    while (NULL != (item = opal_list_remove_first(&lmngr->blocks_list))) {
        OBJ_RELEASE(item);
    }

    OBJ_DESTRUCT(&lmngr->blocks_list);

    if (NULL != lmngr->alloc_base) {
        for( i = 0; i < max_nc; i++ ) {
            nc = lmngr->net_context[i];
            rc = nc->deregister_memory_fn(nc->context_data,
                    lmngr->reg_desc[nc->context_id]);
            if(rc != OMPI_SUCCESS) {
                ML_ERROR(("Failed to unregister , lmngr %p", (void *)lmngr));
            }
        }

        ML_VERBOSE(10, ("Release base addr %p", lmngr->alloc_base));

        free(lmngr->alloc_base);
        lmngr->alloc_base = NULL;
        lmngr->base_addr = NULL;
    }

    lmngr->list_block_size = 0;
    lmngr->list_alignment = 0;
    lmngr->list_size = 0;
    lmngr->n_resources = 0;

    OBJ_DESTRUCT(&lmngr->mem_lock);
}
コード例 #25
0
ファイル: memheap_base_mkey.c プロジェクト: anhzhang/ompi
void memheap_oob_destruct(void)
{
    int i;
    oob_comm_request_t *r;

    opal_progress_unregister(oshmem_mkey_recv_cb);

    for (i = 0; i < MEMHEAP_RECV_REQS_MAX; i++) {
        r = &memheap_oob.req_pool[i];
        PMPI_Cancel(&r->recv_req);
        PMPI_Request_free(&r->recv_req);
    }

    /*clear these list object as they don't belong here */
    while (NULL != opal_list_remove_first(&memheap_oob.req_list)) {
        continue;
    }

    OBJ_DESTRUCT(&memheap_oob.req_list);
    OBJ_DESTRUCT(&memheap_oob.lck);
    OBJ_DESTRUCT(&memheap_oob.cond);
}
コード例 #26
0
ファイル: btl_ugni_component.c プロジェクト: urids/XSCALAMPI
static inline int
mca_btl_ugni_progress_wait_list (mca_btl_ugni_module_t *ugni_module)
{
    int count = opal_list_get_size (&ugni_module->ep_wait_list);
    int rc, i;

    for (i = 0 ; i < count ; ++i) {
        mca_btl_base_endpoint_t *endpoint =
            (mca_btl_base_endpoint_t *) opal_list_remove_first (&ugni_module->ep_wait_list);
        assert (NULL != endpoint);

        endpoint->wait_listed = false;

        rc = mca_btl_ugni_progress_send_wait_list (endpoint);
        if (OMPI_SUCCESS != rc && false == endpoint->wait_listed) {
            opal_list_append (&ugni_module->ep_wait_list, &endpoint->super);
            endpoint->wait_listed = true;
        }
    }

    return count;
}
コード例 #27
0
static int orte_odls_base_close(void)
{
    int i;
    orte_proc_t *proc;
    opal_list_item_t *item;

    /* cleanup ODLS globals */
    while (NULL != (item = opal_list_remove_first(&orte_odls_globals.xterm_ranks))) {
        OBJ_RELEASE(item);
    }
    OBJ_DESTRUCT(&orte_odls_globals.xterm_ranks);
    
    /* cleanup the global list of local children and job data */
    for (i=0; i < orte_local_children->size; i++) {
        if (NULL != (proc = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) {
            OBJ_RELEASE(proc);
        }
    }
    OBJ_RELEASE(orte_local_children);

    return mca_base_framework_components_close(&orte_odls_base_framework, NULL);
}
コード例 #28
0
ファイル: orte_wait.c プロジェクト: bringhurst/ompi
int 
orte_wait_kill(int sig)
{
    opal_list_item_t* item;

    OPAL_THREAD_LOCK(&mutex);
    do_waitall(0);
    while (NULL != (item = opal_list_remove_first(&registered_cb))) {
        registered_cb_item_t *cb = (registered_cb_item_t*)item;
        pending_pids_item_t *pending = find_pending_pid(cb->pid,false);
        if(NULL == pending) {
            int status;
            kill(cb->pid, sig);
            waitpid(cb->pid,&status,0);
        } else {
            OBJ_RELEASE(pending);
        }
        OBJ_RELEASE(item);
    } 
    OPAL_THREAD_UNLOCK(&mutex);
    return ORTE_SUCCESS;
}
コード例 #29
0
/* This function must be called with the rcache lock held */
static void do_unregistration_gc(struct mca_mpool_base_module_t *mpool)
{
    mca_mpool_rdma_module_t *mpool_rdma = (mca_mpool_rdma_module_t*)mpool;
    mca_mpool_base_registration_t *reg;

    do {
        /* Remove registration from garbage collection list
           before deregistering it */
        reg = (mca_mpool_base_registration_t *)
            opal_list_remove_first(&mpool_rdma->gc_list);
        mpool->rcache->rcache_delete(mpool->rcache, reg);

        /* Drop the rcache lock before calling dereg_mem as there
           may be memory allocations */
        OPAL_THREAD_UNLOCK(&mpool->rcache->lock);
        dereg_mem(mpool, reg);
        OPAL_THREAD_LOCK(&mpool->rcache->lock);

        OMPI_FREE_LIST_RETURN(&mpool_rdma->reg_list,
                (ompi_free_list_item_t*)reg);
    } while(!opal_list_is_empty(&mpool_rdma->gc_list));
}
コード例 #30
0
ファイル: ras_bjs.c プロジェクト: aosm/openmpi
static int orte_ras_bjs_allocate(orte_jobid_t jobid, opal_list_t *attributes)
{
    opal_list_t nodes;
    opal_list_item_t* item;
    int rc;
    orte_app_context_t **context = NULL;
    orte_std_cntr_t i, num_context = 0;

    OBJ_CONSTRUCT(&nodes, opal_list_t);
    
    rc = orte_rmgr.get_app_context(jobid, &context, &num_context);
    if(ORTE_SUCCESS != rc) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }

    if(ORTE_SUCCESS != (rc = orte_ras_bjs_discover(&nodes, context, num_context))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }

    rc = orte_ras_base_allocate_nodes(jobid, &nodes);
    if(ORTE_SUCCESS != rc) {
        ORTE_ERROR_LOG(rc);
    }

cleanup:
    while(NULL != (item = opal_list_remove_first(&nodes))) {
        OBJ_RELEASE(item);
    }
    OBJ_DESTRUCT(&nodes);
    for(i=0; i<num_context; i++) {
        OBJ_RELEASE(context[i]);
    }
    if (NULL != context) {
        free(context);
    }
    return rc;
}