- /* Try the same test, but using MPI_IN_PLACE */
- initMat( comm, bufout );
- if (rank == root) {
- MPI_Reduce( MPI_IN_PLACE, bufout, count, mattype, op, root, comm );
- }
- else {
- MPI_Reduce( bufout, NULL, count, mattype, op, root, comm );
- }
- if (rank == root) {
- errs += isPermutedIdentity( comm, bufout );
- }
- }
- MPI_Type_free( &mattype );
+ buf = (int *) malloc(count * size * size * sizeof(int));
+ if (!buf)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ bufout = (int *) malloc(count * size * size * sizeof(int));
+ if (!bufout)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+
+ for (root = 0; root < size; root++) {
+ initMat(comm, buf);
+ MPI_Reduce(buf, bufout, count, mattype, op, root, comm);
+ if (rank == root) {
+ errs += isPermutedIdentity(comm, bufout);
+ }
+
+ /* Try the same test, but using MPI_IN_PLACE */
+ initMat(comm, bufout);
+ if (rank == root) {
+ MPI_Reduce(MPI_IN_PLACE, bufout, count, mattype, op, root, comm);
+ }
+ else {
+ MPI_Reduce(bufout, NULL, count, mattype, op, root, comm);
+ }
+ if (rank == root) {
+ errs += isPermutedIdentity(comm, bufout);
+ }
+ }
+ MPI_Type_free(&mattype);