diff options
-rw-r--r-- | src/H5Dmpio.c | 304 |
1 files changed, 300 insertions, 4 deletions
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index c5a3fae..9239b21 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -86,6 +86,12 @@ #define H5D_CHUNK_SELECT_IRREG 2 #define H5D_CHUNK_SELECT_NONE 0 +#define PARALLEL_COMPRESS_DEBUG + +#ifdef PARALLEL_COMPRESS_DEBUG +FILE *debug_file; +#endif + /******************/ /* Local Typedefs */ /******************/ @@ -403,6 +409,18 @@ H5D__mpio_array_gather(const H5D_io_info_t *io_info, void *local_array, *_gathered_array = gathered_array; *_gathered_array_num_entries = gathered_array_num_entries; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, " Contents of gathered array:\n"); + HDfprintf(debug_file, "------------------------------\n"); + for (size_t j = 0; j < (size_t) gathered_array_num_entries; j++) { + HDfprintf(debug_file, "| Chunk Entry %zd:\n", j); + HDfprintf(debug_file, "| - Chunk Address: %a\n", ((H5D_filtered_collective_io_info_t *) gathered_array)[j].old_chunk.offset); + HDfprintf(debug_file, "| - Chunk Length: %zd\n", ((H5D_filtered_collective_io_info_t *) gathered_array)[j].old_chunk.length); + HDfprintf(debug_file, "| - Address of mspace: %x\n", ((H5D_filtered_collective_io_info_t *) gathered_array)[j].chunk_info.mspace); + } + HDfprintf(debug_file, "------------------------------\n\n"); +#endif + done: if (receive_counts_array) H5MM_free(receive_counts_array); @@ -895,6 +913,14 @@ H5D__chunk_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_ FUNC_ENTER_PACKAGE +#ifdef PARALLEL_COMPRESS_DEBUG + char name[10]; + + snprintf(name, 10, "out - %d", H5F_mpi_get_rank(io_info->dset->oloc.file)); + + debug_file = fopen(name, "w"); +#endif + /* Call generic selection operation */ if(H5D__chunk_collective_io(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") @@ -1327,6 +1353,16 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "couldn't construct filtered I/O info list") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Incoming messages from other processes:\n"); + HDfprintf(debug_file, "-----------------------------------------\n"); + for (size_t j = 0; j < chunk_list_num_entries; j++) { + HDfprintf(debug_file, "| Owner of chunk at address %a is expecting messages from %d other processes.\n", + chunk_list[j].old_chunk.offset, chunk_list[j].num_writers - 1); + } + HDfprintf(debug_file, "-----------------------------------------\n\n"); +#endif + if (io_info->op_type == H5D_IO_OP_WRITE) { /* Filtered collective write */ H5D_chk_idx_info_t index_info; H5D_chunk_ud_t udata; @@ -1344,6 +1380,12 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in udata.common.storage = index_info.storage; udata.filter_mask = 0; + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Processing chunks:\n"); + HDfprintf(debug_file, "---------------------------------------------------\n"); +#endif + /* Iterate through all the chunks in the collective write operation, * updating each chunk with the data modifications from other processes, * then re-filtering the chunk. @@ -1353,6 +1395,10 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "couldn't process chunk entry") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "---------------------------------------------------\n\n"); +#endif + /* Gather the new chunk sizes to all processes for a collective reallocation * of the chunks in the file. */ @@ -1361,15 +1407,32 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in (void **) &collective_chunk_list, &collective_chunk_list_num_entries, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "couldn't gather new chunk sizes") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Reallocing chunks:\n"); + HDfprintf(debug_file, "------------------------------\n"); +#endif + /* Collectively re-allocate the modified chunks (from each process) in the file */ for (i = 0; i < collective_chunk_list_num_entries; i++) { hbool_t insert; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Reallocing chunk at address %a with new length of %zd.\n", collective_chunk_list[i].new_chunk.offset, collective_chunk_list[i].new_chunk.length); +#endif + if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[i].old_chunk, &collective_chunk_list[i].new_chunk, &insert, collective_chunk_list[i].chunk_info.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Chunk now at address %a.\n|\n", collective_chunk_list[i].new_chunk); +#endif } /* end for */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "------------------------------\n\n"); +#endif + if (NULL == (num_chunks_selected_array = (size_t *) H5MM_malloc((size_t) mpi_size * sizeof(*num_chunks_selected_array)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate num chunks selected array") @@ -1377,6 +1440,15 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in 1, MPI_UNSIGNED_LONG_LONG, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, " Num Chunks Selected Array\n"); + HDfprintf(debug_file, "------------------------------------\n"); + for (size_t j = 0; j < (size_t) mpi_size; j++) { + HDfprintf(debug_file, "| Process %d has %zd chunks selected.\n", j, num_chunks_selected_array[j]); + } + HDfprintf(debug_file, "------------------------------------\n\n"); +#endif + /* If this process has any chunks selected, create a MPI type for collectively * writing out the chunks to file. Otherwise, the process contributes to the * collective write with a none type. @@ -1425,6 +1497,10 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in /* Participate in the collective re-insertion of all chunks modified * in this iteration into the chunk index */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Reinserting chunks into chunk index.\n"); + HDfprintf(debug_file, "---------------------------------------\n"); +#endif for (i = 0; i < collective_chunk_list_num_entries; i++) { udata.chunk_block = collective_chunk_list[i].new_chunk; @@ -1432,7 +1508,15 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Successfully inserted chunk at address %a into the chunk index.\n", udata.chunk_block.offset); +#endif } /* end for */ + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "---------------------------------------\n"); +#endif } /* end if */ done: @@ -1805,6 +1889,19 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i udata.common.storage = index_info.storage; udata.filter_mask = 0; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Incoming messages from other processes:\n"); + HDfprintf(debug_file, "-----------------------------------------\n"); + for (size_t k = 0; k < chunk_list_num_entries; k++) { + HDfprintf(debug_file, "| Owner of chunk at address %a is expecting messages from %d other processes.\n", + chunk_list[k].old_chunk.offset, chunk_list[k].num_writers - 1); + } + HDfprintf(debug_file, "-----------------------------------------\n\n"); + + HDfprintf(debug_file, "Processing chunks:\n"); + HDfprintf(debug_file, "---------------------------------------------------\n"); +#endif + /* Retrieve the maximum number of chunks being written among all processes */ if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&chunk_list_num_entries, &max_num_chunks, 1, MPI_UNSIGNED_LONG_LONG, MPI_MAX, io_info->comm))) @@ -1847,17 +1944,35 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i (void **) &collective_chunk_list, &collective_chunk_list_num_entries, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "couldn't gather new chunk sizes") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Reallocing chunks:\n"); + HDfprintf(debug_file, "------------------------------\n"); +#endif + /* Participate in the collective re-allocation of all chunks modified * in this iteration. */ for (j = 0; j < collective_chunk_list_num_entries; j++) { hbool_t insert = FALSE; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Re-allocing chunk at address %a with new length of %llu bytes.\n", + collective_chunk_list[j].new_chunk.offset, collective_chunk_list[j].new_chunk.length); +#endif + if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[j].old_chunk, &collective_chunk_list[j].new_chunk, &insert, chunk_list[j].chunk_info.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Chunk now at address %a.\n|\n", collective_chunk_list[j].new_chunk); +#endif } /* end for */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "------------------------------\n\n"); +#endif + /* If this process has a chunk to work on, create a MPI type for the * memory and file for writing out the chunk */ @@ -1869,6 +1984,11 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i /* XXX: offset could be wrong if a process runs out of chunks */ HDmemcpy(&chunk_list[i].new_chunk, &collective_chunk_list[mpi_rank].new_chunk, sizeof(chunk_list[i].new_chunk)); +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "New chunk record after memcpy back to local:\n"); + HDfprintf(debug_file, " - Chunk offset: %a, Chunk length: %lld\n", chunk_list[i].new_chunk.offset, chunk_list[i].new_chunk.length); +#endif + H5_CHECKED_ASSIGN(mpi_type_count, int, chunk_list[i].new_chunk.length, hsize_t); /* Create MPI memory type for writing to chunk */ @@ -1907,14 +2027,27 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i /* Participate in the collective re-insertion of all chunks modified * in this iteration into the chunk index */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "Reinserting chunks into chunk index.\n"); + HDfprintf(debug_file, "---------------------------------------\n"); +#endif + for (j = 0; j < collective_chunk_list_num_entries; j++) { udata.chunk_block = collective_chunk_list[j].new_chunk; udata.common.scaled = collective_chunk_list[j].chunk_info.scaled; if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Successfully inserted chunk at address %a into the chunk index.\n", udata.chunk_block.offset); +#endif } /* end for */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "---------------------------------------\n"); +#endif + if (collective_chunk_list) collective_chunk_list = (H5D_filtered_collective_io_info_t *) H5MM_free(collective_chunk_list); } /* end for */ @@ -2599,6 +2732,39 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ chunk_node = H5SL_next(chunk_node); } /* end for */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, " Contents of local info array\n"); + HDfprintf(debug_file, "------------------------------\n"); + for (size_t j = 0; j < (size_t) num_chunks_selected; j++) { + HDfprintf(debug_file, "| Chunk Entry %zd:\n", j); + HDfprintf(debug_file, "| - Chunk Address: %a\n", local_info_array[j].old_chunk.offset); + HDfprintf(debug_file, "| - Chunk Length: %zd\n", local_info_array[j].old_chunk.length); + HDfprintf(debug_file, "| - Address of mspace: %x\n", local_info_array[j].chunk_info.mspace); + HDfprintf(debug_file, "| - Chunk Selection Type: %d\n", H5S_GET_SELECT_TYPE(local_info_array[j].chunk_info.mspace)); + HDfprintf(debug_file, "| - Chunk Num Elmts Sel.: %zd\n", H5S_GET_SELECT_NPOINTS(local_info_array[j].chunk_info.mspace)); + } + HDfprintf(debug_file, "------------------------------\n\n"); + + HDfprintf(debug_file, "Testing mem/file space addresses:\n"); + HDfprintf(debug_file, "-----------------------------------\n"); + + for (size_t j = 0; j < num_chunks_selected; j++) { + HDfprintf(debug_file, "| Testing chunk at address %a.\n", local_info_array[j].old_chunk.offset); + HDfprintf(debug_file, "| Mem Space:\n"); + HDfprintf(debug_file, "| - Extent Num elements: %zd\n", H5S_GET_EXTENT_NPOINTS(local_info_array[j].chunk_info.mspace)); + HDfprintf(debug_file, "| - Extent type: %d\n", H5S_GET_EXTENT_TYPE(local_info_array[j].chunk_info.mspace)); + HDfprintf(debug_file, "| - Selection Num elements: %zd\n", H5S_GET_SELECT_NPOINTS(local_info_array[j].chunk_info.mspace)); + HDfprintf(debug_file, "| - Selection type: %d\n", H5S_GET_SELECT_TYPE(local_info_array[j].chunk_info.mspace)); + HDfprintf(debug_file, "| File Space:\n"); + HDfprintf(debug_file, "| - Extent Num elements: %zd\n", H5S_GET_EXTENT_NPOINTS(local_info_array[j].chunk_info.fspace)); + HDfprintf(debug_file, "| - Extent type: %d\n", H5S_GET_EXTENT_TYPE(local_info_array[j].chunk_info.fspace)); + HDfprintf(debug_file, "| - Selection Num elements: %zd\n", H5S_GET_SELECT_NPOINTS(local_info_array[j].chunk_info.fspace)); + HDfprintf(debug_file, "| - Selection type: %d\n|\n", H5S_GET_SELECT_TYPE(local_info_array[j].chunk_info.fspace)); + } + + HDfprintf(debug_file, "-----------------------------------\n\n"); +#endif + /* Redistribute shared chunks to new owners as necessary */ if (!no_overlap && (io_info->op_type == H5D_IO_OP_WRITE)) { size_t i; @@ -2652,9 +2818,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ } num_writers++; - - if (++i == overlap_info_array_num_entries) break; - } while (overlap_info_array[i].old_chunk.offset == chunk_addr); + } while (++i < overlap_info_array_num_entries && overlap_info_array[i].old_chunk.offset == chunk_addr); if (mpi_rank == new_owner) { /* Make sure the new owner will know how many other processes will @@ -2684,6 +2848,10 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ mod_data_size += (size_t) iter_nelmts * type_info->src_type_size; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Allocing %zd bytes for mod. data buffer.\n", (size_t) mod_data_size); +#endif + if (NULL == (mod_data = (unsigned char *) H5MM_malloc(mod_data_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk modification send buffer") @@ -2697,11 +2865,27 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Iterating over %lld elements.\n", iter_nelmts); +#endif + /* Collect the modification data into the buffer */ if (!H5D__gather_mem(io_info->u.wbuf, chunk_entry.chunk_info.mspace, mem_iter, (size_t) iter_nelmts, io_info->dxpl_cache, mod_data_p)) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Mod. Data Buffer:\n"); + HDfprintf(debug_file, "| - ["); + for (size_t j = 0; j < (size_t) iter_nelmts; j++) { + if (j > 0) HDfprintf(debug_file, ", "); + HDfprintf(debug_file, "%lld", ((long *) mod_data_p)[j]); + } + HDfprintf(debug_file, "]\n|\n"); + + HDfprintf(debug_file, "| Sending modification data for chunk at address %a to process %d.\n", chunk_entry.old_chunk.offset, new_owner); +#endif + /* Send modification data to new owner */ H5_CHECK_OVERFLOW(mod_data_size, size_t, int) H5_CHECK_OVERFLOW(chunk_entry.chunk_info.index, hsize_t, int) @@ -2709,12 +2893,19 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ (int) chunk_entry.chunk_info.index, io_info->comm, &send_requests[num_send_requests++]))) HMPI_GOTO_ERROR(FAIL, "MPI_Isend failed", mpi_code) +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Mod. data sent.\n|\n"); +#endif if (mod_data) mod_data = (unsigned char *) H5MM_free(mod_data); if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") mem_iter_init = FALSE; } /* end else */ + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Chunk at address %a re-assigned to process %d.\n|\n", chunk_addr, new_owner); +#endif } /* end for */ /* Release old list */ @@ -2723,6 +2914,22 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ /* Local info list becomes modified (redistributed) chunk list */ local_info_array = overlap_info_array; + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "This process now has %d chunks selected after redistribution.\n\n", num_chunks_selected); + + HDfprintf(debug_file, " Contents of local info array (after redistribution)\n"); + HDfprintf(debug_file, "------------------------------\n"); + for (size_t j = 0; j < (size_t) num_chunks_selected; j++) { + HDfprintf(debug_file, "| Chunk Entry %zd:\n", j); + HDfprintf(debug_file, "| - Chunk Address: %a\n", local_info_array[j].old_chunk.offset); + HDfprintf(debug_file, "| - Chunk Length: %zd\n", local_info_array[j].old_chunk.length); + HDfprintf(debug_file, "| - Address of mspace: %x\n", local_info_array[j].chunk_info.fspace); + HDfprintf(debug_file, "| - Chunk Selection Type: %d\n", H5S_GET_SELECT_TYPE(local_info_array[j].chunk_info.fspace)); + HDfprintf(debug_file, "| - Chunk Num Elmts Sel.: %zd\n", H5S_GET_SELECT_NPOINTS(local_info_array[j].chunk_info.fspace)); + } + HDfprintf(debug_file, "------------------------------\n\n"); +#endif } /* end if */ *chunk_list = local_info_array; @@ -2805,6 +3012,11 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun /* Ensure the list is sorted in ascending order of offset in the file */ HDqsort(chunk_list, num_entries, sizeof(*chunk_list), H5D__cmp_filtered_collective_io_info_entry); +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "MPI Write type entries:\n"); + HDfprintf(debug_file, "---------------------------------\n"); +#endif + base_buf = chunk_list[0].buf; for (i = 0; i < num_entries; i++) { /* Set up the offset in the file, the length of the chunk data, and the relative @@ -2813,8 +3025,22 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun file_offset_array[i] = (MPI_Aint) chunk_list[i].new_chunk.offset; length_array[i] = (int) chunk_list[i].new_chunk.length; write_buf_array[i] = (MPI_Aint) chunk_list[i].buf - (MPI_Aint) base_buf; + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Type Entry %zd:\n", i); + HDfprintf(debug_file, "| - Offset: %a; Length: %zd\n", file_offset_array[i], length_array[i]); + HDfprintf(debug_file, "| - Write buffer:\n| ["); + for (size_t j = 0; j < (size_t) length_array[i]; j++) { + HDfprintf(debug_file, "%c, ", ((char *) chunk_list[i].buf)[j]); + } + HDfprintf(debug_file, "]\n|\n"); +#endif } /* end for */ +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "---------------------------------\n\n"); +#endif + /* Create memory MPI type */ if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int) num_entries, length_array, write_buf_array, MPI_BYTE, new_mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) @@ -2877,8 +3103,13 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HDassert(io_info); HDassert(type_info); +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Chunk at address %a:\n", chunk_entry->old_chunk.offset); +#endif + /* XXX: Determine if a chunk is being fully overwritten by looking at the total selection - * in the dataspace + * in the dataspace. Possibly receive all data ahead of time so that the dataspaces can + * be ORed? */ /* If this is a read operation or a write operation where the chunk is not being fully @@ -2891,6 +3122,12 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk : (hsize_t) H5S_GET_EXTENT_NPOINTS(chunk_entry->chunk_info.fspace) * type_info->src_type_size; chunk_entry->new_chunk.length = buf_size; +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Allocing %zd bytes for chunk data buffer.\n", buf_size); + if (io_info->op_type == H5D_IO_OP_WRITE) + HDfprintf(debug_file, "| - Write type is: %s.\n", (full_overwrite) ? "overwrite" : "non-overwrite"); +#endif + if (NULL == (chunk_entry->buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") @@ -2906,6 +3143,17 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk io_info->dxpl_cache->err_detect, io_info->dxpl_cache->filter_cb, (size_t *) &chunk_entry->new_chunk.length, &buf_size, &chunk_entry->buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "couldn't unfilter chunk for modifying") + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - After decompression: Nbytes=%zd; Buf_size=%zd.\n", chunk_entry->new_chunk.length, buf_size); + + HDfprintf(debug_file, "| - Read buf:\n| - ["); + for (size_t j = 0; j < chunk_entry->new_chunk.length / type_info->src_type_size; j++) { + if (j > 0) HDfprintf(debug_file, ", "); + HDfprintf(debug_file, "%lld", ((long *) chunk_entry->buf)[j]); + } + HDfprintf(debug_file, "]\n|\n"); +#endif } /* end if */ /* Initialize iterator for memory selection */ @@ -2955,10 +3203,18 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk io_info->comm, &status))) HMPI_GOTO_ERROR(FAIL, "MPI_Probe failed", mpi_code) +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Found message from source %d with tag %d.\n", status.MPI_SOURCE, status.MPI_TAG); +#endif + /* Retrieve the message size */ if (MPI_SUCCESS != (mpi_code = MPI_Get_count(&status, MPI_BYTE, &count))) HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mpi_code) +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Message size is %d bytes.\n", count); +#endif + if (NULL == (mod_data = (unsigned char *) H5MM_malloc((size_t) count))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate modification data receive buffer") mod_data_p = mod_data; @@ -2967,10 +3223,23 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk (int) chunk_entry->chunk_info.index, io_info->comm, &status))) HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mpi_code) +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Received the message.\n"); +#endif + /* Decode the process' chunk file dataspace */ if (NULL == (dataspace = H5S_decode(&mod_data_p))) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Deserialized selection info:\n"); + HDfprintf(debug_file, "| Mem Space:\n"); + HDfprintf(debug_file, "| - Extent Num elements: %zd\n", H5S_GET_EXTENT_NPOINTS(dataspace)); + HDfprintf(debug_file, "| - Extent type: %d\n", H5S_GET_EXTENT_TYPE(dataspace)); + HDfprintf(debug_file, "| - Selection Num elements: %zd\n", H5S_GET_SELECT_NPOINTS(dataspace)); + HDfprintf(debug_file, "| - Selection type: %d\n", H5S_GET_SELECT_TYPE(dataspace)); +#endif + if (H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; @@ -2978,6 +3247,20 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Contents of message:\n| ["); + for (size_t j = 0; j < iter_nelmts; j++) { + if (j > 0) HDfprintf(debug_file, ", "); + HDfprintf(debug_file, "%lld", ((long *) mod_data_p)[j]); + } + HDfprintf(debug_file, "]\n"); +#endif + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| Iter nelmts=%lld.\n", iter_nelmts); + HDfprintf(debug_file, "| Mem space selected points: %zd.\n| \n", H5S_GET_SELECT_NPOINTS(dataspace)); +#endif + /* Update the chunk data with the received modification data */ if (H5D__scatter_mem(mod_data_p, dataspace, mem_iter, (size_t) iter_nelmts, io_info->dxpl_cache, chunk_entry->buf) < 0) @@ -2997,6 +3280,19 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk mem_iter_init = FALSE; } /* end while */ + +#ifdef PARALLEL_COMPRESS_DEBUG + HDfprintf(debug_file, "| - Chunk Data Buffer:\n"); + HDfprintf(debug_file, "| - ["); + for (size_t j = 0; j < chunk_entry->new_chunk.length / type_info->src_type_size; j++) { + if (j > 0) HDfprintf(debug_file, ", "); + HDfprintf(debug_file, "%lld", ((long *) chunk_entry->buf)[j]); + } + HDfprintf(debug_file, "]\n|\n"); + + HDfprintf(debug_file, "| - About to filter %zd bytes in buffer of size %zd.\n|\n", chunk_entry->new_chunk.length, buf_size); +#endif + /* Filter the chunk */ if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, 0, &filter_mask, io_info->dxpl_cache->err_detect, io_info->dxpl_cache->filter_cb, |