1
1

Adding more accurate checking of the input parameters for the

add_error_class and add_error_code files. Also fixed the update of the
lastusedcode attribute, all of work according to my tests pretty fine.

Please note: the testcode attached to the bug 683 still reports some bugs. I
am however pretty sure that the testcode is wrong at that points:
 - the standard says that the attribute MPI_LASTUSEDCODE has to be updated for
 a new error_class or a new error_code. The test currently assumes, that only
 the add_error_code call changes the attribute value.
 - you have to comment out the two lines 73 and 74 in order to make the
 test finish, since these lines check for the error string of non-existent
 codes.
- line 126 the error-string of MPI_ERR_ARG is not "invalid argument" but a
little bit more, so the test thinks the output is wrong. So probably the test
has to be update to match the according error string of MPI_ERR_ARG.

Fixes trac:682

This commit was SVN r12913.

The following Trac tickets were found above:
  Ticket 682 --> https://svn.open-mpi.org/trac/ompi/ticket/682
Этот коммит содержится в:
Edgar Gabriel 2006-12-21 19:36:31 +00:00
родитель f1aec23507
Коммит dc532577db
5 изменённых файлов: 87 добавлений и 10 удалений

Просмотреть файл

@ -430,8 +430,8 @@ int ompi_mpi_errcode_init (void)
strcpy(ompi_err_win.errstring, "MPI_ERR_WIN:invalid window");
ompi_pointer_array_set_item(&ompi_mpi_errcodes, MPI_ERR_WIN, &ompi_err_win);
ompi_mpi_errcode_lastused=MPI_ERR_WIN+1;
ompi_mpi_errcode_lastpredefined=MPI_ERR_WIN+1;
ompi_mpi_errcode_lastused=MPI_ERR_WIN;
ompi_mpi_errcode_lastpredefined=MPI_ERR_WIN;
return OMPI_SUCCESS;
}
@ -440,7 +440,7 @@ int ompi_mpi_errcode_finalize(void)
int i;
ompi_mpi_errcode_t *errc;
for (i=ompi_mpi_errcode_lastpredefined; i<ompi_mpi_errcode_lastused; i++) {
for (i=ompi_mpi_errcode_lastpredefined+1; i<=ompi_mpi_errcode_lastused; i++) {
/*
* there are some user defined error-codes, which
* we have to free.
@ -513,7 +513,7 @@ int ompi_mpi_errcode_add(int errclass )
ompi_mpi_errcode_t *newerrcode;
newerrcode = OBJ_NEW(ompi_mpi_errcode_t);
newerrcode->code = ompi_mpi_errcode_lastused;
newerrcode->code = (ompi_mpi_errcode_lastused+1);
newerrcode->cls = errclass;
ompi_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->code, newerrcode);
@ -526,7 +526,7 @@ int ompi_mpi_errclass_add(void)
ompi_mpi_errcode_t *newerrcode;
newerrcode = OBJ_NEW(ompi_mpi_errcode_t);
newerrcode->cls = ompi_mpi_errcode_lastused;
newerrcode->cls = ( ompi_mpi_errcode_lastused+1);
ompi_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->cls, newerrcode);
ompi_mpi_errcode_lastused++;

Просмотреть файл

@ -36,8 +36,6 @@ extern "C" {
* Please note:
* if code == MPI_UNDEFINED, than the according structure
* represents an error class.
* if cls == MPI_UNDEFINED, than the according structure
* represents an error code.
* For the predefined error codes and classes, code and
* cls are both set to the according value.
*/
@ -51,6 +49,7 @@ typedef struct ompi_mpi_errcode_t ompi_mpi_errcode_t;
OMPI_DECLSPEC extern ompi_pointer_array_t ompi_mpi_errcodes;
OMPI_DECLSPEC extern int ompi_mpi_errcode_lastused;
OMPI_DECLSPEC extern int ompi_mpi_errcode_lastpredefined;
OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown;
@ -59,7 +58,7 @@ OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown;
*/
static inline bool ompi_mpi_errcode_is_invalid(int errcode)
{
if ( errcode >= 0 && errcode < ompi_mpi_errcode_lastused )
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastused )
return 0;
else
return 1;
@ -81,6 +80,38 @@ static inline int ompi_mpi_errcode_get_class (int errcode)
}
return ompi_err_unknown.cls;
}
static inline int ompi_mpi_errcode_is_predefined ( int errcode )
{
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastpredefined )
return true;
return false;
}
static inline int ompi_mpi_errnum_is_class ( int errnum )
{
ompi_mpi_errcode_t *err;
if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
/* Predefined error values represent an error code and
an error class at the same time */
return true;
}
err = (ompi_mpi_errcode_t *)ompi_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
if (NULL != err) {
if ( MPI_UNDEFINED == err->code) {
/* Distinction between error class and error code is that for the
first one the code section is set to MPI_UNDEFINED */
return true;
}
}
return false;
}
/**
* Return the error string
*/

Просмотреть файл

@ -21,6 +21,7 @@
#include "ompi/mpi/c/bindings.h"
#include "ompi/errhandler/errcode.h"
#include "ompi/attribute/attribute.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
#pragma weak MPI_Add_error_class = PMPI_Add_error_class
@ -36,6 +37,7 @@ static const char FUNC_NAME[] = "MPI_Add_error_class";
int MPI_Add_error_class(int *errorclass)
{
int err_class;
int rc;
if ( MPI_PARAM_CHECK ) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
@ -47,6 +49,22 @@ int MPI_Add_error_class(int *errorclass)
FUNC_NAME);
}
/*
** Update the attribute value. See the comments
** in attribute/attribute.c and attribute/attribute_predefined.c
** why we have to call the fortran attr_set function
*/
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true, true);
if ( MPI_SUCCESS != rc ) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
}
*errorclass = err_class;
return MPI_SUCCESS;
}

Просмотреть файл

@ -21,6 +21,7 @@
#include "ompi/mpi/c/bindings.h"
#include "ompi/errhandler/errcode.h"
#include "ompi/attribute/attribute.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
#pragma weak MPI_Add_error_code = PMPI_Add_error_code
@ -36,6 +37,7 @@ static const char FUNC_NAME[] = "MPI_Add_error_code";
int MPI_Add_error_code(int errorclass, int *errorcode)
{
int code;
int rc;
if ( MPI_PARAM_CHECK ) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
@ -44,6 +46,9 @@ int MPI_Add_error_code(int errorclass, int *errorcode)
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
if ( !ompi_mpi_errnum_is_class ( errorclass) )
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
}
code = ompi_mpi_errcode_add ( errorclass);
@ -52,6 +57,21 @@ int MPI_Add_error_code(int errorclass, int *errorcode)
FUNC_NAME);
}
/*
** Update the attribute value. See the comments
** in attribute/attribute.c and attribute/attribute_predefined.c
** why we have to call the fortran attr_set function
*/
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true, true);
if ( MPI_SUCCESS != rc ) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
}
*errorcode = code;
return MPI_SUCCESS;
}

Просмотреть файл

@ -44,6 +44,14 @@ int MPI_Add_error_string(int errorcode, char *string)
if ( ompi_mpi_errcode_is_invalid(errorcode) )
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
if ( ompi_mpi_errcode_is_predefined(errorcode) )
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
if ( MPI_MAX_ERROR_STRING < (strlen(string)+1) )
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
}
rc = ompi_mpi_errnum_add_string (errorcode, string, (int)(strlen(string)+1));