Skip to content

Commit

Permalink
starting to put map array allocations on heap with alloc instead of VLAs
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Mar 7, 2019
1 parent 8f37cda commit a6025c8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,18 +1039,24 @@ int PIOc_write_nc_decomp(int iosysid, const char *filename, int cmode, int ioid,
/* Fill local array with my map. Use the fill value for unused */
/* elements at the end if max_maplen is longer than maplen. Also
* subtract 1 because the iodesc->map is 1-based. */
int my_map[max_maplen];
int *my_map;

if (!(my_map = malloc(sizeof(int) * max_maplen)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);

for (int e = 0; e < max_maplen; e++)
{
my_map[e] = e < iodesc->maplen ? iodesc->map[e] - 1 : NC_FILL_INT;
LOG((3, "my_map[%d] = %d", e, my_map[e]));
}

/* Gather my_map from all computation tasks and fill the full_map array. */
if ((mpierr = MPI_Allgather(&my_map, max_maplen, MPI_INT, full_map, max_maplen,
if ((mpierr = MPI_Allgather(my_map, max_maplen, MPI_INT, full_map, max_maplen,
MPI_INT, ios->comp_comm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);

free(my_map);

for (int p = 0; p < ios->num_comptasks; p++)
for (int e = 0; e < max_maplen; e++)
LOG((3, "full_map[%d][%d] = %d", p, e, full_map[p][e]));
Expand Down

0 comments on commit a6025c8

Please sign in to comment.