8#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_GD_HPP_
9#define OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_GD_HPP_
12#include "Packer_Unpacker/Pack_selector.hpp"
13#include "Packer_Unpacker/Packer.hpp"
14#include "Packer_Unpacker/Unpacker.hpp"
15#include "util/GBoxes.hpp"
22 template<
typename device_gr
id>
23 inline void save(
const std::string & filename,
33 Packer<
typename std::remove_reference<
decltype(loc_grid)>::type,
HeapMemory>::packRequest(loc_grid,req);
34 Packer<
typename std::remove_reference<
decltype(gdb_ext)>::type,
HeapMemory>::packRequest(gdb_ext,req);
48 Packer<
typename std::remove_reference<
decltype(loc_grid)>::type,
HeapMemory>::pack(mem,loc_grid,sts);
49 Packer<
typename std::remove_reference<
decltype(gdb_ext)>::type,
HeapMemory>::pack(mem,gdb_ext,sts);
61 MPI_Info info = MPI_INFO_NULL;
65 hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
66 H5Pset_fapl_mpio(plist_id, comm, info);
69 hid_t file = H5Fcreate (filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
72 size_t sz = pmem.
size();
80 for (
size_t i = 0; i < sz_others.
size(); i++)
81 sum += sz_others.get(i);
84 hsize_t fdim[1] = {
sum};
87 hsize_t fdim2[1] = {(size_t)mpi_size};
90 hid_t file_dataspace_id = H5Screate_simple(1, fdim, NULL);
93 hid_t file_dataspace_id_2 = H5Screate_simple(1, fdim2, NULL);
99 hid_t file_dataset = H5Dcreate (file,
"grid_dist", H5T_NATIVE_CHAR, file_dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
102 hid_t file_dataset_2 = H5Dcreate (file,
"metadata", H5T_NATIVE_LLONG, file_dataspace_id_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
105 H5Sclose(file_dataspace_id);
106 H5Sclose(file_dataspace_id_2);
108 hsize_t block[1] = {pmem.
size()};
112 hsize_t count[1] = {1};
114 hsize_t offset[1] = {0};
116 for (
int i = 0; i < mpi_rank; i++)
124 offset[0] += sz_others.get(i);
129 long int metadata[mpi_size];
131 for (
int i = 0; i < mpi_size; i++)
132 metadata[i] = sz_others.get(i);
135 file_dataspace_id = H5Dget_space(file_dataset);
138 plist_id = H5Pcreate(H5P_DATASET_XFER);
139 H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
142 size_t to_write = block[0];
147 block_c[0] = std::min((
size_t)(to_write),(
size_t)0x7FFFFFFF);
150 hid_t mem_dataspace_id = H5Screate_simple(1, block_c, NULL);
152 hsize_t offset_c[1] = {offset[0] + coffset};
153 H5Sselect_hyperslab(file_dataspace_id, H5S_SELECT_SET, offset_c, NULL, count, block_c);
156 H5Dwrite(file_dataset, H5T_NATIVE_CHAR, mem_dataspace_id, file_dataspace_id, plist_id, (
const char *)pmem.
getPointer() + coffset);
158 coffset += std::min((
size_t)(to_write),(
size_t)0x7FFFFFFF);
159 to_write -= std::min((
size_t)(to_write),(
size_t)0x7FFFFFFF);
161 H5Sclose(mem_dataspace_id);
164 file_dataspace_id_2 = H5Dget_space(file_dataset_2);
167 H5Dwrite(file_dataset_2, H5T_NATIVE_LLONG, H5S_ALL, file_dataspace_id_2, plist_id, metadata);
170 H5Dclose(file_dataset);
171 H5Sclose(file_dataspace_id);
172 H5Dclose(file_dataset_2);
173 H5Sclose(file_dataspace_id_2);
virtual void decRef()
Decrement the reference counter.
virtual void incRef()
Increment the reference counter.
This class allocate, and destroy CPU memory.
virtual void * getPointer()
get a readable pointer with the data
virtual size_t size() const
the the size of the allocated memory
void execute()
Execute all the requests.
MPI_Comm getMPIComm()
Get the MPI_Communicator (or processor group) this VCluster is using.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
This structure store the Box that define the domain inside the Ghost + domain box.
It model an expression expr1 + ... exprn.