Commit 26aa08fd authored by Tobias Meisel's avatar Tobias Meisel Committed by Dmitry Yu. Naumov
Browse files

[MeL/IO] HDF5 : Improve get partition interface

parent 6b219bbb
......@@ -44,17 +44,30 @@ HdfData::HdfData(void const* data_start, std::size_t const size_partitioned_dim,
std::size_t const size_tuple, std::string const& name,
MeshPropertyDataType const mesh_property_data_type)
: data_start(data_start),
data_space{size_partitioned_dim, size_tuple},
name(name)
{
auto const& partition_info = getPartitionInfo(size_partitioned_dim);
DBUG(
"HdfData: The partition of dataset {:s} has dimension {:d} and offset "
"HdfData: The partition of dataset {:s} has length {:d} and offset "
"{:d}.",
name, size_partitioned_dim, partition_info.first);
auto const& offset_partitioned_dim = partition_info.first;
name, size_partitioned_dim, partition_info.local_offset);
auto const& offset_partitioned_dim = partition_info.local_offset;
offsets = {offset_partitioned_dim, 0};
file_space = {partition_info.second, size_tuple};
std::size_t unified_length = partition_info.local_length;
data_space =
(size_tuple > 1)
? std::vector<Hdf5DimType>{unified_length, size_tuple}
: std::vector<Hdf5DimType>{unified_length};
file_space =
(size_tuple > 1)
? std::vector<Hdf5DimType>{partition_info.local_length * partition_info.global_number_processes, size_tuple}
: std::vector<Hdf5DimType>{partition_info.local_length * partition_info.global_number_processes};
INFO("Filespace: for dataset {:s} has length {:d} and tuple {:d}.", name,
file_space[0], size_tuple);
INFO("Dataspace: for dataset {:s} has length {:d} and tuple {:d}.", name,
data_space[0], size_tuple);
data_type = meshPropertyType2HdfType(mesh_property_data_type);
}
} // namespace MeshLib::IO
\ No newline at end of file
......@@ -28,7 +28,7 @@ struct HdfData
std::size_t size_tuple, std::string const& name,
MeshPropertyDataType mesh_property_data_type);
void const* data_start;
std::vector<Hdf5DimType> const data_space;
std::vector<Hdf5DimType> data_space;
std::vector<Hdf5DimType> offsets;
std::vector<Hdf5DimType> file_space;
std::string const name;
......
......@@ -61,11 +61,11 @@ XdmfData::XdmfData(std::size_t size_partitioned_dim,
DBUG(
"XdmfData: The partition of dataset {:s} has dimension {:d} and offset "
"{:d}.",
name, size_partitioned_dim, partition_info.first);
name, size_partitioned_dim, partition_info.local_offset);
// TODO (tm) XdmfLib does not support 64 bit data types so far
assert(partition_info.second < std::numeric_limits<unsigned int>::max());
assert(partition_info.local_length < std::numeric_limits<unsigned int>::max());
auto const ui_global_components =
static_cast<unsigned int>(partition_info.second);
static_cast<unsigned int>(partition_info.local_length);
auto const ui_tuple_size = static_cast<unsigned int>(size_tuple);
piece_dims = {ui_global_components, ui_tuple_size};
......
......@@ -28,7 +28,7 @@ bool isFileManager()
return mpi_rank == 0;
}
std::pair<std::size_t, std::size_t> getPartitionInfo(std::size_t const size)
PartitionInfo getPartitionInfo(std::size_t const size)
{
MPI_Comm const mpi_comm = MPI_COMM_WORLD;
int mpi_size;
......@@ -55,6 +55,10 @@ std::pair<std::size_t, std::size_t> getPartitionInfo(std::size_t const size)
partition_sizes.end(),
back_inserter(partition_offsets));
return {partition_offsets[mpi_rank], partition_offsets.back()};
//chunked
std::size_t longest_partition = *max_element(partition_sizes.begin(), partition_sizes.end());
auto this_partition_offset = longest_partition*mpi_rank;
return {this_partition_offset, longest_partition,partition_sizes.size()};
//return {partition_offsets[mpi_rank], partition_offsets.back()};
}
} // namespace MeshLib::IO
......@@ -16,6 +16,13 @@
namespace MeshLib::IO
{
std::pair<std::size_t, std::size_t> getPartitionInfo(std::size_t const size);
struct PartitionInfo
{
std::size_t local_offset;
std::size_t local_length;
std::size_t global_number_processes;
} ;
PartitionInfo getPartitionInfo(std::size_t const size);
bool isFileManager();
} // namespace MeshLib::IO
......@@ -17,8 +17,8 @@ bool isFileManager()
return true;
}
std::pair<std::size_t, std::size_t> getPartitionInfo(std::size_t const size)
PartitionInfo getPartitionInfo(std::size_t const size)
{
return {0, size};
return {0, size, 1};
}
} // namespace MeshLib::IO
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment