예제 #1
0
void csetmpitype_( MPI_Fint *ftype, MPI_Fint *fkey, MPI_Aint *val, 
		   MPI_Fint *errs )
{
    MPI_Datatype dtype = MPI_Type_f2c( *ftype );
    
    MPI_Type_set_attr( dtype, *fkey, (void *)*val );
}
예제 #2
0
JNIEXPORT void JNICALL Java_mpi_Datatype_setAttr(
        JNIEnv *env, jobject jthis, jlong type, jint keyval, jbyteArray jval)
{
    void *cval = ompi_java_attrSet(env, jval);
    int rc = MPI_Type_set_attr((MPI_Datatype)type, keyval, cval);
    ompi_java_exceptionCheck(env, rc);
}
예제 #3
0
int main(int argc, char *argv[])
{
    int mpi_errno;
    MPI_Datatype type, duptype;
    int rank;

    MPI_Init(&argc, &argv);
    
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );

    foo_initialize();

    mpi_errno = MPI_Type_contiguous(2, MPI_INT, &type);

    mpi_errno = MPI_Type_set_attr(type, foo_keyval, NULL);

    mpi_errno = MPI_Type_dup(type, &duptype);

    my_func = "Free of type";
    mpi_errno = MPI_Type_free(&type);

    my_func = "free of duptype";
    mpi_errno = MPI_Type_free(&duptype);

    foo_finalize();

    if (rank == 0) {
      int errs = 0;
      if (copy_called != 1) {
	printf( "Copy called %d times; expected once\n", copy_called );
	errs++;
      }
      if (delete_called != 2) {
	printf( "Delete called %d times; expected twice\n", delete_called );
	errs++;
      }
      if (errs == 0) {
	printf( " No Errors\n" );
      }
      else {
	printf( " Found %d errors\n", errs );
      }
      fflush(stdout);
    }

    MPI_Finalize();
    return 0;
}
예제 #4
0
int main( int argc, char *argv[] )
{
    int errs = 0;
    int attrval;
    int i, key[32], keyval, saveKeyval;
    MPI_Datatype type, duptype;
    MTestDatatype mstype, mrtype;
    char typename[MPI_MAX_OBJECT_NAME];
    int tnlen;

    MTest_Init( &argc, &argv );

    while (MTestGetDatatypes( &mstype, &mrtype, 1 )) {
        type = mstype.datatype;
        MPI_Type_create_keyval( copy_fn, delete_fn, &keyval, (void *)0 );
        saveKeyval = keyval;   /* in case we need to free explicitly */
        attrval = 1;
        MPI_Type_set_attr( type, keyval, (void*)&attrval );
        /* See MPI-1, 5.7.1.  Freeing the keyval does not remove it if it
           is in use in an attribute */
        MPI_Type_free_keyval( &keyval );

        /* We create some dummy keyvals here in case the same keyval
           is reused */
        for (i=0; i<32; i++) {
            MPI_Type_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
                                    &key[i], (void *)0 );
        }

        if (attrval != 1) {
            errs++;
            MPI_Type_get_name( type, typename, &tnlen );
            printf( "attrval is %d, should be 1, before dup in type %s\n",
                    attrval, typename );
        }
        MPI_Type_dup( type, &duptype );
        /* Check that the attribute was copied */
        if (attrval != 2) {
            errs++;
            MPI_Type_get_name( type, typename, &tnlen );
            printf( "Attribute not incremented when type dup'ed (%s)\n",
                    typename );
        }
예제 #5
0
int main(int argc, char *argv[])
{
    int comm_keyval, win_keyval, type_keyval;
    int comm_aval;
    int err, errs = 0;
    int buf, flag;
    MPI_Win win;
    void *rval;
    MPI_Datatype dtype;

    MTest_Init(&argc, &argv);

    MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, MPI_COMM_NULL_DELETE_FN, &comm_keyval, 0);
    MPI_Win_create_keyval(MPI_WIN_NULL_COPY_FN, MPI_WIN_NULL_DELETE_FN, &win_keyval, 0);
    MPI_Type_create_keyval(MPI_TYPE_NULL_COPY_FN, MPI_TYPE_NULL_DELETE_FN, &type_keyval, 0);
    MPI_Type_contiguous(4, MPI_DOUBLE, &dtype);
    MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);

    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    err = MPI_Comm_set_attr(MPI_COMM_WORLD, win_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_set_attr accepted win keyval\n");
    }
    err = MPI_Comm_set_attr(MPI_COMM_WORLD, type_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_set_attr accepted type keyval\n");
    }
    err = MPI_Type_set_attr(dtype, win_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Type_set_attr accepted win keyval\n");
    }
    err = MPI_Type_set_attr(dtype, comm_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_set_attr accepted type keyval\n");
    }
    err = MPI_Win_set_attr(win, comm_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Win_set_attr accepted comm keyval\n");
    }
    err = MPI_Win_set_attr(win, type_keyval, &comm_aval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Win_set_attr accepted type keyval\n");
    }

    err = MPI_Comm_get_attr(MPI_COMM_WORLD, win_keyval, &rval, &flag);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_get_attr accepted win keyval\n");
    }
    err = MPI_Comm_get_attr(MPI_COMM_WORLD, type_keyval, &rval, &flag);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_get_attr accepted type keyval\n");
    }

    err = MPI_Comm_free_keyval(&win_keyval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_free_keyval accepted win keyval\n");
    }
    err = MPI_Comm_free_keyval(&type_keyval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Comm_free_keyval accepted type keyval\n");
    }
    if (win_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Type_free_keyval(&win_keyval);
        if (err == MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Type_free_keyval accepted win keyval\n");
        }
    }
    err = MPI_Type_free_keyval(&comm_keyval);
    if (err == MPI_SUCCESS) {
        errs++;
        fprintf(stderr, "Type_free_keyval accepted comm keyval\n");
    }
    if (type_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Win_free_keyval(&type_keyval);
        if (err == MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Win_free_keyval accepted type keyval\n");
        }
    }
    if (comm_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Win_free_keyval(&comm_keyval);
        if (err == MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Win_free_keyval accepted comm keyval\n");
        }
    }

    /* Now, free for real */
    if (comm_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Comm_free_keyval(&comm_keyval);
        if (err != MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Could not free comm keyval\n");
        }
    }
    if (type_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Type_free_keyval(&type_keyval);
        if (err != MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Could not free type keyval\n");
        }
    }
    if (win_keyval != MPI_KEYVAL_INVALID) {
        err = MPI_Win_free_keyval(&win_keyval);
        if (err != MPI_SUCCESS) {
            errs++;
            fprintf(stderr, "Could not free win keyval\n");
        }
    }

    MPI_Win_free(&win);
    MPI_Type_free(&dtype);


    MTest_Finalize(errs);

    return MTestReturnValue(errs);
}
예제 #6
0
void ctoctest_( MPI_Fint *errs )
{
    int errcnt = *errs;
    int baseattrval = (1 << (sizeof(int)*8-2))-3;
    MPI_Datatype cduptype;
    MPI_Comm   cdup;

    /* MPI-1 function */
    ccomm1Attr = baseattrval;
    MPI_Attr_put( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr );
    /* Test that we have the same value */
    errcnt += cmpi1read( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr, "C to C" );

    /* Dup, check that the copy routine does what is expected */
    MPI_Comm_dup( MPI_COMM_SELF, &cdup );
    errcnt += cmpi1read( cdup, ccomm1Key, &ccomm1Attr, "C to C dup" );
    if (ccomm1Attr != baseattrval + 1) {
	printf( " Did not increment int in C to C dup: %d %d\n", 
		ccomm1Attr, baseattrval + 1 );
	errcnt ++;
    }

    MPI_Comm_free( &cdup );
    if (ccomm1Attr != baseattrval) {
	printf( " Did not increment int in C to C delete: %d %d\n", 
		ccomm1Attr, baseattrval );
	errcnt ++;
    }

    /* MPI-2 functions */
    ccomm1Attr = 0;
    ccomm2Attr = baseattrval;
    MPI_Comm_set_attr( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr );
    /* Test that we have the same value */
    errcnt += cmpi2read( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr, "C to C (2)" );

    /* Dup, check that the copy routine does what is expected */
    MPI_Comm_dup( MPI_COMM_SELF, &cdup );
    errcnt += cmpi2read( cdup, ccomm2Key, &ccomm2Attr, "C to C dup (2)" );
    if (ccomm2Attr != baseattrval + 1) {
	printf( " Did not increment int in C to C dup: %d %d\n", 
		ccomm2Attr, baseattrval + 1 );
	errcnt ++;
    }

    MPI_Comm_free( &cdup );
    if (ccomm2Attr != baseattrval) {
	printf( " Did not increment int in C to C delete (2): %d %d\n", 
		ccomm2Attr, baseattrval );
	errcnt ++;
    }

    /* MPI-2 functions */
    ctype2Attr = baseattrval;
    MPI_Type_set_attr( MPI_INTEGER, ctype2Key, &ctype2Attr );
    /* Test that we have the same value */
    errcnt += cmpi2readtype( MPI_INTEGER, ctype2Key, &ctype2Attr, "C to C type (2)" );

    /* Dup, check that the copy routine does what is expected */
    MPI_Type_dup( MPI_INTEGER, &cduptype );
    errcnt += cmpi2readtype( cduptype, ctype2Key, &ctype2Attr, "C to C typedup (2)" );
    if (ctype2Attr != baseattrval + 1) {
	printf( " Did not increment int in C to C typedup: %d %d\n", 
		ctype2Attr, baseattrval + 1 );
	errcnt ++;
    }
    ccomm1Attr = 0;

    MPI_Type_free( &cduptype );
    if (ctype2Attr != baseattrval) {
	printf( " Did not increment int in C to C typedelete (2): %d %d\n", 
		ctype2Attr, baseattrval );
	errcnt ++;
    }

    
    *errs = errcnt;
}
예제 #7
0
int main( int argc, char *argv[] )
{
    int errs = 0;
    int key[3], attrval[3];
    int i;
    MPI_Datatype type;

    MTest_Init( &argc, &argv );

    {
	type = MPI_INT;
	/* Create key values */
	for (i=0; i<3; i++) {
	    MPI_Type_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
			       &key[i], (void *)0 );
	    attrval[i] = 1024 * i;
	}
	
	/* Insert attribute in several orders.  Test after put with get,
	 then delete, then confirm delete with get. */

	MPI_Type_set_attr( type, key[2], &attrval[2] );
	MPI_Type_set_attr( type, key[1], &attrval[1] );
	MPI_Type_set_attr( type, key[0], &attrval[0] );

	errs += checkAttrs( type, 3, key, attrval );
	
	MPI_Type_delete_attr( type, key[0] );
	MPI_Type_delete_attr( type, key[1] );
	MPI_Type_delete_attr( type, key[2] );

	errs += checkNoAttrs( type, 3, key );
	
	MPI_Type_set_attr( type, key[1], &attrval[1] );
	MPI_Type_set_attr( type, key[2], &attrval[2] );
	MPI_Type_set_attr( type, key[0], &attrval[0] );

	errs += checkAttrs( type, 3, key, attrval );
	
	MPI_Type_delete_attr( type, key[2] );
	MPI_Type_delete_attr( type, key[1] );
	MPI_Type_delete_attr( type, key[0] );

	errs += checkNoAttrs( type, 3, key );

	MPI_Type_set_attr( type, key[0], &attrval[0] );
	MPI_Type_set_attr( type, key[1], &attrval[1] );
	MPI_Type_set_attr( type, key[2], &attrval[2] );

	errs += checkAttrs( type, 3, key, attrval );
	
	MPI_Type_delete_attr( type, key[1] );
	MPI_Type_delete_attr( type, key[2] );
	MPI_Type_delete_attr( type, key[0] );

	errs += checkNoAttrs( type, 3, key );
	
	for (i=0; i<3; i++) {
	    MPI_Type_free_keyval( &key[i] );
	}
    }
    
    MTest_Finalize( errs );
    MPI_Finalize();
    return 0;
  
}