2005-05-01 04:53:00 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-02-07 06:32:36 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-01 04:53:00 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-05-01 04:53:00 +04:00
|
|
|
* Additional copyrights may follow
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-05-01 04:53:00 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal_config.h"
|
2005-05-01 04:53:00 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal/dss/dss_internal.h"
|
2005-05-01 04:53:00 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_peek(opal_buffer_t *buffer, opal_data_type_t *type,
|
|
|
|
int32_t *num_vals)
|
2005-05-01 04:53:00 +04:00
|
|
|
{
|
|
|
|
int ret;
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_buffer_t tmp;
|
|
|
|
int32_t n=1;
|
|
|
|
opal_data_type_t local_type;
|
2005-05-01 04:53:00 +04:00
|
|
|
|
|
|
|
/* check for errors */
|
|
|
|
if (buffer == NULL) {
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_BAD_PARAM;
|
2005-05-01 04:53:00 +04:00
|
|
|
}
|
|
|
|
|
2005-05-01 04:58:06 +04:00
|
|
|
/* Double check and ensure that there is data left in the buffer. */
|
|
|
|
|
|
|
|
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
|
2008-02-28 04:57:57 +03:00
|
|
|
*type = OPAL_NULL;
|
2005-05-01 04:58:06 +04:00
|
|
|
*num_vals = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
2005-05-01 04:58:06 +04:00
|
|
|
}
|
Bring over the ORTE 2.0 DSS. This introduces a few changes, almost all of which are transparent to the user:
1. Introduces a flag for the type of buffer that now allows a user to either have a fully described or a completely non-described buffer. In the latter case, no data type descriptions are included in the buffer. This obviously limits what we can do for debugging purposes, but the intent here was to provide an optimized communications capability for those wanting it.
Note that individual buffers can be designated for either type using the orte_dss.set_buffer_type command. In other words, the buffer type can be set dynamically - it isn't a configuration setting at all. The type will default to fully described. A buffer MUST be empty to set its type - this is checked by the set_buffer_type command, and you will receive an error if you violate that rule.
IMPORTANT NOTE: ORTE 1.x actually will NOT work with non-described buffers. This capability should therefore NOT be used until we tell you it is okay. For now, it is here simply so we can begin bringing over parts of ORTE 2.0. The problem is that ORTE 1.x depends upon the transmission of non-hard-cast data types such as size_t. These "soft" types currently utilize a "peek" function to see their actual type in the buffer - obviously, without description, the system has no idea how to unpack these "soft" types. We will deal with this later - for now, please don't use the non-described buffer option.
2. Introduces the orte_std_cntr_t type. This will become the replacement for the size_t's used throughout ORTE 1.x. At the moment, it is actually typedef'd to size_t for backward compatibility.
3. Introduces the orte_dss.arith API that supports arbitrary arithmetic functions on numeric data types. Calling the function with any other data type will generate an error.
This commit was SVN r11075.
2006-08-01 22:42:25 +04:00
|
|
|
|
|
|
|
/* if this is NOT a fully described buffer, then that is as much as
|
|
|
|
* we can do - there is no way we can tell the caller what type is
|
|
|
|
* in the buffer since that info wasn't stored.
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) {
|
|
|
|
*type = OPAL_UNDEF;
|
Bring over the ORTE 2.0 DSS. This introduces a few changes, almost all of which are transparent to the user:
1. Introduces a flag for the type of buffer that now allows a user to either have a fully described or a completely non-described buffer. In the latter case, no data type descriptions are included in the buffer. This obviously limits what we can do for debugging purposes, but the intent here was to provide an optimized communications capability for those wanting it.
Note that individual buffers can be designated for either type using the orte_dss.set_buffer_type command. In other words, the buffer type can be set dynamically - it isn't a configuration setting at all. The type will default to fully described. A buffer MUST be empty to set its type - this is checked by the set_buffer_type command, and you will receive an error if you violate that rule.
IMPORTANT NOTE: ORTE 1.x actually will NOT work with non-described buffers. This capability should therefore NOT be used until we tell you it is okay. For now, it is here simply so we can begin bringing over parts of ORTE 2.0. The problem is that ORTE 1.x depends upon the transmission of non-hard-cast data types such as size_t. These "soft" types currently utilize a "peek" function to see their actual type in the buffer - obviously, without description, the system has no idea how to unpack these "soft" types. We will deal with this later - for now, please don't use the non-described buffer option.
2. Introduces the orte_std_cntr_t type. This will become the replacement for the size_t's used throughout ORTE 1.x. At the moment, it is actually typedef'd to size_t for backward compatibility.
3. Introduces the orte_dss.arith API that supports arbitrary arithmetic functions on numeric data types. Calling the function with any other data type will generate an error.
This commit was SVN r11075.
2006-08-01 22:42:25 +04:00
|
|
|
*num_vals = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
Bring over the ORTE 2.0 DSS. This introduces a few changes, almost all of which are transparent to the user:
1. Introduces a flag for the type of buffer that now allows a user to either have a fully described or a completely non-described buffer. In the latter case, no data type descriptions are included in the buffer. This obviously limits what we can do for debugging purposes, but the intent here was to provide an optimized communications capability for those wanting it.
Note that individual buffers can be designated for either type using the orte_dss.set_buffer_type command. In other words, the buffer type can be set dynamically - it isn't a configuration setting at all. The type will default to fully described. A buffer MUST be empty to set its type - this is checked by the set_buffer_type command, and you will receive an error if you violate that rule.
IMPORTANT NOTE: ORTE 1.x actually will NOT work with non-described buffers. This capability should therefore NOT be used until we tell you it is okay. For now, it is here simply so we can begin bringing over parts of ORTE 2.0. The problem is that ORTE 1.x depends upon the transmission of non-hard-cast data types such as size_t. These "soft" types currently utilize a "peek" function to see their actual type in the buffer - obviously, without description, the system has no idea how to unpack these "soft" types. We will deal with this later - for now, please don't use the non-described buffer option.
2. Introduces the orte_std_cntr_t type. This will become the replacement for the size_t's used throughout ORTE 1.x. At the moment, it is actually typedef'd to size_t for backward compatibility.
3. Introduces the orte_dss.arith API that supports arbitrary arithmetic functions on numeric data types. Calling the function with any other data type will generate an error.
This commit was SVN r11075.
2006-08-01 22:42:25 +04:00
|
|
|
}
|
2005-05-01 04:58:06 +04:00
|
|
|
|
2005-05-01 04:53:00 +04:00
|
|
|
/* cheat: unpack from a copy of the buffer -- leaving all the
|
|
|
|
original pointers intact */
|
|
|
|
tmp = *buffer;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, &local_type))) {
|
|
|
|
*type = OPAL_NULL;
|
2005-05-01 04:58:06 +04:00
|
|
|
*num_vals = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_INT32 != local_type) { /* if the length wasn't first, then error */
|
|
|
|
*type = OPAL_NULL;
|
2005-05-01 04:58:06 +04:00
|
|
|
*num_vals = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_UNPACK_FAILURE;
|
2005-05-01 04:58:06 +04:00
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_dss_unpack_int32(&tmp, num_vals, &n, OPAL_INT32))) {
|
|
|
|
*type = OPAL_NULL;
|
2005-05-01 04:58:06 +04:00
|
|
|
*num_vals = 0;
|
2005-05-01 04:53:00 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, type))) {
|
|
|
|
*type = OPAL_NULL;
|
2005-05-01 04:58:06 +04:00
|
|
|
*num_vals = 0;
|
2005-05-01 04:53:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_peek_type(opal_buffer_t *buffer, opal_data_type_t *type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
|
|
|
int ret;
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_buffer_t tmp;
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
/* check for errors */
|
|
|
|
if (buffer == NULL) {
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_BAD_PARAM;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
Bring over the ORTE 2.0 DSS. This introduces a few changes, almost all of which are transparent to the user:
1. Introduces a flag for the type of buffer that now allows a user to either have a fully described or a completely non-described buffer. In the latter case, no data type descriptions are included in the buffer. This obviously limits what we can do for debugging purposes, but the intent here was to provide an optimized communications capability for those wanting it.
Note that individual buffers can be designated for either type using the orte_dss.set_buffer_type command. In other words, the buffer type can be set dynamically - it isn't a configuration setting at all. The type will default to fully described. A buffer MUST be empty to set its type - this is checked by the set_buffer_type command, and you will receive an error if you violate that rule.
IMPORTANT NOTE: ORTE 1.x actually will NOT work with non-described buffers. This capability should therefore NOT be used until we tell you it is okay. For now, it is here simply so we can begin bringing over parts of ORTE 2.0. The problem is that ORTE 1.x depends upon the transmission of non-hard-cast data types such as size_t. These "soft" types currently utilize a "peek" function to see their actual type in the buffer - obviously, without description, the system has no idea how to unpack these "soft" types. We will deal with this later - for now, please don't use the non-described buffer option.
2. Introduces the orte_std_cntr_t type. This will become the replacement for the size_t's used throughout ORTE 1.x. At the moment, it is actually typedef'd to size_t for backward compatibility.
3. Introduces the orte_dss.arith API that supports arbitrary arithmetic functions on numeric data types. Calling the function with any other data type will generate an error.
This commit was SVN r11075.
2006-08-01 22:42:25 +04:00
|
|
|
/* if this is NOT a fully described buffer, then there isn't anything
|
|
|
|
* we can do - there is no way we can tell the caller what type is
|
|
|
|
* in the buffer since that info wasn't stored.
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) {
|
|
|
|
*type = OPAL_UNDEF;
|
|
|
|
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
Bring over the ORTE 2.0 DSS. This introduces a few changes, almost all of which are transparent to the user:
1. Introduces a flag for the type of buffer that now allows a user to either have a fully described or a completely non-described buffer. In the latter case, no data type descriptions are included in the buffer. This obviously limits what we can do for debugging purposes, but the intent here was to provide an optimized communications capability for those wanting it.
Note that individual buffers can be designated for either type using the orte_dss.set_buffer_type command. In other words, the buffer type can be set dynamically - it isn't a configuration setting at all. The type will default to fully described. A buffer MUST be empty to set its type - this is checked by the set_buffer_type command, and you will receive an error if you violate that rule.
IMPORTANT NOTE: ORTE 1.x actually will NOT work with non-described buffers. This capability should therefore NOT be used until we tell you it is okay. For now, it is here simply so we can begin bringing over parts of ORTE 2.0. The problem is that ORTE 1.x depends upon the transmission of non-hard-cast data types such as size_t. These "soft" types currently utilize a "peek" function to see their actual type in the buffer - obviously, without description, the system has no idea how to unpack these "soft" types. We will deal with this later - for now, please don't use the non-described buffer option.
2. Introduces the orte_std_cntr_t type. This will become the replacement for the size_t's used throughout ORTE 1.x. At the moment, it is actually typedef'd to size_t for backward compatibility.
3. Introduces the orte_dss.arith API that supports arbitrary arithmetic functions on numeric data types. Calling the function with any other data type will generate an error.
This commit was SVN r11075.
2006-08-01 22:42:25 +04:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
/* Double check and ensure that there is data left in the buffer. */
|
|
|
|
|
|
|
|
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
|
2008-02-28 04:57:57 +03:00
|
|
|
*type = OPAL_UNDEF;
|
|
|
|
return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cheat: unpack from a copy of the buffer -- leaving all the
|
|
|
|
original pointers intact */
|
|
|
|
tmp = *buffer;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, type))) {
|
|
|
|
*type = OPAL_UNDEF;
|
2006-02-07 06:32:36 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_SUCCESS;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|