-
Notifications
You must be signed in to change notification settings - Fork 27
chunked Packing for diagnostics #1001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,15 +1,14 @@ | ||||||||||||||||
#ifndef PHARE_HDF5_PARTICLE_WRITER_HPP | ||||||||||||||||
#define PHARE_HDF5_PARTICLE_WRITER_HPP | ||||||||||||||||
|
||||||||||||||||
#include <array> | ||||||||||||||||
#include <vector> | ||||||||||||||||
|
||||||||||||||||
#include "hdf5/detail/hdf5_utils.hpp" | ||||||||||||||||
#include "hdf5/detail/h5/h5_file.hpp" | ||||||||||||||||
|
||||||||||||||||
#include "core/def.hpp" | ||||||||||||||||
#include "core/data/particles/particle_packer.hpp" | ||||||||||||||||
|
||||||||||||||||
#include "hdf5/detail/hdf5_utils.hpp" | ||||||||||||||||
#include "hdf5/detail/h5/h5_file.hpp" | ||||||||||||||||
|
||||||||||||||||
#include <vector> | ||||||||||||||||
|
||||||||||||||||
namespace PHARE::hdf5 | ||||||||||||||||
{ | ||||||||||||||||
|
@@ -19,23 +18,29 @@ | |||||||||||||||
template<typename H5File, typename Particles> | ||||||||||||||||
static void write(H5File& h5file, Particles const& particles, std::string const& path) | ||||||||||||||||
{ | ||||||||||||||||
auto constexpr dim = Particles::dimension; | ||||||||||||||||
using Packer = core::ParticlePacker<dim>; | ||||||||||||||||
constexpr auto dim = Particles::dimension; | ||||||||||||||||
using Packer = core::ParticlePacker<dim>; | ||||||||||||||||
constexpr auto particle_members = Packer::empty(); | ||||||||||||||||
static auto& keys = Packer::keys(); | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
Packer packer(particles); | ||||||||||||||||
core::ContiguousParticles<dim> copy{particles.size()}; | ||||||||||||||||
packer.pack(copy); | ||||||||||||||||
Packer{particles}.pack_ranges_into([&](auto const& arr, auto const from) { | ||||||||||||||||
auto const soa_members = arr(); | ||||||||||||||||
|
||||||||||||||||
std::size_t part_idx = 0; | ||||||||||||||||
core::apply(copy.as_tuple(), [&](auto const& arg) { | ||||||||||||||||
auto data_path = path + packer.keys()[part_idx++]; | ||||||||||||||||
h5file.template write_data_set_flat<2>(data_path, arg.data()); | ||||||||||||||||
core::for_N<Packer::n_keys>([&](auto ki) { | ||||||||||||||||
auto const [key, member] = std::get<ki>(soa_members); | ||||||||||||||||
auto const actual = std::get<ki>(particle_members); | ||||||||||||||||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix potential unused variable warning The -auto const [key, member] = std::get<ki>(soa_members);
+auto const [_, member] = std::get<ki>(soa_members); Or alternatively, if you want to preserve the meaningful name for documentation purposes: -auto const [key, member] = std::get<ki>(soa_members);
+auto const [[maybe_unused]] key, member] = std::get<ki>(soa_members); 📝 Committable suggestion
Suggested change
|
||||||||||||||||
|
||||||||||||||||
h5file.file() | ||||||||||||||||
.getDataSet(path + keys[ki]) | ||||||||||||||||
.select({from, 0ul}, size_for<dim>(actual, arr.size())) | ||||||||||||||||
.write_raw(member.data()); | ||||||||||||||||
}); | ||||||||||||||||
}); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
template<std::size_t dim, typename T, typename Size> | ||||||||||||||||
NO_DISCARD auto static size_for(T const& type, Size const& n_particles) | ||||||||||||||||
{ | ||||||||||||||||
|
Check notice
Code scanning / CodeQL
Unused local variable Note