Skip to content

Commit df367cf

Browse files
committed
Bug fix: write_block_read_column.c fix start and count
1 parent 557b679 commit df367cf

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

benchmarks/C/write_block_read_column.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
#define NVARS 4
4444

45+
static int verbose;
46+
4547
#define ERR(e) {if((e)!=NC_NOERR){printf("Error at line=%d: %s\n", __LINE__, ncmpi_strerror(e));nerrs++;}}
4648

4749
/*----< print_info() >------------------------------------------------------*/
@@ -124,6 +126,8 @@ int benchmark_write(char *filename,
124126
psizes[0] = psizes[1] = 0;
125127
MPI_Dims_create(nprocs, 2, psizes);
126128

129+
if (verbose && rank == 0) printf("psizes = %d %d\n",psizes[0],psizes[1]);
130+
127131
gsizes[0] = len * psizes[0];
128132
gsizes[1] = len * psizes[1];
129133

@@ -157,11 +161,14 @@ int benchmark_write(char *filename,
157161
timing[2] = end_t - start_t;
158162
start_t = end_t;
159163

160-
start[0] = len * (rank % psizes[0]);
161-
start[1] = len * ((rank / psizes[1]) % psizes[1]);
164+
start[0] = len * (rank / psizes[1]);
165+
start[1] = len * (rank % psizes[1]);
162166
count[0] = len;
163167
count[1] = len;
164168

169+
if (verbose)
170+
printf("%d: start=%lld %lld count=%lld %lld\n",rank,start[0],start[1],count[0],count[1]);
171+
165172
for (i=0; i<NVARS; i++) {
166173
if (i % 4 == 0) {
167174
err = ncmpi_put_vara_int_all(ncid, varid[i], start, count, (int*)buf[i]);
@@ -272,6 +279,8 @@ int benchmark_read(char *filename,
272279
timing[2] = end_t - start_t;
273280
start_t = end_t;
274281

282+
if (verbose) printf("%d: start=%lld %lld count=%lld %lld\n",rank,start[0],start[1],count[0],count[1]);
283+
275284
for (i=0; i<nvars; i++) {
276285
if (i % 4 == 0) {
277286
err = ncmpi_get_vara_int_all(ncid, varid[i], start, count, (int*)buf[i]);
@@ -331,7 +340,7 @@ int main(int argc, char** argv) {
331340
extern int optind;
332341
extern char *optarg;
333342
char filename[256];
334-
int i, rank, nprocs, verbose=1, nerrs=0;
343+
int i, rank, nprocs, nerrs=0;
335344
double timing[10], max_t[10];
336345
MPI_Offset len=0, w_size, r_size, sum_w_size, sum_r_size;
337346
MPI_Comm comm=MPI_COMM_WORLD;
@@ -342,6 +351,7 @@ int main(int argc, char** argv) {
342351
MPI_Comm_size(comm, &nprocs);
343352

344353
/* get command-line arguments */
354+
verbose = 1;
345355
while ((i = getopt(argc, argv, "hql:")) != EOF)
346356
switch(i) {
347357
case 'q': verbose = 0;

0 commit comments

Comments
 (0)