int main(int argc, char *argv[]) { int ierr, i, size, rank; int cnt = 270000000; int stat_cnt = 0; MPI_Status status; long long *cols; int errs = 0; MTest_Init(&argc, &argv); /* need large memory */ if (sizeof(void *) < 8) { MTest_Finalize(errs); return MTestReturnValue(errs); } ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (size != 3) { fprintf(stderr, "[%d] usage: mpiexec -n 3 %s\n", rank, argv[0]); MPI_Abort(MPI_COMM_WORLD, 1); } cols = malloc(cnt * sizeof(long long)); if (cols == NULL) { printf("malloc of >2GB array failed\n"); errs++; MTest_Finalize(errs); return MTestReturnValue(errs); } if (rank == 0) { for (i = 0; i < cnt; i++) cols[i] = i; /* printf("[%d] sending...\n",rank); */ ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 1, 0, MPI_COMM_WORLD); ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 2, 0, MPI_COMM_WORLD); } else { /* printf("[%d] receiving...\n",rank); */ for (i = 0; i < cnt; i++) cols[i] = -1; ierr = MPI_Recv(cols, cnt, MPI_LONG_LONG_INT, 0, 0, MPI_COMM_WORLD, &status); ierr = MPI_Get_count(&status, MPI_LONG_LONG_INT, &stat_cnt); if (cnt != stat_cnt) { fprintf(stderr, "Output of MPI_Get_count (%d) does not match expected count (%d).\n", stat_cnt, cnt); errs++; } for (i = 0; i < cnt; i++) { if (cols[i] != i) { /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i); */ errs++; } } } MTest_Finalize(errs); return MTestReturnValue(errs); }
int main(int argc, char *argv[]) { int rank, size; int i, j; long *sendbuf = NULL; long *recvbuf = NULL; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); sendbuf = malloc(COUNT * sizeof(long)); if (sendbuf == NULL) { fprintf(stderr, "PE %d:ERROR: malloc of sendbuf failed\n", rank); } for (i = 0; i < COUNT; i++) { sendbuf[i] = (long) i + (long) rank *VERIFY_CONST; } if (rank == ROOT) { recvbuf = malloc(COUNT * sizeof(long) * size); if (recvbuf == NULL) { fprintf(stderr, "PE %d:ERROR: malloc of recvbuf failed\n", rank); } for (i = 0; i < COUNT * size; i++) { recvbuf[i] = -456789L; } } MPI_Gather(sendbuf, COUNT, MPI_LONG, recvbuf, COUNT, MPI_LONG, ROOT, MPI_COMM_WORLD); int lerr = 0; if (rank == ROOT) { for (i = 0; i < size; i++) { for (j = 0; j < COUNT; j++) { if (recvbuf[i * COUNT + j] != i * VERIFY_CONST + j) { printf("PE 0: mis-match error"); printf(" recbuf[%d * %d + %d] = ", i, COUNT, j); printf(" %ld,", recvbuf[i * COUNT + j]); printf(" should be %ld\n", i * VERIFY_CONST + j); lerr++; if (lerr > 10) { j = COUNT; } } } } MTest_Finalize(lerr); free(recvbuf); } else { MTest_Finalize(lerr); } MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); free(sendbuf); return 0; }
int main(int argc, char *argv[]) { MPI_Info i1, i2; int errs = 0; char value[64]; int flag; MTest_Init(&argc, &argv); MPI_Info_create(&i1); MPI_Info_create(&i2); MPI_Info_set(i1, (char *) "key1", (char *) "value1"); MPI_Info_set(i2, (char *) "key2", (char *) "value2"); MPI_Info_get(i1, (char *) "key2", 64, value, &flag); if (flag) { printf("Found key2 in info1\n"); errs++; } MPI_Info_get(i1, (char *) "key1", 64, value, &flag); if (!flag) { errs++; printf("Did not find key1 in info1\n"); } else if (strcmp(value, "value1")) { errs++; printf("Found wrong value (%s), expected value1\n", value); } MPI_Info_free(&i1); MPI_Info_free(&i2); MTest_Finalize(errs); return MTestReturnValue(errs); }
int main(int argc, char **argv) { int rank, nproc; int out_val, i, counter = 0; MPI_Win win; MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nproc); MPI_Win_create(&counter, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win); for (i = 0; i < NITER; i++) { MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win); MPI_Get_accumulate(&acc_val, 1, MPI_INT, &out_val, 1, MPI_INT, rank, 0, 1, MPI_INT, MPI_SUM, win); MPI_Win_unlock(rank, win); if (out_val != acc_val * i) { errs++; printf("Error: got %d, expected %d at iter %d\n", out_val, acc_val * i, i); break; } } MPI_Win_free(&win); MTest_Finalize(errs); return MTestReturnValue(errs); }
int main( int argc, char **argv ) { int rank, size, i; int data; int errors=0; int result = -100; int correct_result; 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 *)addem, 1, &op ); MPI_Reduce ( &data, &result, 1, MPI_INT, op, 0, MPI_COMM_WORLD ); MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Op_free( &op ); correct_result = 0; for(i=0;i<size;i++) correct_result += i; if (result != correct_result) errors++; MTest_Finalize( errors ); MPI_Finalize(); return MTestReturnValue( errors ); }
int main(int argc, char *argv[]) { int errs = 0, err; int j, count; char *ap; MTest_Init(&argc, &argv); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); for (count = 1; count < 128000; count *= 2) { err = MPI_Alloc_mem(count, MPI_INFO_NULL, &ap); if (err) { int errclass; /* An error of MPI_ERR_NO_MEM is allowed */ MPI_Error_class(err, &errclass); if (errclass != MPI_ERR_NO_MEM) { errs++; MTestPrintError(err); } } else { /* Access all of this memory */ for (j = 0; j < count; j++) { ap[j] = (char) (j & 0x7f); } MPI_Free_mem(ap); } } MTest_Finalize(errs); return MTestReturnValue(errs); }
int main(int argc, char *argv[]) { int rank, nprocs, A[SIZE2], B[SIZE2], i; 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 processes\n"); MPI_Abort(MPI_COMM_WORLD,1); } if (rank == 0) { for (i=0; i<SIZE2; i++) A[i] = B[i] = i; MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win); for (i=0; i<SIZE1; i++) { MPI_Win_lock(MPI_LOCK_SHARED, 1, 0, win); MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win); MPI_Win_unlock(1, win); } for (i=0; i<SIZE1; i++) { MPI_Win_lock(MPI_LOCK_SHARED, 1, 0, win); MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win); MPI_Win_unlock(1, win); } MPI_Win_free(&win); for (i=0; i<SIZE1; i++) if (B[i] != (-4)*(i+SIZE1)) { printf("Get Error: B[%d] is %d, should be %d\n", i, B[i], (-4)*(i+SIZE1)); errs++; } } else { /* rank=1 */ for (i=0; i<SIZE2; i++) B[i] = (-4)*i; MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win); MPI_Win_free(&win); for (i=0; i<SIZE1; i++) { if (B[i] != i) { printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i); errs++; } } } /* if (rank==0) printf("Done\n");*/ MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main( int argc, char *argv[] ) { int buf[2]; MPI_Win win; MPI_Errhandler newerr; int i; MTest_Init( &argc, &argv ); /* Run this test multiple times to expose storage leaks (we found a leak of error handlers with this test) */ for (i=0;i<1000; i++) { calls = 0; MPI_Win_create( buf, 2*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win ); mywin = win; MPI_Win_create_errhandler( eh, &newerr ); MPI_Win_set_errhandler( win, newerr ); MPI_Win_call_errhandler( win, MPI_ERR_OTHER ); MPI_Errhandler_free( &newerr ); if (calls != 1) { errs++; printf( "Error handler not called\n" ); } MPI_Win_free( &win ); } MTest_Finalize( errs ); MPI_Finalize(); return 0; }
int main(int argc, char **argv) { MPI_Group basegroup; MPI_Group g1; MPI_Comm comm, newcomm; int rank, size; int worldrank; int errs = 0, errclass, mpi_errno; 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_intersection for NULL variable */ mpi_errno = MPI_Group_intersection(basegroup, g1, 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); return 0; }
int main(int argc, char **argv) { int err, errs = 0; MTest_Init(&argc, &argv); parse_args(argc, argv); /* To improve reporting of problems about operations, we * change the error handler to errors return */ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); /* perform some tests */ err = darray_2d_c_test1(); if (err && verbose) fprintf(stderr, "%d errors in 2d darray c test 1.\n", err); errs += err; err = darray_4d_c_test1(); if (err && verbose) fprintf(stderr, "%d errors in 4d darray c test 1.\n", err); errs += err; /* print message and exit */ /* Allow the use of more than one process - some MPI implementations * (including IBM's) check that the number of processes given to * Type_create_darray is no larger than MPI_COMM_WORLD */ MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int errs = 0, err; int dims[2]; int periods[2]; int size, rank; MPI_Comm comm; MTest_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); dims[0] = size; dims[1] = size; periods[0] = 0; periods[1] = 0; MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); err = MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm); if (err == MPI_SUCCESS) { errs++; printf("Cart_create returned success when dims > size\n"); } else if (comm != MPI_COMM_NULL) { errs++; printf("Expected a null comm from cart create\n"); } MTest_Finalize(errs); return MTestReturnValue(errs); }
int main( int argc, char **argv ) { int rank, size, i; int data; int errors=0; int result = -100; int correct_result; MTest_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); data = rank; MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD ); MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); correct_result = 0; for(i=0;i<size;i++) correct_result += i; if (result != correct_result) errors++; MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD ); MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); if (result != 0) errors++; MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD ); MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); if (result != (size-1)) errors++; MTest_Finalize( errors ); MPI_Finalize(); return MTestReturnValue( errors ); }
int main(int argc, char *argv[]) { MPI_Win win; int flag, tmp, rank; int base[1024], errs = 0; MPI_Request req; MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Win_create(base, 1024 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win); if (rank == 0) { MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win); MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); MPI_Win_unlock(0, win); } else { MPI_Barrier(MPI_COMM_WORLD); MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win); MPI_Rput(&tmp, 1, MPI_INT, 0, 0, 1, MPI_INT, win, &req); MPI_Test(&req, &flag, MPI_STATUS_IGNORE); MPI_Barrier(MPI_COMM_WORLD); MPI_Win_unlock(0, win); } MPI_Win_free(&win); MTest_Finalize(errs); return MTestReturnValue(errs); }
int main(int argc, char *argv[]) { int wrank, wsize, rank, size, color; int tmp; MPI_Comm newcomm; MTest_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &wsize); MPI_Comm_rank(MPI_COMM_WORLD, &wrank); /* Color is 0 or 1; 1 will be the processes that "fault" */ color = (wrank > 0) && (wrank <= wsize / 2); MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm); MPI_Barrier(MPI_COMM_WORLD); if (color) { /* Simulate a fault on some processes */ exit(1); } /* Can we still use newcomm? */ MPI_Comm_size(newcomm, &size); MPI_Comm_rank(newcomm, &rank); MPI_Allreduce(&rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm); if (tmp != (size * (size + 1)) / 2) { printf("Allreduce gave %d but expected %d\n", tmp, (size * (size + 1)) / 2); } MPI_Comm_free(&newcomm); MTest_Finalize(0); return 0; }
int main(int argc, char *argv[]) { int errs = 0; MPI_Win win; int cnt, namelen; char name[MPI_MAX_OBJECT_NAME], nameout[MPI_MAX_OBJECT_NAME]; MTest_Init(&argc, &argv); cnt = 0; while (MTestGetWin(&win, 1)) { if (win == MPI_WIN_NULL) continue; sprintf(name, "win-%d", cnt); cnt++; MPI_Win_set_name(win, name); nameout[0] = 0; MPI_Win_get_name(win, nameout, &namelen); if (strcmp(name, nameout)) { errs++; printf("Unexpected name, was %s but should be %s\n", nameout, name); } MTestFreeWin(&win); } MTest_Finalize(errs); return MTestReturnValue(errs); }
int main(int argc, char* argv[]) { MPI_Comm comm, newcomm, scomm; MPI_Group group; MPI_Info newinfo; int rank, size, color; int errs = 0, errclass, mpi_errno; MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_dup(MPI_COMM_WORLD, &comm); MPI_Comm_group(comm, &group); MPI_Comm_create(comm, group, &newcomm); color = rank % 2; MPI_Comm_split(MPI_COMM_WORLD, color, rank, &scomm); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); /*test comm_split_type for NULL variable */ mpi_errno = MPI_Comm_split_type(scomm, 2, 4, newinfo, NULL); MPI_Error_class(mpi_errno, &errclass); if (errclass != MPI_ERR_ARG) ++errs; MPI_Comm_free(&comm); MPI_Comm_free(&newcomm); MPI_Comm_free(&scomm); MPI_Group_free(&group); MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main( int argc, char *argv[] ) { int errs = 0; int topo_type, size, dims[1], periods[1]; MPI_Comm comm; MTest_Init( &argc, &argv ); /* Check that topo test returns the correct type, including MPI_UNDEFINED */ MPI_Topo_test( MPI_COMM_WORLD, &topo_type ); if (topo_type != MPI_UNDEFINED) { errs++; printf( "Topo type of comm world is not UNDEFINED\n" ); } MPI_Comm_size( MPI_COMM_WORLD, &size ); dims[0] = size; periods[0] = 0; MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); MPI_Topo_test( comm, &topo_type ); if (topo_type != MPI_CART) { errs++; printf( "Topo type of cart comm is not CART\n" ); } MPI_Comm_free( &comm ); /* FIXME: still need graph example */ MTest_Finalize( errs ); MPI_Finalize(); return 0; }
int main(int argc, char **argv) { int thread_args[NUM_THREADS]; int i, provided; int errs = 0; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); check(provided == MPI_THREAD_MULTIPLE); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); for (i = 0; i < NUM_THREADS; i++) { MPI_Comm_dup(MPI_COMM_WORLD, &comms[i]); } for (i = 0; i < NUM_THREADS; i++) { thread_args[i] = i; MTest_Start_thread(test_iallred, (void *) &thread_args[i]); } errs = MTest_Join_threads(); for (i = 0; i < NUM_THREADS; i++) { MPI_Comm_free(&comms[i]); } MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int nprocs, i, pmode; char *win_buf; MTest_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode); if (pmode != MPI_THREAD_MULTIPLE) { fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n"); MPI_Abort(MPI_COMM_WORLD, -1); } MPI_Comm_size(MPI_COMM_WORLD, &nprocs); if (nprocs < 2) { printf("Run this program with 2 or more processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); } errs += MPI_Win_allocate(COUNT * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win_buf, &win); errs += MPI_Win_lock_all(0, win); for (i = 0; i < NUM_THREADS; i++) errs += MTest_Start_thread(run_test, NULL); errs += MTest_Join_threads(); errs += MPI_Win_unlock_all(win); errs += MPI_Win_free(&win); MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main( int argc, char *argv[] ) { int rank, size; int provided; char buffer[100]; MPI_Status status; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); if (provided != MPI_THREAD_MULTIPLE) { if (rank == 0) { printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n"); fflush(stdout); } MPI_Finalize(); return -1; } MTest_Start_thread(send_thread, NULL); MPI_Probe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&status); MPI_Recv(buffer, sizeof(buffer), MPI_CHAR, rank, 0, MPI_COMM_WORLD, &status); MTest_Join_threads(); MTest_Finalize(0); MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int errs = 0, errclass, mpi_errno; int rank, size; MPI_Comm comm; MPI_Group group; MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_dup(MPI_COMM_WORLD, &comm); MPI_Comm_group(comm, &group); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); /*test comm_create for NULL variable */ mpi_errno = MPI_Comm_create(comm, group, NULL); MPI_Error_class(mpi_errno, &errclass); if (errclass != MPI_ERR_ARG) ++errs; MPI_Comm_free(&comm); MPI_Group_free(&group); MTest_Finalize(errs); return 0; }
int main(int argc, char **argv) { MPI_Datatype vec; MPI_Comm comm; double *vecin, *vecout; int minsize = 2, count; int root, i, n, stride, errs = 0; int rank, size; MTest_Init(&argc, &argv); while (MTestGetIntracommGeneral(&comm, minsize, 1)) { if (comm == MPI_COMM_NULL) continue; /* Determine the sender and receiver */ MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); for (root = 0; root < size; root++) { for (count = 1; count < 65000; count = count * 2) { n = 12; stride = 10; vecin = (double *) malloc(n * stride * size * sizeof(double)); vecout = (double *) malloc(size * n * sizeof(double)); MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec); MPI_Type_commit(&vec); for (i = 0; i < n * stride; i++) vecin[i] = -2; for (i = 0; i < n; i++) vecin[i * stride] = rank * n + i; MPI_Gather(vecin, 1, vec, vecout, n, MPI_DOUBLE, root, comm); if (rank == root) { for (i = 0; i < n * size; i++) { if (vecout[i] != i) { errs++; if (errs < 10) { fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]); } } } } MPI_Type_free(&vec); free(vecin); free(vecout); } } MTestFreeComm(&comm); } /* do a zero length gather */ MPI_Gather(NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD); MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main(int argc, char **argv) { int err, errs = 0; MTest_Init(&argc, &argv); parse_args(argc, argv); /* To improve reporting of problems about operations, we * change the error handler to errors return */ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); /* perform some tests */ err = blockindexed_contig_test(); if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n", err); errs += err; err = blockindexed_vector_test(); if (err && verbose) fprintf(stderr, "%d errors in blockindexed vector test.\n", err); errs += err; MTest_Finalize(errs); return MTestReturnValue(errs); }
int main( int argc, char *argv[] ) { int errs = 0; int rc; int ranks[2]; MPI_Group ng; char str[MPI_MAX_ERROR_STRING+1]; int slen; MTest_Init( &argc, &argv ); /* Set errors return */ MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN ); /* Create some valid input data except for the group handle */ ranks[0] = 0; rc = MPI_Group_incl( MPI_COMM_WORLD, 1, ranks, &ng ); if (rc == MPI_SUCCESS) { errs ++; printf( "Did not detect invalid handle (comm) in group_incl\n" ); } else { if (verbose) { MPI_Error_string( rc, str, &slen ); printf( "Found expected error; message is: %s\n", str ); } } MTest_Finalize( errs ); MPI_Finalize( ); return 0; }
int main(int argc, char *argv[]) { int i, k, wrank, errs = 0; int dims[MAX_DIMS]; MTest_Init(0, 0); MPI_Comm_rank(MPI_COMM_WORLD, &wrank); if (wrank == 0) { for (k=0; tests[k].size > 0; k++) { zeroDims(tests[k].dim, dims); MPI_Dims_create(tests[k].size, tests[k].dim, dims); if (checkDims(&tests[k], dims)) { errs++; MTestPrintfMsg(1, "Test %d failed with mismatched output", k); if (errs < 10) { fprintf(stderr, "%d in %dd: ", tests[k].size, tests[k].dim); for (i=0; i<tests[k].dim-1; i++) fprintf(stderr, "%d x ", dims[i]); fprintf(stderr, "%d != %d", dims[tests[k].dim-1], tests[k].orderedDecomp[0]); for (i=1; i<tests[k].dim; i++) fprintf(stderr," x %d", tests[k].orderedDecomp[i]); fprintf(stderr,"\n"); } } } } MTest_Finalize(errs); MPI_Finalize(); return MTestReturnValue(errs); }
int main(int argc, char *argv[]) { int size, rank; int dest; int i; char *buff; MPI_Request reqs[N_TRY]; MTest_Init(&argc, &argv); buff = malloc(N_TRY * BLKSIZE); memset(buff, -1, N_TRY * BLKSIZE); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); dest = size - 1; if (rank == 0) { for (i = 0; i < N_TRY; i++) MPI_Isend(buff + BLKSIZE * i, BLKSIZE, MPI_BYTE, dest, 0, MPI_COMM_WORLD, &reqs[i]); MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE); } else if (rank == dest) { for (i = 0; i < N_TRY; i++) MPI_Irecv(buff + BLKSIZE * i, BLKSIZE, MPI_BYTE, 0, 0, MPI_COMM_WORLD, &reqs[i]); MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE); } free(buff); MTest_Finalize(0); return 0; }
int main(int argc, char *argv[]) { int rank, size; int provided; int buffer[1]; MPI_Comm comm1, comm2, comm4; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); /* Check that we're multi-threaded */ if (provided != MPI_THREAD_MULTIPLE) { if (rank == 0) { printf ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n"); fflush(stdout); } MPI_Finalize(); return 1; } /* The test is this: * The main thread on ODD processors tells the other thread to start * a comm dup(on comm2), then starts a comm dup(on comm1) after a delay. * The main thread on even processors starts a comm dup(on comm1) * * The second thread on ODD processors waits until it gets a message * (from the same process) before starting the comm dup on comm2. */ /* Create two communicators */ MPI_Comm_dup(MPI_COMM_WORLD, &comm1); MPI_Comm_dup(MPI_COMM_WORLD, &comm2); /* Start a thread that will perform a dup comm2 */ MTest_Start_thread(dup_thread, (void *) &comm2); /* If we're odd, send to our new thread and then delay */ if (rank & 0x1) { MPI_Ssend(buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD); MTestSleep(1); } MPI_Comm_dup(comm1, &comm4); /* Tell the threads to exit after we've created our new comm */ MPI_Barrier(comm4); MPI_Ssend(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD); MPI_Recv(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); MPI_Comm_free(&comm4); MPI_Comm_free(&comm1); MPI_Comm_free(&comm2); MTest_Finalize(0); MPI_Finalize(); return 0; }
int main( int argc, char **argv ) { int *sendbuf; int block_size; int *recvbuf; int size, rank, i; MPI_Comm comm; MPI_Op left_op, right_op, nc_sum_op; MTest_Init( &argc, &argv ); comm = MPI_COMM_WORLD; MPI_Comm_size( comm, &size ); MPI_Comm_rank( comm, &rank ); #if MTEST_HAVE_MIN_MPI_VERSION(2,2) /* MPI_Reduce_scatter block was added in MPI-2.2 */ MPI_Op_create(&left, 0/*non-commutative*/, &left_op); MPI_Op_create(&right, 0/*non-commutative*/, &right_op); MPI_Op_create(&nc_sum, 0/*non-commutative*/, &nc_sum_op); for (block_size = 1; block_size < MAX_BLOCK_SIZE; block_size *= 2) { sendbuf = (int *) malloc( block_size * size * sizeof(int) ); recvbuf = malloc( block_size * sizeof(int) ); for (i=0; i<(size*block_size); i++) sendbuf[i] = rank + i; for (i=0; i<block_size; i++) recvbuf[i] = 0xdeadbeef; MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, left_op, comm ); for (i = 0; i < block_size; ++i) if (recvbuf[i] != (rank * block_size + i)) ++err; MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, right_op, comm ); for (i = 0; i < block_size; ++i) if (recvbuf[i] != ((size - 1) + (rank * block_size) + i)) ++err; MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, nc_sum_op, comm ); for (i = 0; i < block_size; ++i) { int x = rank * block_size + i; if (recvbuf[i] != (size*x + (size-1)*size/2)) ++err; } free(recvbuf); free(sendbuf); } MPI_Op_free(&left_op); MPI_Op_free(&right_op); MPI_Op_free(&nc_sum_op); #endif MTest_Finalize( err ); MPI_Finalize( ); return err; }
int main( int argc, char *argv[] ) { int size; int minsize = 2, count; MPI_Comm comm; int *buf, *bufout; MPI_Op op; MPI_Datatype mattype; MTest_Init( &argc, &argv ); MPI_Op_create( uop, 0, &op ); while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { if (comm == MPI_COMM_NULL) { continue; } MPI_Comm_size( comm, &size ); matSize = size; /* Only one matrix for now */ count = 1; /* A single matrix, the size of the communicator */ MPI_Type_contiguous( size*size, MPI_INT, &mattype ); MPI_Type_commit( &mattype ); max_offset = count * size * size; buf = (int *)malloc( max_offset * sizeof(int) ); if (!buf) { MPI_Abort( MPI_COMM_WORLD, 1 ); } bufout = (int *)malloc( max_offset * sizeof(int) ); if (!bufout) { MPI_Abort( MPI_COMM_WORLD, 1 ); } initMat( comm, buf ); MPI_Allreduce( buf, bufout, count, mattype, op, comm ); errs += isIdentity( comm, bufout ); /* Try the same test, but using MPI_IN_PLACE */ initMat( comm, bufout ); MPI_Allreduce( MPI_IN_PLACE, bufout, count, mattype, op, comm ); errs += isIdentity( comm, bufout ); free( buf ); free( bufout ); //MPI_Type_free( &mattype ); MTestFreeComm( &comm ); } // MPI_Op_free( &op ); MTest_Finalize( errs ); MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int provided; MPI_Request request; int flag; int outcount = -1; int indices[1] = { -1 }; MPI_Status status; char *env; env = getenv("MPITEST_VERBOSE"); if (env) { if (*env != '0') verbose = 1; } MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); if (provided != MPI_THREAD_MULTIPLE) { printf("This test requires MPI_THREAD_MULTIPLE\n"); MPI_Abort(MPI_COMM_WORLD, 1); } IF_VERBOSE(("Post Init ...\n")); MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request); grequest = request; /* copy the handle */ MTest_Start_thread(do_work, &grequest); IF_VERBOSE(("Testing ...\n")); flag = 0; while (!flag) { MPI_Test(&request, &flag, &status); } MTest_Join_threads(); MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request); grequest = request; /* copy the handle */ MTest_Start_thread(do_work, &grequest); IF_VERBOSE(("Testing ...\n")); outcount = 0; while (!outcount) { MPI_Testsome(1, &request, &outcount, indices, &status); } MTest_Join_threads(); MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request); grequest = request; /* copy the handle */ MTest_Start_thread(do_work, &grequest); IF_VERBOSE(("Testing ...\n")); flag = 0; while (!flag) { MPI_Testall(1, &request, &flag, &status); } MTest_Join_threads(); IF_VERBOSE(("Goodbye !!!\n")); MTest_Finalize(0); MPI_Finalize(); return 0; }