コード例 #1
0
ファイル: mtl_mxm.c プロジェクト: h4ck3rm1k3/ompi-svn-mirror
/*
 * recieve information using modex
 */
static int ompi_mtl_mxm_recv_ep_address(ompi_proc_t *source_proc, void **address_p,
                                        size_t *address_len_p)
{
    char *modex_component_name = mca_base_component_to_string(&mca_mtl_mxm_component.super.mtl_version);
    char *modex_name = malloc(strlen(modex_component_name) + 5);
    unsigned char *modex_buf_ptr;
    size_t modex_cur_size;
    size_t modex_buf_size;
    size_t *address_len_buf_ptr;
    int modex_name_id = 0;
    int rc;

    *address_p = NULL;
    *address_len_p = 0;

    /* Receive address length */
    sprintf(modex_name, "%s-len", modex_component_name);
    rc = ompi_modex_recv_string(modex_name, source_proc, (void**)&address_len_buf_ptr,
                                &modex_cur_size);
    if (OMPI_SUCCESS != rc) {
        MXM_ERROR("Failed to receive ep address length");
        goto bail;
    }

    /* Allocate buffer to hold the address */
    *address_len_p = *address_len_buf_ptr;
    *address_p = malloc(*address_len_p);
    if (*address_p == NULL) {
        MXM_ERROR("Failed to allocate modex receive buffer");
        rc = OMPI_ERR_OUT_OF_RESOURCE;
        goto bail;
    }

    /* Receive the data, in parts */
    modex_buf_size = 0;
    while (modex_buf_size < *address_len_p) {
        sprintf(modex_name, "%s-%d", modex_component_name, modex_name_id);
        rc = ompi_modex_recv_string(modex_name, source_proc, (void**)&modex_buf_ptr,
                                    &modex_cur_size);
        if (OMPI_SUCCESS != rc) {
            MXM_ERROR("Open MPI couldn't distribute EP connection details");
            goto bail;
        }

        memcpy((char*)(*address_p) + modex_buf_size, modex_buf_ptr, modex_cur_size);
        modex_buf_size += modex_cur_size;
        modex_name_id++;
    }

    rc = OMPI_SUCCESS;
bail:
    free(modex_component_name);
    free(modex_name);
    return rc;
}
コード例 #2
0
int ompi_comm_cid_init (void)
{
    ompi_proc_t **procs, *thisproc;
    uint8_t thread_level;
    void *tlpointer;
    int ret;
    size_t i, size, numprocs;
    
    /** Note that the following call only returns processes
     * with the same jobid. This is on purpose, since 
     * we switch for the dynamic communicators anyway 
     * to the original (slower) cid allocation algorithm.
     */ 
    procs = ompi_proc_world ( &numprocs );

    for ( i=0; i<numprocs; i++ ) {
        thisproc = procs[i];
       
        ret = ompi_modex_recv_string("MPI_THREAD_LEVEL", thisproc, &tlpointer, &size);
        if (OMPI_SUCCESS == ret) {
            thread_level = *((uint8_t *) tlpointer);
            if ( OMPI_THREADLEVEL_IS_MULTIPLE (thread_level) ) {
                ompi_comm_world_thread_level_mult = 1;
                break;
            }
        } else if (OMPI_ERR_NOT_IMPLEMENTED == ret) {
            if (ompi_mpi_thread_multiple) {
                ompi_comm_world_thread_level_mult = 1;
            }
            break;
        } else {
            return ret;
        }
    }
    free(procs);

    return OMPI_SUCCESS;
}