コード例 #1
0
int
ompi_modex_recv(const mca_base_component_t *component,
                const ompi_proc_t *proc,
                void **buffer,
                size_t *size)
{
    int rc;
    char *key;
    opal_byte_object_t *boptr;

    /* set defaults */
    *buffer = NULL;
    *size = 0;

    key = mca_base_component_to_string(component);
    if (NULL == key) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    
    /* the fetch API returns a pointer to the data */
    rc = orte_db.fetch(&proc->proc_name, key, (void**)&boptr, OPAL_BYTE_OBJECT);

    if (ORTE_SUCCESS == rc) {
        /* xfer the data - it was allocated in the call */
        *buffer = (void*)boptr->bytes;
        *size = boptr->size;
    }
    /* we no longer require the struct itself since all we
     * wanted was the data inside it
     */
    free(boptr);
    free(key);
    return rc;
}
コード例 #2
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;
}
コード例 #3
0
int
ompi_modex_send(mca_base_component_t * source_component,
                const void *data, size_t size)
{
    int rc;
    char * name = mca_base_component_to_string(source_component);
    
    if(NULL == name) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    
    rc = orte_grpcomm.set_proc_attr(name, data, size);
    free(name);
    return rc;
}
コード例 #4
0
int
ompi_modex_recv(mca_base_component_t * component,
                ompi_proc_t * proc,
                void **buffer,
                size_t * size)
{
    int rc;
    char * name = mca_base_component_to_string(component);
    
    if(NULL == name) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    
    rc = orte_grpcomm.get_proc_attr(proc->proc_name, name, buffer, size);
    free(name);
    return rc;
}
コード例 #5
0
ファイル: mtl_mxm.c プロジェクト: h4ck3rm1k3/ompi-svn-mirror
/*
 * send information using modex (in some case there is limitation on data size for example ess/pmi)
 * set size of data sent for once
 *
 */
static int ompi_mtl_mxm_send_ep_address(void *address, size_t address_len)
{
    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);
    const size_t modex_max_size = 0x60;
    unsigned char *modex_buf_ptr;
    size_t modex_buf_size;
    size_t modex_cur_size;
    int modex_name_id = 0;
    int rc;

    /* Send address length */
    sprintf(modex_name, "%s-len", modex_component_name);
    rc = ompi_modex_send_string((const char *)modex_name, &address_len, sizeof(address_len));
    if (OMPI_SUCCESS != rc) {
        MXM_ERROR("failed to send address length");
        goto bail;
    }

    /* Send address, in parts.
     * modex name looks as mtl.mxm.1.5-18 where mtl.mxm.1.5 is the component and 18 is part index.
     */
    modex_buf_size = address_len;
    modex_buf_ptr = address;
    while (modex_buf_size) {
        sprintf(modex_name, "%s-%d", modex_component_name, modex_name_id);
        modex_cur_size = (modex_buf_size < modex_max_size) ? modex_buf_size : modex_max_size;
        rc = ompi_modex_send_string(modex_name, modex_buf_ptr, modex_cur_size);
        if (OMPI_SUCCESS != rc) {
            MXM_ERROR("Open MPI couldn't distribute EP connection details");
            goto bail;
        }

        modex_name_id++;
        modex_buf_ptr += modex_cur_size;
        modex_buf_size -= modex_cur_size;
    }

    rc = OMPI_SUCCESS;

bail:
    free(modex_component_name);
    free(modex_name);
    return rc;
}
コード例 #6
0
int ompi_modex_send(const mca_base_component_t *source_component,
                    const void *data, size_t size)
{
    int rc;
    char *key;
    opal_byte_object_t bo;

    key = mca_base_component_to_string(source_component);
    if (NULL == key) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }

    bo.bytes = (uint8_t *)data;
    bo.size = size;

    /* the store API makes a copy of the provided data */
    rc = orte_db.store(ORTE_PROC_MY_NAME, key, &bo, OPAL_BYTE_OBJECT);
    free(key);
    return rc;
}