Exemplo n.º 1
0
int main( int argc, char *argv[] )
{
    int errs = 0;
    char string[MPI_MAX_ERROR_STRING], outstring[MPI_MAX_ERROR_STRING];
    int newclass[NCLASSES], newcode[NCLASSES][NCODES];
    int i, j, slen, outclass;

    MTest_Init( &argc, &argv );

    /* Initialize the new codes */
    for (i=0; i<NCLASSES; i++) {
	MPI_Add_error_class( &newclass[i] );
	for (j=0; j<NCODES; j++) {
	    MPI_Add_error_code( newclass[i], &newcode[i][j] );
	    sprintf( string, "code for class %d code %d\n", i, j );
	    MPI_Add_error_string( newcode[i][j], string );
	}
    }

    /* check the values */
    for (i=0; i<NCLASSES; i++) {
	MPI_Error_class( newclass[i], &outclass );
	if (outclass != newclass[i]) {
	    errs++;
	    printf( "Error class %d is not a valid error code %x %x\n", i,
		    outclass, newclass[i]);
	}
	for (j=0; j<NCODES; j++) {
	    MPI_Error_class( newcode[i][j], &outclass );
	    if (outclass != newclass[i]) {
		errs++;
		printf( "Class of code for %d is not correct %x %x\n", j,
			outclass, newclass[i] );
	    }
	    MPI_Error_string( newcode[i][j], outstring, &slen );
	    sprintf( string, "code for class %d code %d\n", i, j );
	    if (strcmp( outstring, string )) {
		errs++;
		printf( "Error string is :%s: but should be :%s:\n",
			outstring, string );
	    }
	}
    }

    MTest_Finalize( errs );
    MPI_Finalize();
    return 0;
  
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    int errorclass;
    char errorstring[MPI_MAX_ERROR_STRING] = { 64, 0 };
    int slen;
    MPI_Init(&argc, &argv);
    MPI_Add_error_class(&errorclass);
    MPI_Error_string(errorclass, errorstring, &slen);
    if (strncmp(errorstring, "", 1)) {
        fprintf(stderr, "errorclass:%d errorstring:'%s' len:%d\n", errorclass, errorstring, slen);
    }
    else {
        printf(" No Errors\n");
    }
    MPI_Finalize();
    return 0;
}
Exemplo n.º 3
0
/**
 * Initialize error codes by adding information about them to MPI as described in MPI specification.
 *
 * @returns Error code as described in MPI specification.
 */
int init_error_codes() {
   int result, i;
   int error_codes_count = 8;
   int *error_codes[] = {
      &MPI_ERR_PMEM_ROOT_PATH,
      &MPI_ERR_PMEM_NAME,
      &MPI_ERR_PMEM_CKPT_VER,
      &MPI_ERR_PMEM_MODE,
      &MPI_ERR_PMEM_WINDOWS,
      &MPI_ERR_PMEM_VERSIONS,
      &MPI_ERR_PMEM_ARG,
      &MPI_ERR_PMEM_NO_MEM };
   char *error_strings[] = {
      "Invalid root path",
      "Invalid persistent memory area name",
      "Invalid checkpoint version",
      "Invalid mode",
      "Invalid windows argument",
      "Invalid versions argument",
      "Invalid argument of some other kind",
      "Unable to allocate memory" };

   mpi_log_debug("Initializing error codes.");

   // Add global error class
   result = MPI_Add_error_class(&MPI_ERR_PMEM);
   CHECK_ERROR_CODE(result);
   result = MPI_Add_error_string(MPI_ERR_PMEM, "General MPI PMEM error");
   CHECK_ERROR_CODE(result);

   // Add individual error codes to class.
   for (i = 0; i < error_codes_count; i++) {
      result = MPI_Add_error_code(MPI_ERR_PMEM, error_codes[i]);
      CHECK_ERROR_CODE(result);
      result = MPI_Add_error_string(*error_codes[i], error_strings[i]);
      CHECK_ERROR_CODE(result);
   }

   mpi_log_debug("Error codes initialized.");

   return MPI_SUCCESS;
}