[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1-229-ge3813c2
Service Account
noreply at mpich.org
Tue May 6 14:00:01 CDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".
The branch, master has been updated
via e3813c2e9e7816c0baa750883d984e0f9110a2a7 (commit)
via 50f3d5806e5cf3934ef991eef2d7d238846380d6 (commit)
via 4190800705217a5ff136e40ad8be031bf5e36243 (commit)
via 71f1dae1cd5eb073f9dadf823a59f69e50fa433d (commit)
from 27f99ee3363c938a56b7be935545c5355a051820 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/e3813c2e9e7816c0baa750883d984e0f9110a2a7
commit e3813c2e9e7816c0baa750883d984e0f9110a2a7
Author: Rob Latham <robl at mcs.anl.gov>
Date: Tue May 6 12:53:43 2014 -0500
test case for 'resized of resized'
ROMIO flattening code presently does not handle resized-of-resized
types.
See #2088
diff --git a/test/mpi/io/Makefile.am b/test/mpi/io/Makefile.am
index 9d988de..31e6c87 100644
--- a/test/mpi/io/Makefile.am
+++ b/test/mpi/io/Makefile.am
@@ -22,7 +22,8 @@ noinst_PROGRAMS = \
async \
async_any \
userioerr \
- resized
+ resized \
+ resized2
clean-local:
-rm -f testfile testfile.*
diff --git a/test/mpi/io/resized2.c b/test/mpi/io/resized2.c
new file mode 100644
index 0000000..a60ff26
--- /dev/null
+++ b/test/mpi/io/resized2.c
@@ -0,0 +1,131 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test file views with MPI_Type_create_resized";
+*/
+
+int main(int argc, char **argv)
+{
+ int i, nprocs, len, mpi_errno, buf[2], newbuf[4];
+ int errs=0;
+ MPI_Offset size;
+ MPI_Aint lb, extent;
+ MPI_File fh;
+ char *filename;
+ MPI_Datatype newtype, newtype1;
+
+ MTest_Init(&argc,&argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ if (nprocs != 1) {
+ fprintf(stderr, "Run this program on 1 process\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ len = 8;
+ filename = (char *)malloc(len + 10);
+ strcpy( filename, "testfile" );
+ /*
+ fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int)strlen(*argv);
+ filename = (char *) malloc(len+1);
+ strcpy(filename, *argv);
+ }
+
+ MPI_File_delete(filename, MPI_INFO_NULL);
+
+ /* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
+ lb = sizeof(int);
+ extent = 3*sizeof(int);
+ MPI_Type_create_resized(MPI_INT, lb, extent, &newtype1);
+
+ MPI_Type_commit(&newtype1);
+ MPI_Type_create_resized(newtype1, lb, extent, &newtype);
+ MPI_Type_commit(&newtype);
+
+ /* initialize the file */
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
+ MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ for (i=0; i<4; i++) newbuf[i] = 55;
+ MPI_File_write(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+ MPI_File_close(&fh);
+
+ /* write 2 ints into file view with resized type */
+
+ buf[0] = 10;
+ buf[1] = 20;
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
+ MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS) errs++;
+
+ MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
+
+ MPI_File_close(&fh);
+
+
+ /* read back file view with resized type and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS) errs++;
+
+ for (i=0; i<4; i++) newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 2, MPI_INT, MPI_STATUS_IGNORE);
+ if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] !=100) || (newbuf[3] != 100)) {
+ errs++;
+ fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ }
+
+ MPI_File_close(&fh);
+
+ /* read file back and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename,
+ MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ MPI_File_get_size(fh, &size);
+ if (size != 4*sizeof(int)) {
+ errs++;
+ fprintf(stderr, "file size is %lld, should be %d\n", size, (int)(4*sizeof(int)));
+ }
+
+ for (i=0; i<4; i++) newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+ if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] !=55) || (newbuf[2] != 55)) {
+ errs++;
+ fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&newtype1);
+ MPI_Type_free(&newtype);
+ free(filename);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/io/testlist b/test/mpi/io/testlist
index 0a019e0..dfad3f0 100644
--- a/test/mpi/io/testlist
+++ b/test/mpi/io/testlist
@@ -8,3 +8,4 @@ async 4
async_any 4
userioerr 1
resized 1
+resized2 1 xfail=ticket2088
http://git.mpich.org/mpich.git/commitdiff/50f3d5806e5cf3934ef991eef2d7d238846380d6
commit 50f3d5806e5cf3934ef991eef2d7d238846380d6
Author: Rob Latham <robl at mcs.anl.gov>
Date: Mon May 5 10:14:14 2014 -0500
ROMIO dtype flattening: ignore zero-length counts
Bill Gropp reminds us not to forget this text from MPI-3
MPI-3, page 84, lines 18-20.
"Most datatype constructors have replication count or block length
arguments. Allowed values are non-negative integers. If the value is
zero, no elements are generated in the type map and there is no effect
on datatype bounds or extent."
The ROMIO flattening codes was treating blocklen elments of zero as
significant.
the struct case probably has the same bug, but I'm deeply nervous about
touching too much of this old code with a release imminent.
Closes: #2073
diff --git a/src/mpi/romio/adio/common/flatten.c b/src/mpi/romio/adio/common/flatten.c
index 6437705..b8708af 100644
--- a/src/mpi/romio/adio/common/flatten.c
+++ b/src/mpi/romio/adio/common/flatten.c
@@ -107,7 +107,7 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
ADIO_Offset st_offset, MPI_Count *curr_index)
{
- int i, k, m, n, basic_num;
+ int i, k, m, n, basic_num, nonzeroth;
int combiner, old_combiner, old_is_contig;
int nints, nadds, ntypes, old_nints, old_nadds, old_ntypes;
/* By using ADIO_Offset we preserve +/- sign and
@@ -140,6 +140,13 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
DBG_FPRINTF(stderr,"ADIOI_Flatten:: types[%d]=%#llX\n",i,(unsigned long long)(unsigned long)types[i]);
}
#endif
+ /* Chapter 4, page 83: when processing datatypes, note this item from the
+ * standard:
+ Most datatype constructors have replication count or block length
+ arguments. Allowed values are non-negative integers. If the value is
+ zero, no elements are generated in the type map and there is no effect
+ on datatype bounds or extent. */
+
switch (combiner) {
#ifdef MPIIMPL_HAVE_MPI_COMBINER_DUP
case MPI_COMBINER_DUP:
@@ -399,12 +406,19 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
if (prev_index == *curr_index) {
/* simplest case, indexed type made up of basic or contiguous types */
j = *curr_index;
- for (i=j; i<j+top_count; i++) {
+ for (i=j, nonzeroth=i; i<j+top_count; i++) {
/* By using ADIO_Offset we preserve +/- sign and
avoid >2G integer arithmetic problems */
ADIO_Offset blocklength = ints[1+i-j], stride = ints[top_count+1+i-j];
- flat->indices[i] = st_offset + stride* ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[i] = blocklength* ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ if (blocklength > 0) {
+ flat->indices[nonzeroth] =
+ st_offset + stride* ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] =
+ blocklength* ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ nonzeroth++;
+ } else {
+ flat->count--; /* don't count/consider any zero-length blocklens */
+ }
}
*curr_index = i;
}
@@ -418,10 +432,17 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
/* The noncontiguous types have to be replicated blocklens[i] times
and then strided. Replicate the first one. */
for (m=1; m<ints[1]; m++) {
- for (i=0; i<num; i++) {
- flat->indices[j] = flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-num];
- j++;
+ for (i=0, nonzeroth = j; i<num; i++) {
+ if (flat->blocklens[j-num] > 0) {
+ flat->indices[nonzeroth] =
+ flat->indices[nonzeroth-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] =
+ flat->blocklens[nonzeroth-num];
+ j++;
+ nonzeroth++;
+ } else {
+ flat->count --;
+ }
}
}
*curr_index = j;
@@ -430,20 +451,32 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
for (i=1; i<top_count; i++) {
num = *curr_index - prev_index;
prev_index = *curr_index;
- for (m=0; m<basic_num; m++) {
+ for (m=0, nonzeroth=j; m<basic_num; m++) {
/* By using ADIO_Offset we preserve +/- sign and
avoid >2G integer arithmetic problems */
ADIO_Offset stride = ints[top_count+1+i]-ints[top_count+i];
- flat->indices[j] = flat->indices[j-num] + stride* ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-num];
- j++;
+ if (flat->blocklens[j-num] > 0 ) {
+ flat->indices[nonzeroth] =
+ flat->indices[j-num] + stride* ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] = flat->blocklens[j-num];
+ j++;
+ nonzeroth++;
+ } else {
+ flat->count--;
+ }
}
*curr_index = j;
for (m=1; m<ints[1+i]; m++) {
- for (k=0; k<basic_num; k++) {
- flat->indices[j] = flat->indices[j-basic_num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-basic_num];
- j++;
+ for (k=0, nonzeroth=j; k<basic_num; k++) {
+ if (flat->blocklens[j-basic_num] > 0) {
+ flat->indices[nonzeroth] =
+ flat->indices[j-basic_num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] = flat->blocklens[j-basic_num];
+ j++;
+ nonzeroth++;
+ } else {
+ flat->count --;
+ }
}
}
*curr_index = j;
@@ -542,12 +575,17 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
/* simplest case, indexed type made up of basic or contiguous types */
j = *curr_index;
MPI_Type_size_x(types[0], &old_size);
- for (i=j; i<j+top_count; i++) {
- /* By using ADIO_Offset we preserve +/- sign and
- avoid >2G integer arithmetic problems */
- ADIO_Offset blocklength = ints[1+i-j];
- flat->indices[i] = st_offset + adds[i-j];
- flat->blocklens[i] = blocklength*old_size;
+ for (i=j, nonzeroth=j; i<j+top_count; i++) {
+ if (ints[1+i-j] > 0) {
+ /* By using ADIO_Offset we preserve +/- sign and
+ avoid >2G integer arithmetic problems */
+ ADIO_Offset blocklength = ints[1+i-j];
+ flat->indices[nonzeroth] = st_offset + adds[i-j];
+ flat->blocklens[nonzeroth] = blocklength*old_size;
+ nonzeroth++;
+ } else {
+ flat->count--;
+ }
}
*curr_index = i;
}
@@ -562,10 +600,16 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
and then strided. Replicate the first one. */
MPI_Type_extent(types[0], &old_extent);
for (m=1; m<ints[1]; m++) {
- for (i=0; i<num; i++) {
- flat->indices[j] = flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-num];
- j++;
+ for (i=0, nonzeroth=j; i<num; i++) {
+ if (flat->blocklens[j-num] > 0) {
+ flat->indices[nonzeroth] =
+ flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] = flat->blocklens[j-num];
+ j++;
+ nonzeroth++;
+ } else {
+ flat->count--;
+ }
}
}
*curr_index = j;
@@ -574,18 +618,28 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
for (i=1; i<top_count; i++) {
num = *curr_index - prev_index;
prev_index = *curr_index;
- for (m=0; m<basic_num; m++) {
- flat->indices[j] = flat->indices[j-num] + adds[i] - adds[i-1];
- flat->blocklens[j] = flat->blocklens[j-num];
- j++;
+ for (m=0, nonzeroth=j; m<basic_num; m++) {
+ if (flat->blocklens[j-num] > 0) {
+ flat->indices[nonzeroth] =
+ flat->indices[j-num] + adds[i] - adds[i-1];
+ flat->blocklens[nonzeroth] = flat->blocklens[j-num];
+ j++;
+ nonzeroth++;
+ } else {
+ flat->count--;
+ }
}
*curr_index = j;
for (m=1; m<ints[1+i]; m++) {
- for (k=0; k<basic_num; k++) {
- flat->indices[j] = flat->indices[j-basic_num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-basic_num];
- j++;
- }
+ for (k=0,nonzeroth=j; k<basic_num; k++) {
+ if (flat->blocklens[j-basic_num] >0) {
+ flat->indices[nonzeroth] =
+ flat->indices[j-basic_num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[nonzeroth] = flat->blocklens[j-basic_num];
+ j++;
+ nonzeroth++;
+ }
+ }
}
*curr_index = j;
}
@@ -611,15 +665,19 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
/* simplest case, current type is basic or contiguous types */
/* By using ADIO_Offset we preserve +/- sign and
avoid >2G integer arithmetic problems */
- ADIO_Offset blocklength = ints[1+n];
- j = *curr_index;
- flat->indices[j] = st_offset + adds[n];
- MPI_Type_size_x(types[n], &old_size);
- flat->blocklens[j] = blocklength * old_size;
- #ifdef FLATTEN_DEBUG
- DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",n,adds[n],j, flat->indices[j], j, flat->blocklens[j]);
- #endif
- (*curr_index)++;
+ if (ints[1+n] > 0) {
+ ADIO_Offset blocklength = ints[1+n];
+ j = *curr_index;
+ flat->indices[j] = st_offset + adds[n];
+ MPI_Type_size_x(types[n], &old_size);
+ flat->blocklens[j] = blocklength * old_size;
+#ifdef FLATTEN_DEBUG
+ DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",n,adds[n],j, flat->indices[j], j, flat->blocklens[j]);
+#endif
+ (*curr_index)++;
+ } else {
+ flat->count--;
+ }
}
else {
/* current type made up of noncontiguous derived types */
@@ -631,12 +689,17 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
MPI_Type_extent(types[n], &old_extent);
for (m=1; m<ints[1+n]; m++) {
for (i=0; i<num; i++) {
- flat->indices[j] = flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
- flat->blocklens[j] = flat->blocklens[j-num];
- #ifdef FLATTEN_DEBUG
- DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple old_extent "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",old_extent,j, flat->indices[j], j, flat->blocklens[j]);
- #endif
- j++;
+ if (flat->blocklens[j-num] > 0) {
+ flat->indices[j] =
+ flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
+ flat->blocklens[j] = flat->blocklens[j-num];
+#ifdef FLATTEN_DEBUG
+ DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple old_extent "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",old_extent,j, flat->indices[j], j, flat->blocklens[j]);
+#endif
+ j++;
+ } else {
+ flat->count --;
+ }
}
}
*curr_index = j;
@@ -654,6 +717,9 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
/* handle the Lb */
j = *curr_index;
flat->indices[j] = st_offset + adds[0];
+ /* this zero-length blocklens[] element, unlike eleswhere in the
+ * flattening code, is correct and is used to indicate a lower bound
+ * marker */
flat->blocklens[j] = 0;
#ifdef FLATTEN_DEBUG
@@ -688,6 +754,8 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
/* take care of the extent as a UB */
j = *curr_index;
flat->indices[j] = st_offset + adds[0] + adds[1];
+ /* again, zero-element ok: an upper-bound marker explicitly set by the
+ * constructor of this resized type */
flat->blocklens[j] = 0;
#ifdef FLATTEN_DEBUG
http://git.mpich.org/mpich.git/commitdiff/4190800705217a5ff136e40ad8be031bf5e36243
commit 4190800705217a5ff136e40ad8be031bf5e36243
Author: Rob Latham <robl at mcs.anl.gov>
Date: Thu May 1 15:54:37 2014 -0500
turn datatype test into a function
diff --git a/src/mpi/romio/test/indexed_zeros.c b/src/mpi/romio/test/indexed_zeros.c
index e574dd8..96bd2cd 100644
--- a/src/mpi/romio/test/indexed_zeros.c
+++ b/src/mpi/romio/test/indexed_zeros.c
@@ -17,22 +17,18 @@ static void handle_error(int errcode, const char *str)
fprintf(stderr, "%s: %s\n", str, msg);
MPI_Abort(MPI_COMM_WORLD, 1);
}
-int main(int argc, char **argv) {
+
+int test_indexed_with_zeros(char *filename)
+{
int i, rank, np, buflen, num, err, nr_errors;
int nelms[MAXLEN], buf[MAXLEN], indices[MAXLEN], blocklen[MAXLEN];
MPI_File fh;
MPI_Status status;
MPI_Datatype filetype;
- MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &np);
- if (np != 2) {
- if (rank == 0) fprintf(stderr,"Must run on 2 MPI processes\n");
- MPI_Finalize(); return 1;
- }
-
/* set up the number of integers to write in each iteration */
for (i=0; i<MAXLEN; i++) nelms[i] = 0;
if (rank == 0) nelms[4]=nelms[5]=nelms[7]=1;
@@ -41,7 +37,7 @@ int main(int argc, char **argv) {
/* pre-fill the file with integers -999 */
if (rank == 0) {
for (i=0; i<MAXLEN; i++) buf[i] = -999;
- err =MPI_File_open(MPI_COMM_SELF, argv[1], MPI_MODE_CREATE|MPI_MODE_WRONLY,
+ err =MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE|MPI_MODE_WRONLY,
MPI_INFO_NULL, &fh);
if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
err = MPI_File_write(fh, buf, MAXLEN, MPI_INT, &status);
@@ -64,7 +60,7 @@ int main(int argc, char **argv) {
/* initialize write buffer and write to file*/
for (i=0; i<MAXLEN; i++) buf[i] = 1;
- err =MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ err =MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
err = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view");
@@ -76,7 +72,7 @@ int main(int argc, char **argv) {
/* read back and check */
if (rank == 0) {
- err = MPI_File_open(MPI_COMM_SELF, argv[1], MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
err = MPI_File_read(fh,buf, MAXLEN, MPI_INT, &status);
if (err != MPI_SUCCESS) handle_error(err, "MPI_File_read");
@@ -88,8 +84,26 @@ int main(int argc, char **argv) {
printf("Error: unexpected value at buf[%d] == %d\n",i,buf[i]);
}
}
- if (nr_errors == 0) printf(" No Errors\n");
}
+ return nr_errors;
+}
+
+int main(int argc, char **argv)
+{
+
+ int nr_errors, rank, np;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &np);
+
+ if (np != 2) {
+ if (rank == 0) fprintf(stderr,"Must run on 2 MPI processes\n");
+ MPI_Finalize(); return 1;
+ }
+ nr_errors += test_indexed_with_zeros(argv[1]);
+
+ if (rank == 0 && nr_errors == 0) printf(" No Errors\n");
MPI_Finalize();
return 0;
http://git.mpich.org/mpich.git/commitdiff/71f1dae1cd5eb073f9dadf823a59f69e50fa433d
commit 71f1dae1cd5eb073f9dadf823a59f69e50fa433d
Author: Wei-keng Liao <wkliao at eecs.northwestern.edu>
Date: Wed Apr 30 16:38:26 2014 -0500
ROMIO test case demonstrating indexed type bugs
The problem is when defining a filetype using MPI_Type_indexed and the
first few elements of argument blocklens[] are zeros, a collective write
will miss writing some data.
The test program first fills a file with 9 integers with values all
-999. It then defines a filetype and writes to the file in parallel
with user buffers with value all 1s. Lastly, the file is read back and
checked for contents.
(it's Wei-keng's test case. I just hooked it into ROMIO's test suite)
Signed-off-by: Rob Latham <robl at mcs.anl.gov>
diff --git a/src/mpi/romio/test/Makefile.am b/src/mpi/romio/test/Makefile.am
index f3157bd..6159361 100644
--- a/src/mpi/romio/test/Makefile.am
+++ b/src/mpi/romio/test/Makefile.am
@@ -25,7 +25,7 @@ AM_FFLAGS = $(USER_FFLAGS)
CTESTS = simple perf async coll_test coll_perf misc file_info excl large_array \
atomicity noncontig i_noncontig noncontig_coll split_coll shared_fp \
large_file psimple error status noncontig_coll2 aggregation1 aggregation2 \
- async-multiple ordered_fp hindexed external32
+ async-multiple ordered_fp hindexed external32 indexed_zeros
FTESTS = fcoll_test fperf fmisc pfcoll_test
diff --git a/src/mpi/romio/test/indexed_zeros.c b/src/mpi/romio/test/indexed_zeros.c
new file mode 100644
index 0000000..e574dd8
--- /dev/null
+++ b/src/mpi/romio/test/indexed_zeros.c
@@ -0,0 +1,97 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include <mpi.h>
+
+#define MAXLEN 9
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+int main(int argc, char **argv) {
+ int i, rank, np, buflen, num, err, nr_errors;
+ int nelms[MAXLEN], buf[MAXLEN], indices[MAXLEN], blocklen[MAXLEN];
+ MPI_File fh;
+ MPI_Status status;
+ MPI_Datatype filetype;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &np);
+
+ if (np != 2) {
+ if (rank == 0) fprintf(stderr,"Must run on 2 MPI processes\n");
+ MPI_Finalize(); return 1;
+ }
+
+ /* set up the number of integers to write in each iteration */
+ for (i=0; i<MAXLEN; i++) nelms[i] = 0;
+ if (rank == 0) nelms[4]=nelms[5]=nelms[7]=1;
+ if (rank == 1) nelms[0]=nelms[1]=nelms[2]=nelms[3]=nelms[6]=nelms[8]=1;
+
+ /* pre-fill the file with integers -999 */
+ if (rank == 0) {
+ for (i=0; i<MAXLEN; i++) buf[i] = -999;
+ err =MPI_File_open(MPI_COMM_SELF, argv[1], MPI_MODE_CREATE|MPI_MODE_WRONLY,
+ MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ err = MPI_File_write(fh, buf, MAXLEN, MPI_INT, &status);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_write");
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* define a filetype using indexed constructor */
+ buflen = num = 0;
+ for (i=0; i<MAXLEN; i++) {
+ buflen += nelms[i];
+ indices[num] = i;
+ blocklen[num] = nelms[i];
+ num++;
+ }
+ MPI_Type_indexed(num, blocklen, indices, MPI_INT, &filetype);
+ MPI_Type_commit(&filetype);
+
+ /* initialize write buffer and write to file*/
+ for (i=0; i<MAXLEN; i++) buf[i] = 1;
+ err =MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ err = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view");
+ err = MPI_File_write_all(fh, buf, buflen, MPI_INT, &status);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_write_all");
+ MPI_Type_free(&filetype);
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+
+ /* read back and check */
+ if (rank == 0) {
+ err = MPI_File_open(MPI_COMM_SELF, argv[1], MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ err = MPI_File_read(fh,buf, MAXLEN, MPI_INT, &status);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_read");
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+ for (i=0; i<MAXLEN; i++) {
+ if (buf[i] < 0) {
+ nr_errors++;
+ printf("Error: unexpected value at buf[%d] == %d\n",i,buf[i]);
+ }
+ }
+ if (nr_errors == 0) printf(" No Errors\n");
+ }
+
+ MPI_Finalize();
+ return 0;
+}
+
diff --git a/src/mpi/romio/test/runtests.in b/src/mpi/romio/test/runtests.in
index 0ae23eb..1d606f5 100644
--- a/src/mpi/romio/test/runtests.in
+++ b/src/mpi/romio/test/runtests.in
@@ -372,6 +372,13 @@ echo '**** Testing status.c ****'
$mpirun -np 1 ./status -fname $FILENAME
# CheckOutput status
CleanExe status
+testfiles="$testfiles indexed_zeros.out"
+\rm -f indexed_zeros.out
+MakeExe indexed_zeros
+\rm -f $FILENAME*
+echo '**** Testing indexed_zeros ****'
+$mpirun -np 2 ./indexed_zeros $FILENAME
+CleanExe indexed_zeros
#
if [ @NOF77@ = 0 ] ; then
echo ""
-----------------------------------------------------------------------
Summary of changes:
src/mpi/romio/adio/common/flatten.c | 168 +++++++++++++++++++++++----------
src/mpi/romio/test/Makefile.am | 2 +-
src/mpi/romio/test/indexed_zeros.c | 111 ++++++++++++++++++++++
src/mpi/romio/test/runtests.in | 7 ++
test/mpi/io/Makefile.am | 3 +-
test/mpi/io/{resized.c => resized2.c} | 7 +-
test/mpi/io/testlist | 1 +
7 files changed, 245 insertions(+), 54 deletions(-)
create mode 100644 src/mpi/romio/test/indexed_zeros.c
copy test/mpi/io/{resized.c => resized2.c} (94%)
hooks/post-receive
--
MPICH primary repository
More information about the commits
mailing list