2007-07-09 21:16:34 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2011-10-04 18:50:31 +04:00
|
|
|
* Copyright (c) 2004-2011 The University of Tennessee and The University
|
2007-07-09 21:16:34 +04:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2012-06-19 17:38:42 +04:00
|
|
|
* Copyright (c) 2006-2012 Los Alamos National Security, LLC. All rights
|
2007-07-09 21:16:34 +04:00
|
|
|
* reserved.
|
2014-04-30 01:49:23 +04:00
|
|
|
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
2007-07-09 21:16:34 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "ompi/constants.h"
|
2007-07-09 21:16:34 +04:00
|
|
|
|
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2009-07-15 08:54:53 +04:00
|
|
|
#include "opal/dss/dss.h"
|
2007-07-09 21:16:34 +04:00
|
|
|
|
2013-01-28 03:25:10 +04:00
|
|
|
#include "ompi/mca/rte/rte.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "ompi/proc/proc.h"
|
|
|
|
#include "ompi/runtime/ompi_module_exchange.h"
|
2007-07-09 21:16:34 +04:00
|
|
|
|
|
|
|
|
2012-06-27 18:53:55 +04:00
|
|
|
int ompi_modex_send(const mca_base_component_t *source_component,
|
|
|
|
const void *data, size_t size)
|
2007-07-09 21:16:34 +04:00
|
|
|
{
|
|
|
|
int rc;
|
2012-06-27 18:53:55 +04:00
|
|
|
char *key;
|
|
|
|
opal_byte_object_t bo;
|
|
|
|
|
|
|
|
key = mca_base_component_to_string(source_component);
|
|
|
|
if (NULL == key) {
|
2008-02-28 04:57:57 +03:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2007-07-09 21:16:34 +04:00
|
|
|
}
|
2012-06-27 18:53:55 +04:00
|
|
|
|
2012-07-20 16:10:00 +04:00
|
|
|
bo.bytes = (uint8_t *)data;
|
2012-06-27 18:53:55 +04:00
|
|
|
bo.size = size;
|
|
|
|
|
|
|
|
/* the store API makes a copy of the provided data */
|
2013-01-28 03:25:10 +04:00
|
|
|
rc = ompi_rte_db_store(OMPI_PROC_MY_NAME, key, &bo, OPAL_BYTE_OBJECT);
|
2012-06-27 18:53:55 +04:00
|
|
|
free(key);
|
2007-07-09 21:16:34 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-27 18:53:55 +04:00
|
|
|
ompi_modex_recv(const mca_base_component_t *component,
|
|
|
|
const ompi_proc_t *proc,
|
2007-07-09 21:16:34 +04:00
|
|
|
void **buffer,
|
2012-06-27 18:53:55 +04:00
|
|
|
size_t *size)
|
2007-07-09 21:16:34 +04:00
|
|
|
{
|
2008-02-28 04:57:57 +03:00
|
|
|
int rc;
|
2012-06-27 18:53:55 +04:00
|
|
|
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;
|
|
|
|
}
|
2007-07-09 21:16:34 +04:00
|
|
|
|
2012-06-27 18:53:55 +04:00
|
|
|
/* the fetch API returns a pointer to the data */
|
2013-12-17 07:26:00 +04:00
|
|
|
rc = ompi_rte_db_fetch(proc, key, (void**)&boptr, OPAL_BYTE_OBJECT);
|
2012-06-27 18:53:55 +04:00
|
|
|
|
2013-01-28 03:25:10 +04:00
|
|
|
if (OMPI_SUCCESS == rc) {
|
2012-06-27 18:53:55 +04:00
|
|
|
/* xfer the data - it was allocated in the call */
|
|
|
|
*buffer = (void*)boptr->bytes;
|
|
|
|
*size = boptr->size;
|
2013-03-25 04:36:57 +04:00
|
|
|
/* we no longer require the struct itself since all we
|
|
|
|
* wanted was the data inside it
|
|
|
|
*/
|
|
|
|
free(boptr);
|
2012-06-27 18:53:55 +04:00
|
|
|
}
|
|
|
|
free(key);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-01-28 03:25:10 +04:00
|
|
|
|
2007-08-09 22:53:28 +04:00
|
|
|
int
|
|
|
|
ompi_modex_send_string(const char* key,
|
|
|
|
const void *buffer, size_t size)
|
|
|
|
{
|
2012-06-27 18:53:55 +04:00
|
|
|
int rc;
|
|
|
|
opal_byte_object_t bo;
|
|
|
|
|
2012-07-20 16:10:00 +04:00
|
|
|
bo.bytes = (uint8_t *)buffer;
|
2012-06-27 18:53:55 +04:00
|
|
|
bo.size = size;
|
|
|
|
|
|
|
|
/* the store API makes a copy of the provided data */
|
2013-01-28 03:25:10 +04:00
|
|
|
rc = ompi_rte_db_store(OMPI_PROC_MY_NAME, key, &bo, OPAL_BYTE_OBJECT);
|
2012-06-27 18:53:55 +04:00
|
|
|
|
|
|
|
return rc;
|
2007-08-09 22:53:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_modex_recv_string(const char* key,
|
2012-06-27 18:53:55 +04:00
|
|
|
const ompi_proc_t *source_proc,
|
2007-08-09 22:53:28 +04:00
|
|
|
void **buffer, size_t *size)
|
|
|
|
{
|
2012-06-27 18:53:55 +04:00
|
|
|
int rc;
|
|
|
|
opal_byte_object_t *boptr;
|
|
|
|
|
|
|
|
/* set defaults */
|
|
|
|
*buffer = NULL;
|
|
|
|
*size = 0;
|
|
|
|
|
|
|
|
/* the fetch API returns a copy of the data */
|
2013-12-17 07:26:00 +04:00
|
|
|
rc = ompi_rte_db_fetch(source_proc, key, (void**)&boptr, OPAL_BYTE_OBJECT);
|
2012-06-27 18:53:55 +04:00
|
|
|
|
2013-01-28 03:25:10 +04:00
|
|
|
if (OMPI_SUCCESS == rc) {
|
2012-06-27 18:53:55 +04:00
|
|
|
/* xfer the data for local use */
|
|
|
|
*buffer = boptr->bytes;
|
|
|
|
*size = boptr->size;
|
|
|
|
}
|
2013-01-03 06:04:54 +04:00
|
|
|
/* we no longer require the struct itself since all we
|
|
|
|
* wanted was the data inside it
|
|
|
|
*/
|
|
|
|
free(boptr);
|
2012-06-27 18:53:55 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-07-15 08:54:53 +04:00
|
|
|
int
|
|
|
|
ompi_modex_send_key_value(const char* key,
|
|
|
|
const void *value,
|
|
|
|
opal_data_type_t dtype)
|
|
|
|
{
|
|
|
|
int rc;
|
2012-06-27 18:53:55 +04:00
|
|
|
|
|
|
|
/* the store API makes a copy of the provided data */
|
2013-01-28 03:25:10 +04:00
|
|
|
rc = ompi_rte_db_store(OMPI_PROC_MY_NAME, key, value, dtype);
|
2009-07-15 08:54:53 +04:00
|
|
|
|
2012-06-27 18:53:55 +04:00
|
|
|
return rc;
|
2009-07-15 08:54:53 +04:00
|
|
|
}
|
|
|
|
|
2012-06-27 18:53:55 +04:00
|
|
|
int ompi_modex_recv_key_value(const char* key,
|
|
|
|
const ompi_proc_t *source_proc,
|
|
|
|
void **value, opal_data_type_t type)
|
2009-07-15 08:54:53 +04:00
|
|
|
{
|
|
|
|
int rc;
|
2012-06-27 18:53:55 +04:00
|
|
|
|
|
|
|
/* the fetch API returns the data */
|
2013-12-17 07:26:00 +04:00
|
|
|
rc = ompi_rte_db_fetch(source_proc, key, (void**)value, type);
|
2012-06-27 18:53:55 +04:00
|
|
|
|
2009-07-15 08:54:53 +04:00
|
|
|
return rc;
|
|
|
|
}
|