当前位置: 首页>>代码示例>>C++>>正文


C++ MTest_Init函数代码示例

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


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


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