예제 #1
0
파일: set-attr.c 프로젝트: ajdecon/play
int main(int argc, char *argv[]) {
    int errs = 0;
    int key[3], attrval[3];
    int i;
    MPI_Comm comm;

    MPI_Init(&argc, &argv);
    comm = MPI_COMM_WORLD;

    /* Create key values */
    for (i=0; i<3; i++) {
        MPI_Comm_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. */
    MPI_Comm_set_attr(comm, key[2], &attrval[2]);
    MPI_Comm_set_attr(comm, key[1], &attrval[1]);
    MPI_Comm_set_attr(comm, key[0], &attrval[0]);
    errs += checkAttrs(comm, 3, key, attrval);

    MPI_Comm_delete_attr(comm, key[0]);
    MPI_Comm_delete_attr(comm, key[1]);
    MPI_Comm_delete_attr(comm, key[2]);
    errs += checkNoAttrs(comm,3,key);

    for (i=0;i<3;i++) {
        MPI_Comm_free_keyval(&key[i]);
    }
    MPI_Finalize();
    return 0;
}
예제 #2
0
int main( int argc, char *argv[] )
{
    int      attrval[10];
    int      wrank, i;
    MPI_Comm comm;

    MPI_Init( &argc, &argv );

    MPI_Comm_rank( MPI_COMM_WORLD, &wrank );

    comm = MPI_COMM_SELF;

    /* Create key values */
    for (nkeys=0; nkeys<NKEYS; nkeys++) {
        MPI_Comm_create_keyval( MPI_NULL_COPY_FN, delete_fn,
                                &key[nkeys], (void *)0 );
        attrval[nkeys] = 1024 * nkeys;
    }

    /* Insert attribute in several orders.  Test after put with get,
       then delete, then confirm delete with get. */

    MPI_Comm_set_attr( comm, key[3], &attrval[3] );
    keyorder[0] = 3;
    MPI_Comm_set_attr( comm, key[2], &attrval[2] );
    keyorder[1] = 2;
    MPI_Comm_set_attr( comm, key[0], &attrval[0] );
    keyorder[2] = 0;
    MPI_Comm_set_attr( comm, key[1], &attrval[1] );
    keyorder[3] = 1;
    MPI_Comm_set_attr( comm, key[4], &attrval[4] );
    keyorder[4] = 4;

    errs += checkAttrs( comm, NKEYS, key, attrval );

    for (i=0; i<NKEYS; i++) {
        /* Save the key value so that we can compare it in the
           delete function */
        int keyval = key[i];
        MPI_Comm_free_keyval( &keyval );
    }

    MPI_Finalize();

    if (wrank == 0) {
        if (ncall != nkeys) {
            printf( "Deleted %d keys but should have deleted %d\n",
                    ncall, nkeys );
            errs++;
        }
        if (errs == 0) printf( " No Errors\n" );
        else printf( " Found %d errors\n", errs );
    }
    return 0;

}
예제 #3
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;
  
}
예제 #4
0
int main(int argc, char *argv[])
{
    int errs = 0;
    int key[3], attrval[3];
    int i;
    MPI_Comm comm;

    MTest_Init(&argc, &argv);

    {
        comm = MPI_COMM_WORLD;
        /* Create key values */
        for (i = 0; i < 3; i++) {
            MPI_Keyval_create(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_Attr_put(comm, key[2], &attrval[2]);
        MPI_Attr_put(comm, key[1], &attrval[1]);
        MPI_Attr_put(comm, key[0], &attrval[0]);

        errs += checkAttrs(comm, 3, key, attrval);

        MPI_Attr_delete(comm, key[0]);
        MPI_Attr_delete(comm, key[1]);
        MPI_Attr_delete(comm, key[2]);

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

        MPI_Attr_put(comm, key[1], &attrval[1]);
        MPI_Attr_put(comm, key[2], &attrval[2]);
        MPI_Attr_put(comm, key[0], &attrval[0]);

        errs += checkAttrs(comm, 3, key, attrval);

        MPI_Attr_delete(comm, key[2]);
        MPI_Attr_delete(comm, key[1]);
        MPI_Attr_delete(comm, key[0]);

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

        MPI_Attr_put(comm, key[0], &attrval[0]);
        MPI_Attr_put(comm, key[1], &attrval[1]);
        MPI_Attr_put(comm, key[2], &attrval[2]);

        errs += checkAttrs(comm, 3, key, attrval);

        MPI_Attr_delete(comm, key[1]);
        MPI_Attr_delete(comm, key[2]);
        MPI_Attr_delete(comm, key[0]);

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

        for (i = 0; i < 3; i++) {
            MPI_Keyval_free(&key[i]);
        }
    }

    MTest_Finalize(errs);
    return MTestReturnValue(errs);
}