• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MTest_Init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MTest_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ MTest_Init函数的具体用法?C++ MTest_Init怎么用?C++ MTest_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MTest_Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

/* #define VERBOSE 1 */
int main(int argc, char *argv[])
{
    int i, rank;
    int rc, maxcomm;
    int errs = 0;
    MPI_Comm comm[MAX_COMMS];

    MTest_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    maxcomm = -1;
    for (i = 0; i < MAX_COMMS; i++) {
#ifdef VERBOSE
        if (rank == 0) {
            if (i % 20 == 0) {
                fprintf(stderr, "\n %d: ", i);
                fflush(stdout);
            }
            else {
                fprintf(stderr, ".");
                fflush(stdout);
            }
        }
#endif
        rc = MPI_Comm_split(MPI_COMM_WORLD, 1, rank, &comm[i]);
        if (rc != MPI_SUCCESS) {
            break;
        }
        maxcomm = i;
    }
    for (i = 0; i <= maxcomm; i++) {
        MPI_Comm_free(&comm[i]);
    }
    /* If we complete, there are no errors */
    MTest_Finalize(errs);
    MPI_Finalize();
    return 0;
}
开发者ID:NexMirror,项目名称:MPICH,代码行数:40,代码来源:manysplit.c


示例2: main

int main(int argc, char *argv[])
{
    int size, rank;
    MPI_Group world_group;
    MPI_Comm group_comm, idup_comm;
    MPI_Request req;
    MTest_Init(&argc, &argv);

    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    if (size % 2) {
        fprintf(stderr, "this program requires even number of processes\n");
        MPI_Abort(MPI_COMM_WORLD, 1);
    }

    /* Create some groups */
    MPI_Comm_group(MPI_COMM_WORLD, &world_group);

    if (rank % 2 == 0) {
        MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm);
        MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req);
    } else {
        MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req);
        MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm);
    }

    MPI_Wait(&req, MPI_STATUSES_IGNORE);
    /*Test new comm with a barrier */
    MPI_Barrier(idup_comm);
    MPI_Barrier(group_comm);

    MPI_Group_free(&world_group);
    MPI_Comm_free(&idup_comm);
    MPI_Comm_free(&group_comm);

    MTest_Finalize(0);
    return 0;
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:39,代码来源:comm_create_group_idup.c


示例3: main

int main(int argc, char *argv[])
{
    int rank, size;
    MPI_Datatype type;
    int errclass, errs = 0, mpi_errno;

    MTest_Init(&argc, &argv);

    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    /* Checking type_extent for NULL variable */
    type = MPI_INT;
    mpi_errno = MPI_Type_extent(type, NULL);
    MPI_Error_class(mpi_errno, &errclass);
    if (errclass != MPI_ERR_ARG)
        ++errs;

    MTest_Finalize(errs);
    return 0;
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:22,代码来源:type_extent_nullarg.c


示例4: main

int main(int argc, char *argv[])
{
    int errors = 0;
    int elems = 20;
    int rank, nproc, dest, i;
    float *in_buf, *out_buf;
    MPI_Comm comm;
    MPI_Request *reqs;

    MTest_Init(&argc, &argv);

    comm = MPI_COMM_WORLD;
    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &nproc);

    reqs = (MPI_Request *) malloc(2 * nproc * sizeof(MPI_Request));
    in_buf = (float *) malloc(elems * nproc * sizeof(float));
    out_buf = (float *) malloc(elems * nproc * sizeof(float));
    MTEST_VG_MEM_INIT(out_buf, elems * nproc * sizeof(float));

    for (i = 0; i < nproc; i++) {
        MPI_Irecv(&in_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i]);
    }

    for (i = 0; i < nproc; i++) {
        MPI_Isend(&out_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i + nproc]);
    }

    MPI_Waitall(nproc * 2, reqs, MPI_STATUSES_IGNORE);

    free(reqs);
    free(in_buf);
    free(out_buf);
    MTest_Finalize(errors);
    MPI_Finalize();
    return 0;

}
开发者ID:NexMirror,项目名称:MPICH,代码行数:38,代码来源:isendirecv.c


示例5: main

int main( int argc, char * argv[] )
{
    int rank;
    int sendMsg = 123;
    int recvMsg = 0;
    int flag = 0;
    int count;
    MPI_Status status;
    MPI_Request request;
    int errs = 0;

    MTest_Init( 0, 0 );

    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    if(rank == 0)
    {
	MPI_Isend( &sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request );
	while(!flag)
	{
	    MPI_Iprobe( 0, 0, MPI_COMM_WORLD, &flag, &status );
	}
	MPI_Get_count( &status, MPI_INT, &count );
	if(count != 1)
	{
	    errs++;
	}
	MPI_Recv( &recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status );
	if(recvMsg != 123)
	{
	    errs++;
	}
	MPI_Wait( &request, &status );
    }
    MTest_Finalize( errs );
    MPI_Finalize();
    return 0;
}
开发者ID:abhinavvishnu,项目名称:matex,代码行数:38,代码来源:isendselfprobe.c


示例6: main

int main (int argc, char **argv)
{
    MPI_Comm duped;
    int keyval = MPI_KEYVAL_INVALID;
    int keyval_copy = MPI_KEYVAL_INVALID;
    int errs=0;

    MTest_Init( &argc, &argv );
    MPI_Comm_dup(MPI_COMM_SELF, &duped);

    MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn,  &keyval, NULL);
    keyval_copy = keyval;

    MPI_Attr_put(MPI_COMM_SELF, keyval, NULL);
    MPI_Attr_put(duped, keyval, NULL);

    MPI_Comm_free(&duped);         /* first MPI_Keyval_free */
    MPI_Keyval_free(&keyval);      /* second MPI_Keyval_free */
    MPI_Keyval_free(&keyval_copy); /* third MPI_Keyval_free */
    MTest_Finalize( errs );
    MPI_Finalize();                /* fourth MPI_Keyval_free */
    return 0;
}
开发者ID:OngOngoing,项目名称:219351_homework,代码行数:23,代码来源:keyval_double_free.c


示例7: main

int main(int argc, char **argv)
{
    MPI_Group basegroup;
    MPI_Group g1;
    MPI_Comm comm, newcomm;
    int errs = 0, mpi_errno, errclass, rank, size;
    int range[1][3];
    int worldrank;

    MTest_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &worldrank);
    comm = MPI_COMM_WORLD;
    MPI_Comm_group(comm, &basegroup);
    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);
    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    MPI_Comm_split(comm, 0, size - rank, &newcomm);
    MPI_Comm_group(newcomm, &g1);

    /* Checking group_range_excl for NULL variable */
    range[0][0] = 1;
    range[0][1] = size-1;
    range[0][2] = 1;
    mpi_errno = MPI_Group_range_incl(basegroup, 1, range, NULL);
    MPI_Error_class(mpi_errno, &errclass);
    if (errclass != MPI_ERR_ARG)
        ++errs;

    MPI_Comm_free(&comm);
    MPI_Comm_free(&newcomm);
    MPI_Group_free(&basegroup);
    MPI_Group_free(&g1);
    MTest_Finalize(errs);
    MPI_Finalize();
    return 0;
}
开发者ID:NexMirror,项目名称:MPICH,代码行数:37,代码来源:group_range_incl_nullarg.c


示例8: main

int main(int argc, char **argv)
{
    MPI_Group basegroup;
    MPI_Group g1, g2;
    MPI_Comm comm, newcomm, dupcomm;
    int errs = 0, mpi_errno, rank, size;
    int errclass, worldrank;

    MTest_Init( &argc, &argv );
    MPI_Comm_rank( MPI_COMM_WORLD, &worldrank );
    comm = MPI_COMM_WORLD;
    MPI_Comm_group( comm, &basegroup );
    MPI_Comm_rank( comm, &rank );
    MPI_Comm_size( comm, &size );
    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    MPI_Comm_split( comm, 0, size - rank, &newcomm );
    MPI_Comm_group( newcomm, &g1);
    MPI_Comm_dup( comm, &dupcomm );
    MPI_Comm_group( dupcomm, &g2 );

    /* checking group_union for NULL variable */
    mpi_errno = MPI_Group_union( g1, g2, NULL );
    MPI_Error_class(mpi_errno, &errclass);
    if (errclass != MPI_ERR_ARG)
        ++errs;

    MPI_Comm_free(&comm);
    MPI_Comm_free(&newcomm);
    MPI_Comm_free(&dupcomm);
    MPI_Group_free(&basegroup);
    MPI_Group_free(&g1);
    MPI_Group_free(&g2);
    MTest_Finalize(errs);
    MPI_Finalize();
    return 0;
}
开发者ID:NexMirror,项目名称:MPICH,代码行数:37,代码来源:group_union_nullarg.c


示例9: main

int main( int argc, char *argv[] )
{
    MPI_Status status;
    int        err, errs = 0, len;
    char       msg[MPI_MAX_ERROR_STRING];

    MTest_Init( &argc, &argv );
    MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );

    err = MPI_Probe( -80, 1, MPI_COMM_WORLD, &status );
    if (!err) {
	errs++;
	printf( "Did not detect an erroneous rank in MPI_Probe\n" );
    }
    else {
	/* Check that we can get a message for this error */
	/* (This works if it does not SEGV or hang) */
	MPI_Error_string( err, msg, &len );
    }

    MTest_Finalize( errs );
    MPI_Finalize( );
    return 0;
}
开发者ID:OngOngoing,项目名称:219351_homework,代码行数:24,代码来源:proberank.c


示例10: main

int main(int argc, char *argv[]) 
{ 
    int rank, nprocs, i, A[SIZE], B[SIZE];
    MPI_Comm CommDeuce;
    MPI_Win win;
    int errs = 0;

    MTest_Init(&argc,&argv); 

    MPI_Comm_size(MPI_COMM_WORLD,&nprocs); 
    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 

    if (nprocs < 2) {
        printf("Run this program with 2 or more processes\n");
        MPI_Abort(MPI_COMM_WORLD, 1);
    }

    MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);

    if (rank < 2) {
        if (rank == 0) {
            for (i=0; i<SIZE; i++)
                B[i] = 500 + i;
            MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
            MPI_Win_fence(0, win);
            for (i=0; i<SIZE; i++) {
                A[i] = i+100;
                MPI_Get(&A[i], 1, MPI_INT, 1, i, 1, MPI_INT, win);
            }
            MPI_Win_fence(0, win);
            for (i=0; i<SIZE; i++)
                if (A[i] != 1000 + i) {
                    SQUELCH( printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000+i); );
                    errs++;
                }
        }
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:36,代码来源:test5.c


示例11: main

int main( int argc, char *argv[] )
{
    int errs = 0;
    int majversion, subversion;

    MTest_Init( &argc, &argv );

    MPI_Get_version( &majversion, &subversion );
    if (majversion != MPI_VERSION) {
	errs++;
	printf( "Major version is %d but is %d in the mpi.h file\n", 
		majversion, MPI_VERSION );
    }
    if (subversion != MPI_SUBVERSION) {
	errs++;
	printf( "Minor version is %d but is %d in the mpi.h file\n", 
		subversion, MPI_SUBVERSION );
    }
    
    MTest_Finalize( errs );
    MPI_Finalize();
    return 0;
  
}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:24,代码来源:version.c


示例12: main

int main(int argc, char **argv)
{
    int rank, size;
    int data;
    int errors = 0;
    int result = -100;
    MPI_Op op;

    MTest_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);

    data = rank;

    MPI_Op_create((MPI_User_function *) assoc, 0, &op);
    MPI_Reduce(&data, &result, 1, MPI_INT, op, size - 1, MPI_COMM_WORLD);
    MPI_Bcast(&result, 1, MPI_INT, size - 1, MPI_COMM_WORLD);
    MPI_Op_free(&op);
    if (result == BAD_ANSWER)
        errors++;

    MTest_Finalize(errors);
    return MTestReturnValue(errors);
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:24,代码来源:coll10.c


示例13: main

int main( int argc, char **argv )
{

    MPI_Comm comm;
    int      *sbuf, *rbuf;
    int      rank, size;
    int      *sendcounts, *recvcounts, *rdispls, *sdispls;
    int      i, j, *p, err;
    MPI_Datatype *sendtypes, *recvtypes;
    
    MTest_Init( &argc, &argv );
    err = 0;
    
    while (MTestGetIntracommGeneral( &comm, 2, 1 )) {
      if (comm == MPI_COMM_NULL) continue;

      /* Create the buffer */
      MPI_Comm_size( comm, &size );
      MPI_Comm_rank( comm, &rank );
      sbuf = (int *)malloc( size * size * sizeof(int) );
      rbuf = (int *)malloc( size * size * sizeof(int) );
      if (!sbuf || !rbuf) {
	fprintf( stderr, "Could not allocated buffers!\n" );
	MPI_Abort( comm, 1 );
      }
      
      /* Load up the buffers */
      for (i=0; i<size*size; i++) {
	sbuf[i] = i + 100*rank;
	rbuf[i] = -i;
      }
      
      /* Create and load the arguments to alltoallv */
      sendcounts = (int *)malloc( size * sizeof(int) );
      recvcounts = (int *)malloc( size * sizeof(int) );
      rdispls    = (int *)malloc( size * sizeof(int) );
      sdispls    = (int *)malloc( size * sizeof(int) );
      sendtypes    = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
      recvtypes    = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
      if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
	fprintf( stderr, "Could not allocate arg items!\n" );
	MPI_Abort( comm, 1 );
      }
      /* Note that process 0 sends no data (sendcounts[0] = 0) */
      for (i=0; i<size; i++) {
	sendcounts[i] = i;
	recvcounts[i] = rank;
	rdispls[i]    = i * rank * sizeof(int);
	sdispls[i]    = (((i+1) * (i))/2) * sizeof(int);
        sendtypes[i] = recvtypes[i] = MPI_INT;
      }
      MPI_Alltoallw( sbuf, sendcounts, sdispls, sendtypes,
		     rbuf, recvcounts, rdispls, recvtypes, comm );
      
      /* Check rbuf */
      for (i=0; i<size; i++) {
	p = rbuf + rdispls[i]/sizeof(int);
	for (j=0; j<rank; j++) {
	  if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
	    fprintf( stderr, "[%d] got %d expected %d for %dth\n",
		     rank, p[j],(i*(i+1))/2 + j, j );
	    err++;
	  }
	}
      }

      free(sendtypes);
      free(sdispls);
      free(sendcounts);
      free(sbuf);

#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
      /* check MPI_IN_PLACE, added in MPI-2.2 */
      free( rbuf );
      rbuf = (int *)malloc( size * (2 * size) * sizeof(int) );
      if (!rbuf) {
        fprintf( stderr, "Could not reallocate rbuf!\n" );
        MPI_Abort( comm, 1 );
      }

      /* Load up the buffers */
      for (i = 0; i < size; i++) {
        /* alltoallw displs are in bytes, not in type extents */
        rdispls[i]    = i * (2 * size) * sizeof(int);
        recvtypes[i]  = MPI_INT;
        recvcounts[i] = i + rank;
      }
      memset(rbuf, -1, size * (2 * size) * sizeof(int));
      for (i=0; i < size; i++) {
        p = rbuf + (rdispls[i] / sizeof(int));
        for (j = 0; j < recvcounts[i]; ++j) {
          p[j] = 100 * rank + 10 * i + j;
        }
      }

      MPI_Alltoallw( MPI_IN_PLACE, NULL, NULL, NULL,
                     rbuf, recvcounts, rdispls, recvtypes, comm );

      /* Check rbuf */
      for (i=0; i<size; i++) {
//.........这里部分代码省略.........
开发者ID:abhinavvishnu,项目名称:matex,代码行数:101,代码来源:alltoallw2.c


示例14: main

int main(int argc, char *argv[])
{
    int errs = 0;
    int rank, size, rsize;
    int np = 3;
    MPI_Comm parentcomm, intercomm;
    int verbose = 0;
    char *env;
    int can_spawn;

    env = getenv("MPITEST_VERBOSE");
    if (env) {
        if (*env != '0')
            verbose = 1;
    }

    MTest_Init(&argc, &argv);

    errs += MTestSpawnPossible(&can_spawn);

    if (can_spawn) {
        MPI_Comm_get_parent(&parentcomm);

        if (parentcomm == MPI_COMM_NULL) {
            IF_VERBOSE(("spawning %d processes\n", np));
            /* Create 3 more processes */
            MPI_Comm_spawn((char *) "./disconnect", MPI_ARGV_NULL, np,
                           MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
        } else {
            intercomm = parentcomm;
        }

        /* We now have a valid intercomm */

        MPI_Comm_remote_size(intercomm, &rsize);
        MPI_Comm_size(intercomm, &size);
        MPI_Comm_rank(intercomm, &rank);

        if (parentcomm == MPI_COMM_NULL) {
            IF_VERBOSE(("parent rank %d alive.\n", rank));
            /* Parent */
            if (rsize != np) {
                errs++;
                printf("Did not create %d processes (got %d)\n", np, rsize);
                fflush(stdout);
            }
            IF_VERBOSE(("disconnecting child communicator\n"));
            MPI_Comm_disconnect(&intercomm);

            /* Errors cannot be sent back to the parent because there is no
             * communicator connected to the children
             * for (i=0; i<rsize; i++)
             * {
             * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
             * errs += err;
             * }
             */
        } else {
            IF_VERBOSE(("child rank %d alive.\n", rank));
            /* Child */
            if (size != np) {
                errs++;
                printf("(Child) Did not create %d processes (got %d)\n", np, size);
                fflush(stdout);
            }

            IF_VERBOSE(("disconnecting communicator\n"));
            MPI_Comm_disconnect(&intercomm);

            /* Send the errs back to the master process */
            /* Errors cannot be sent back to the parent because there is no
             * communicator connected to the parent */
            /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
        }

        /* Note that the MTest_Finalize get errs only over COMM_WORLD */
        /* Note also that both the parent and child will generate "No Errors"
         * if both call MTest_Finalize */
        if (parentcomm == MPI_COMM_NULL) {
            MTest_Finalize(errs);
        } else {
            MPI_Finalize();
        }
    } else {
        MTest_Finalize(errs);
    }

    IF_VERBOSE(("calling finalize\n"));
    return MTestReturnValue(errs);
}
开发者ID:jeffhammond,项目名称:mpich,代码行数:90,代码来源:disconnect.c


示例15: main

/*
 * This test looks at the handling of logical and for types that are not 
 * integers or are not required integers (e.g., long long).  MPICH2 allows
 * these as well.  A strict MPI test should not include this test.
 */
int main( int argc, char *argv[] )
{
    int errs = 0;
    int rank, size, maxsize, result[6] = { 1, 1, 2, 6, 24, 120 };
    MPI_Comm      comm;
    char cinbuf[3], coutbuf[3];
    signed char scinbuf[3], scoutbuf[3];
    unsigned char ucinbuf[3], ucoutbuf[3];
    d_complex dinbuf[3], doutbuf[3];

    MTest_Init( &argc, &argv );

    comm = MPI_COMM_WORLD;

    MPI_Comm_rank( comm, &rank );
    MPI_Comm_size( comm, &size );
    if (size > 5) maxsize = 5;
    else          maxsize = size;

    /* General forumula: If we multiple the values from 1 to n, the 
       product is n!.  This grows very fast, so we'll only use the first 
       five (1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120), with n!
       stored in the array result[n] */

#ifndef USE_STRICT_MPI
    /* char */
    MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
    cinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
    cinbuf[1] = 0;
    cinbuf[2] = (rank > 1);

    coutbuf[0] = 0;
    coutbuf[1] = 1;
    coutbuf[2] = 1;
    MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_PROD, 0, comm );
    if (rank == 0) {
	if (coutbuf[0] != (char)result[maxsize-1]) {
	    errs++;
	    fprintf( stderr, "char PROD(rank) test failed (%d!=%d)\n",
		     (int)coutbuf[0], (int)result[maxsize]);
	}
	if (coutbuf[1]) {
	    errs++;
	    fprintf( stderr, "char PROD(0) test failed\n" );
	}
	if (size > 1 && coutbuf[2]) {
	    errs++;
	    fprintf( stderr, "char PROD(>) test failed\n" );
	}
    }
#endif /* USE_STRICT_MPI */

    /* signed char */
    MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
    scinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
    scinbuf[1] = 0;
    scinbuf[2] = (rank > 1);

    scoutbuf[0] = 0;
    scoutbuf[1] = 1;
    scoutbuf[2] = 1;
    MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_PROD, 0, comm );
    if (rank == 0) {
	if (scoutbuf[0] != (signed char)result[maxsize-1]) {
	    errs++;
	    fprintf( stderr, "signed char PROD(rank) test failed (%d!=%d)\n",
		     (int)scoutbuf[0], (int)result[maxsize]);
	}
	if (scoutbuf[1]) {
	    errs++;
	    fprintf( stderr, "signed char PROD(0) test failed\n" );
	}
	if (size > 1 && scoutbuf[2]) {
	    errs++;
	    fprintf( stderr, "signed char PROD(>) test failed\n" );
	}
    }

    /* unsigned char */
    MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
    ucinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
    ucinbuf[1] = 0;
    ucinbuf[2] = (rank > 0);

    ucoutbuf[0] = 0;
    ucoutbuf[1] = 1;
    ucoutbuf[2] = 1;
    MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_PROD, 0, comm );
    if (rank == 0) {
	if (ucoutbuf[0] != (unsigned char)result[maxsize-1]) {
	    errs++;
	    fprintf( stderr, "unsigned char PROD(rank) test failed\n" );
	}
	if (ucoutbuf[1]) {
	    errs++;
//.........这里部分代码省略.........
开发者ID:jimmycao,项目名称:mpi-test,代码行数:101,代码来源:opprod.c


示例16: main

/*
   This program is derived from one in the MPICH-1 test suite

   This version sends and receives EVERYTHING from MPI_BOTTOM, by putting
   the data into a structure.
 */
int main( int argc, char **argv )
{
    MPI_Datatype *types;
    void         **inbufs, **outbufs;
    int          *counts, *bytesize, ntype;
    MPI_Comm     comm;
    int          ncomm = 20, rank, np, partner, tag, count;
    int          j, k, err, toterr, world_rank, errloc;
    MPI_Status   status;
    char         *obuf;
    MPI_Datatype offsettype;
    int          blen;
    MPI_Aint     displ, extent, natural_extent;
    char         myname[MPI_MAX_OBJECT_NAME];
    int          mynamelen;

    MTest_Init( &argc, &argv );

    MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
			    &ntype );
    MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );

    MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );

    /* Test over a wide range of datatypes and communicators */
    err = 0;
    tag = 0;
    while (MTestGetIntracomm( &comm, 2 )) {
	if (comm == MPI_COMM_NULL) continue;
	MPI_Comm_rank( comm, &rank );
	MPI_Comm_size( comm, &np );
	if (np < 2) continue;
	tag++;
	for (j=0; j<ntype; j++) {
	    MPI_Type_get_name( types[j], myname, &mynamelen );
	    if (world_rank == 0)
		MTestPrintfMsg( 10, "Testing type %s\n", myname );
	    if (rank == 0) {
		MPI_Get_address( inbufs[j], &displ );
		blen = 1;
		MPI_Type_create_struct( 1, &blen, &displ, types + j,
					&offsettype );
		MPI_Type_commit( &offsettype );
		/* Warning: if the type has an explicit MPI_UB, then using a
		   simple shift of the offset won't work.  For now, we skip
		   types whose extents are negative; the correct solution is
		   to add, where required, an explicit MPI_UB */
		MPI_Type_extent( offsettype, &extent );
		if (extent < 0) {
		    if (world_rank == 0)
			MTestPrintfMsg( 10,
			"... skipping (appears to have explicit MPI_UB\n" );
		    MPI_Type_free( &offsettype );
		    continue;
		}
		MPI_Type_extent( types[j], &natural_extent );
		if (natural_extent != extent) {
		    MPI_Type_free( &offsettype );
		    continue;
		}
		partner = np - 1;
		MPI_Send( MPI_BOTTOM, counts[j], offsettype, partner, tag,
			  comm );
		MPI_Type_free( &offsettype );
            }
	    else if (rank == np-1) {
		partner = 0;
		obuf = outbufs[j];
		for (k=0; k<bytesize[j]; k++)
		    obuf[k] = 0;
		MPI_Get_address( outbufs[j], &displ );
		blen = 1;
		MPI_Type_create_struct( 1, &blen, &displ, types + j,
					&offsettype );
		MPI_Type_commit( &offsettype );
		/* Warning: if the type has an explicit MPI_UB, then using a
		   simple shift of the offset won't work.  For now, we skip
		   types whose extents are negative; the correct solution is
		   to add, where required, an explicit MPI_UB */
		MPI_Type_extent( offsettype, &extent );
		if (extent < 0) {
		    MPI_Type_free( &offsettype );
		    continue;
		}
		MPI_Type_extent( types[j], &natural_extent );
		if (natural_extent != extent) {
		    MPI_Type_free( &offsettype );
		    continue;
		}
		MPI_Recv( MPI_BOTTOM, counts[j], offsettype,
			  partner, tag, comm, &status );
		/* Test for correctness */
		MPI_Get_count( &status, types[j], &count );
		if (count != counts[j]) {
//.........这里部分代码省略.........
开发者ID:adevress,项目名称:MPICH-BlueGene,代码行数:101,代码来源:sendrecvt4.c


示例17: main

int main(int argc, char **argv)
{
    int *buf, i, rank, nints, len;
    char *filename, *tmp;
    int errs=0;
    MPI_File fh;
    MPI_Status statuses[NUMOPS];
    MPI_Request requests[NUMOPS];

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

    /* process 0 takes the file name as a command-line argument and
       broadcasts it to other processes */
    if (!rank) {
        i = 1;
        while ((i < argc) && strcmp("-fname", *argv)) {
            i++;
            argv++;
        }
        if (i >= argc) {
            /* Use a default filename of testfile */
            len      = 8;
            filename = (char *)malloc(len + 10);
            strcpy( filename, "testfile" );
            /*
            fprintf(stderr, "\n*#  Usage: async_any -fname filename\n\n");
            MPI_Abort(MPI_COMM_WORLD, 1);
            */
        }
        else {
            argv++;
            len = (int)strlen(*argv);
            filename = (char *) malloc(len+10);
            strcpy(filename, *argv);
        }
        MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
    }
    else {
        MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
        filename = (char *) malloc(len+10);
        MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
    }


    buf = (int *) malloc(SIZE);
    nints = SIZE/sizeof(int);
    for (i=0; i<nints; i++) buf[i] = rank*100000 + i;

    /* each process opens a separate file called filename.'myrank' */
    tmp = (char *) malloc(len+10);
    strcpy(tmp, filename);
    sprintf(filename, "%s.%d", tmp, rank);

    MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
                  MPI_INFO_NULL, &fh);
    MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
    for (i=0; i < NUMOPS; i++) {
        MPI_File_iwrite(fh, buf, nints, MPI_INT, &(requests[i]));
    }
    MPI_Waitall(NUMOPS, requests, statuses);
    MPI_File_close(&fh);

    /* reopen the file and read the data back */

    for (i=0; i<nints; i++) buf[i] = 0;
    MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
                  MPI_INFO_NULL, &fh);
    MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
    for (i=0; i < NUMOPS; i++) {
        MPI_File_iread(fh, buf, nints, MPI_INT, &(requests[i]));
    }
    MPI_Waitall(NUMOPS, requests, statuses);
    MPI_File_close(&fh);

    /* check if the data read is correct */
    for (i=0; i<nints; i++) {
        if (buf[i] != (rank*100000 + i)) {
            errs++;
            fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i], rank*100000+i);
        }
    }

    free(buf);
    free(filename);
    free(tmp);

    MTest_Finalize(errs);
    MPI_Finalize();
    return 0;
}
开发者ID:kleiter,项目名称:mpich,代码行数:92,代码来源:async_any.c


示例18: main

/*
 * This test looks at the handling of char and types that  are not required
 * integers (e.g., long long).  MPICH allows
 * these as well.  A strict MPI test should not include this test.
 */
int main(int argc, char *argv[])
{
    int errs = 0;
    int rank, size;
    MPI_Comm comm;
    char cinbuf[3], coutbuf[3];
    signed char scinbuf[3], scoutbuf[3];
    unsigned char ucinbuf[3], ucoutbuf[3];

    MTest_Init(&argc, &argv);

    comm = MPI_COMM_WORLD;

    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

#ifndef USE_STRICT_MPI
    /* char */
    MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
    cinbuf[0] = 1;
    cinbuf[1] = 0;
    cinbuf[2] = rank;

    coutbuf[0] = 0;
    coutbuf[1] = 1;
    coutbuf[2] = 1;
    MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm);
    if (rank == 0) {
        if (coutbuf[0] != 1) {
            errs++;
            fprintf(stderr, "char MAX(1) test failed\n");
        }
        if (coutbuf[1] != 0) {
            errs++;
            fprintf(stderr, "char MAX(0) test failed\n");
        }
        if (size < 128 && coutbuf[2] != size - 1) {
            errs++;
            fprintf(stderr, "char MAX(>) test failed\n");
        }
    }
#endif /* USE_STRICT_MPI */

    /* signed char */
    MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
    scinbuf[0] = 1;
    scinbuf[1] = 0;
    scinbuf[2] = rank;

    scoutbuf[0] = 0;
    scoutbuf[1] = 1;
    scoutbuf[2] = 1;
    MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm);
    if (rank == 0) {
        if (scoutbuf[0] != 1) {
            errs++;
            fprintf(stderr, "signed char MAX(1) test failed\n");
        }
        if (scoutbuf[1] != 0) {
            errs++;
            fprintf(stderr, "signed char MAX(0) test failed\n");
        }
        if (size < 128 && scoutbuf[2] != size - 1) {
            errs++;
            fprintf(stderr, "signed char MAX(>) test failed\n");
        }
    }

    /* unsigned char */
    MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
    ucinbuf[0] = 1;
    ucinbuf[1] = 0;
    ucinbuf[2] = rank;

    ucoutbuf[0] = 0;
    ucoutbuf[1] = 1;
    ucoutbuf[2] = 1;
    MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm);
    if (rank == 0) {
        if (ucoutbuf[0] != 1) {
            errs++;
            fprintf(stderr, "unsigned char MAX(1) test failed\n");
        }
        if (ucoutbuf[1]) {
            errs++;
            fprintf(stderr, "unsigned char MAX(0) test failed\n");
        }
        if (size < 256 && ucoutbuf[2] != size - 1) {
            errs++;
            fprintf(stderr, "unsigned char MAX(>) test failed\n");
        }
    }

#ifdef HAVE_LONG_DOUBLE
    {
//.........这里部分代码省略.........
开发者ID:Niharikareddy,项目名称:mpich,代码行数:101,代码来源:opmax.c


示例19: main

int main(int argc, char *argv[]) 
{ 
    int rank, nprocs, A[NROWS][NCOLS], i, j, blocklen[2];
    MPI_Aint disp[2];
    MPI_Win win;
    MPI_Datatype column, column1, type[2];
    int errs=0;
 
    MTest_Init(&argc,&argv); 
    MPI_Comm_size(MPI_COMM_WORLD,&nprocs); 
    MPI_Comm_rank(MPI_COMM_WORLD,&rank); 

    if (nprocs != 2)
    {
        printf("Run this program with 2 processes\n");
        MPI_Abort(MPI_COMM_WORLD,1);
    }

    if (rank == 0)
    {
        for (i=0; i<NROWS; i++)
            for (j=0; j<NCOLS; j++)
                A[i][j] = i*NCOLS + j;

        /* create datatype for one column */
        MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
 
        /* create datatype for one column, with the extent of one
           integer. we could use type_create_resized instead. */
        disp[0] = 0;
        disp[1] = sizeof(int);
        type[0]  = column;
        type[1]  = MPI_UB;
        blocklen[0]  = 1;
        blocklen[1]  = 1; 
        MPI_Type_struct(2, blocklen, disp, type, &column1);
        MPI_Type_commit(&column1);
 
        MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win); 

        MPI_Win_fence(0, win); 

        MPI_Put(A, NROWS*NCOLS, MPI_INT, 1, 0, NCOLS, column1, win);

        MPI_Type_free(&column);
        MPI_Type_free(&column1);

        MPI_Win_fence(0, win); 
    }        
    else
    { /* rank = 1 */
        for (i=0; i<NROWS; i++) 
            for (j=0; j<NCOLS; j++)
                A[i][j] = -1;
        MPI_Win_create(A, NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, 
                       MPI_COMM_WORLD, &win); 
        MPI_Win_fence(0, win); 

        MPI_Win_fence(0, win); 

        for (j=0; j<NCOLS; j++)
	{
            for (i=0; i<NROWS; i++)
	    {
                if (A[j][i] != i*NCOLS + j)
		{
		    if (errs < 50)
		    {
			printf("Error: A[%d][%d]=%d should be %d\n", j, i,
			    A[j][i], i*NCOLS + j);
		    }
                    errs++;
                }
	    }
	}
	if (errs >= 50)
	{
	    printf("Total number of errors: %d\n", errs);
	}
    }

    MPI_Win_free(&win); 
    MTest_Finalize(errs);
    MPI_Finalize(); 
    return 0; 
} 
开发者ID:OngOngoing,项目名称:219351_homework,代码行数:86,代码来源:transpose2.c


示例20: main

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_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,
	 then delete, then confirm delete 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 );
	
	MPI_Comm_set_attr( comm, key[1], &attrval[1] );
	MPI_Comm_set_attr( comm, key[2], &attrval[2] );
	MPI_Comm_set_attr( comm, key[0], &attrval[0] );

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

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

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

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

	errs += checkNoAttrs( comm, 3, key );
	
	for (i=0; i<3; i++) {
	    MPI_Comm_free_keyval( &key[i] );
	}
    }
    
    MTest_Finalize( errs );
    MPI_Finalize();
    return 0;
  
}
开发者ID:OngOngoing,项目名称:219351_homework,代码行数:67,代码来源:attrordercomm.c



注:本文中的MTest_Init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MUL函数代码示例发布时间:2022-05-30
下一篇:
C++ MTest_Finalize函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap