Skip to content
Snippets Groups Projects
Commit 08df6993 authored by Pietro Incardona's avatar Pietro Incardona
Browse files

VTKWriter for point set

parents 575fbc37 3308edce
No related branches found
No related tags found
No related merge requests found
Showing
with 618 additions and 20 deletions
......@@ -17,6 +17,20 @@ git clone git@git.mpi-cbg.de:openfpm/openfpm_data.git openfpm_data
git clone git@git.mpi-cbg.de:openfpm/openfpm_pdata.git openfpm_pdata
git clone git@git.mpi-cbg.de:openfpm/openfpm_vcluster.git openfpm_vcluster
# Go in the right branch
cd openfpm_pdata
git checkout Release_0.9.0
cd ..
cd openfpm_data
git checkout Release_0.9.0
cd ..
cd openfpm_vcluster
git checkout Release_0.9.0
cd ..
cd "$1/openfpm_io"
echo "Compiling on $2"
......
......@@ -34,6 +34,11 @@ CXXFLAGS+=" -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-
NVCCFLAGS=" "
INCLUDES_PATH=" "
AC_LANG_PUSH([C++])
AC_CHECK_HEADER(mpi.h,[],[echo "mpi.h not found"
exit 200])
AC_LANG_POP([C++])
# set default prefix
if test "$prefix" = "NONE"; then
prefix="/usr/local"
......
......@@ -38,7 +38,8 @@ vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars'};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -79,11 +79,14 @@ hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
$("#export_svg1").on("click", function (event) {exportToSVG.apply(this,[1]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));chart.draw(data1, options1);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));
chart.draw(data1, options1);
$("#export_svg2").on("click", function (event) {exportToSVG.apply(this,[2]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));chart.draw(data2, options2);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));
chart.draw(data2, options2);
}</script>
</head>
<body>
......
......@@ -39,7 +39,8 @@ hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -45,7 +45,8 @@ curveType: 'function',
lineWidth: 1,
intervals: { 'style':'area' }};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -47,7 +47,8 @@ intervals: { 'style':'area' },
interval: {'i2': { 'color': '#4374E0', 'style':'bars', 'lineWidth':4, 'fillOpacity':1 } }
};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
m4/acx_mpi.m4 100755 → 100644
File mode changed from 100755 to 100644
......@@ -16,7 +16,7 @@
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/for_each.hpp>
#include "csv_multiarray.hpp"
#include "util.hpp"
#include "util/util.hpp"
#include "is_csv_writable.hpp"
#define CSV_WRITER 0x30000
......
......@@ -9,6 +9,11 @@ BOOST_AUTO_TEST_SUITE( csv_writer_test )
BOOST_AUTO_TEST_CASE( csv_writer_particles )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
{
// Allocate a property vector
auto v_prp = allocate_openfpm_prp(16);
......@@ -29,7 +34,7 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles )
// Write the CSV
csv_writer.write("csv_out.csv",v_pos,v_prp);
bool test = compare("csv_out.csv","csv_out_test.csv");
bool test = compare("csv_out.csv","test_data/csv_out_test.csv");
BOOST_REQUIRE_EQUAL(true,test);
}
......@@ -53,7 +58,7 @@ BOOST_AUTO_TEST_CASE( csv_writer_particles )
// Write the CSV
csv_writer.write("csv_out_unk.csv",v_pos,v_prp);
bool test = compare("csv_out_unk.csv","csv_out_unk_test.csv");
bool test = compare("csv_out_unk.csv","test_data/csv_out_unk_test.csv");
BOOST_REQUIRE_EQUAL(true,test);
}
......
......@@ -9,111 +9,132 @@
#define OPENFPM_IO_SRC_CSVWRITER_IS_CSV_WRITABLE_HPP_
//! Indicate if the property T is writable in CSV
template<typename T>
struct is_csv_writable
{
//! as default if not recognized is not writable
enum
{
value = false
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<float>
{
//! float is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<double>
{
//! double is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<char>
{
//! char is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<unsigned char>
{
//! unsigned char is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<short>
{
//! short is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<unsigned short>
{
//! unsigned is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<int>
{
//! int is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<unsigned int>
{
//! unsigned int is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<long int>
{
//! long int is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<unsigned long int>
{
//! unsigned long int is writable
enum
{
value = true
};
};
//! Indicate if the property T is writable in CSV
template<>
struct is_csv_writable<bool>
{
//! bool is writable
enum
{
value = true
......
......@@ -12,7 +12,7 @@
#include "GraphMLWriter.hpp"
#include "Graph/CartesianGraphFactory.hpp"
#include "util.hpp"
#include "util/util.hpp"
BOOST_AUTO_TEST_SUITE( graphml_writer_test )
......@@ -77,6 +77,11 @@ const std::string ne_cp::attributes::name[] = {"x","y","z","double_num","long_nu
BOOST_AUTO_TEST_CASE( graphml_writer_use)
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessUnitID() != 0)
return;
Graph_CSR<ne_cp,ne_cp> g_csr2;
// Add 4 vertex and connect
......@@ -114,7 +119,7 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
// check that match
bool test = compare("test_graph2.graphml","test_graph2_test.graphml");
bool test = compare("test_graph2.graphml","test_data/test_graph2_test.graphml");
BOOST_REQUIRE_EQUAL(true,test);
//! Create a graph
......@@ -138,7 +143,7 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use)
// check that match
test = compare("test_graph.graphml","test_graph_test.graphml");
test = compare("test_graph.graphml","test_data/test_graph_test.graphml");
BOOST_REQUIRE_EQUAL(true,test);
}
......
/*
* HDF5_loader.hpp
*
* Created on: May 1, 2017
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_HPP_
#define OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_HPP_
#include "VCluster/VCluster.hpp"
template <unsigned int type>
class HDF5_reader
{
void load()
{
std::cerr << __FILE__ << ":" << __LINE__ << " Error: we do not know how to write this type of data" << std::endl;
}
};
#include "HDF5_reader_vd.hpp"
#include "HDF5_reader_gd.hpp"
#endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_HPP_ */
/*
* HDF5_reader_gr.hpp
*
* Created on: May 2, 2017
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_GD_HPP_
#define OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_GD_HPP_
#include "Packer_Unpacker/Pack_selector.hpp"
#include "Packer_Unpacker/Packer.hpp"
#include "Packer_Unpacker/Unpacker.hpp"
#include "util/GBoxes.hpp"
template <>
class HDF5_reader<GRID_DIST>
{
template<typename device_grid> void load_block(long int bid,
hssize_t mpi_size_old,
int * metadata_out,
openfpm::vector<size_t> & metadata_accum,
hid_t plist_id,
hid_t dataset_2,
openfpm::vector<device_grid> & loc_grid_old,
openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext_old)
{
hsize_t offset[1];
hsize_t block[1];
if (bid < mpi_size_old && bid != -1)
{
offset[0] = metadata_accum.get(bid);
block[0] = metadata_out[bid];
}
else
{
offset[0] = 0;
block[0] = 0;
}
hsize_t count[1] = {1};
//Select file dataspace
hid_t file_dataspace_id_2 = H5Dget_space(dataset_2);
H5Sselect_hyperslab(file_dataspace_id_2, H5S_SELECT_SET, offset, NULL, count, block);
hsize_t mdim_2[1] = {block[0]};
//Create data space in memory
hid_t mem_dataspace_id_2 = H5Screate_simple(1, mdim_2, NULL);
// allocate the memory
HeapMemory pmem;
//pmem.allocate(req);
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(block[0],pmem));
mem.incRef();
// Read the dataset.
H5Dread(dataset_2, H5T_NATIVE_CHAR, mem_dataspace_id_2, file_dataspace_id_2, plist_id, (char *)mem.getPointer());
mem.allocate(pmem.size());
Unpack_stat ps;
openfpm::vector<device_grid> loc_grid_old_unp;
openfpm::vector<GBoxes<device_grid::dims>> gdb_ext_old_unp;
Unpacker<typename std::remove_reference<decltype(loc_grid_old)>::type,HeapMemory>::unpack(mem,loc_grid_old_unp,ps,1);
Unpacker<typename std::remove_reference<decltype(gdb_ext_old)>::type,HeapMemory>::unpack(mem,gdb_ext_old_unp,ps,1);
for (size_t i = 0; i < loc_grid_old_unp.size(); i++)
loc_grid_old.add(loc_grid_old_unp.get(i));
for (size_t i = 0; i < gdb_ext_old_unp.size(); i++)
gdb_ext_old.add(gdb_ext_old_unp.get(i));
mem.decRef();
delete &mem;
}
public:
template<typename device_grid> inline void load(const std::string & filename,
openfpm::vector<device_grid> & loc_grid_old,
openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext_old)
{
Vcluster & v_cl = create_vcluster();
MPI_Comm comm = v_cl.getMPIComm();
MPI_Info info = MPI_INFO_NULL;
int mpi_rank = v_cl.getProcessUnitID();
//int mpi_size = v_cl.getProcessingUnits();
// Set up file access property list with parallel I/O access
hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_mpio(plist_id, comm, info);
//Open a file
hid_t file = H5Fopen (filename.c_str(), H5F_ACC_RDONLY, plist_id);
H5Pclose(plist_id);
//Open dataset
hid_t dataset = H5Dopen (file, "metadata", H5P_DEFAULT);
//Create property list for collective dataset read
plist_id = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
//Select file dataspace
hid_t file_dataspace_id = H5Dget_space(dataset);
hssize_t mpi_size_old = H5Sget_select_npoints (file_dataspace_id);
//if (mpi_rank == 0)
//printf ("\nOld MPI size: %llu\n", mpi_size_old);
//Where to read metadata
int metadata_out[mpi_size_old];
for (int i = 0; i < mpi_size_old; i++)
{
metadata_out[i] = 0;
}
//Size for data space in memory
hsize_t mdim[1] = {(size_t)mpi_size_old};
//Create data space in memory
hid_t mem_dataspace_id = H5Screate_simple(1, mdim, NULL);
/*
if (mpi_rank == 0)
{
hssize_t size;
size = H5Sget_select_npoints (mem_dataspace_id);
printf ("\nmemspace_id size: %llu\n", size);
size = H5Sget_select_npoints (file_dataspace_id);
printf ("dataspace_id size: %llu\n", size);
}
*/
// Read the dataset.
H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace_id, file_dataspace_id, plist_id, metadata_out);
/*
if (mpi_rank == 0)
{
std::cout << "Metadata_out[]: ";
for (int i = 0; i < mpi_size_old; i++)
{
std::cout << metadata_out[i] << " ";
}
std::cout << " " << std::endl;
}
*/
openfpm::vector<size_t> metadata_accum;
metadata_accum.resize(mpi_size_old);
metadata_accum.get(0) = 0;
for (int i = 1 ; i < mpi_size_old ; i++)
metadata_accum.get(i) = metadata_accum.get(i-1) + metadata_out[i-1];
//Open dataset
hid_t dataset_2 = H5Dopen (file, "grid_dist", H5P_DEFAULT);
//Create property list for collective dataset read
plist_id = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
/////////////////////////////////////
openfpm::vector<size_t> n_block;
n_block.resize(v_cl.getProcessingUnits());
for(size_t i = 0 ; i < n_block.size() ; i++)
n_block.get(i) = mpi_size_old / v_cl.getProcessingUnits();
size_t rest_block = mpi_size_old % v_cl.getProcessingUnits();
// std::cout << "MPI size old: " << mpi_size_old << std::endl;
//std::cout << "MPI size: " << v_cl.getProcessingUnits() << std::endl;
// std::cout << "Rest block: " << rest_block << std::endl;
size_t max_block;
if (rest_block != 0)
max_block = n_block.get(0) + 1;
else
max_block = n_block.get(0);
//for(size_t i = 0 ; i < n_block.size() ; i++)
for(size_t i = 0 ; i < rest_block ; i++)
n_block.get(i) += 1;
//for(size_t i = 0 ; i < n_block.size() ; i++)
//std::cout << "n_block.get(i): " << n_block.get(i) << std::endl;
size_t start_block = 0;
size_t stop_block = 0;
if (v_cl.getProcessUnitID() != 0)
{
for(size_t i = 0 ; i < v_cl.getProcessUnitID() ; i++)
start_block += n_block.get(i);
}
stop_block = start_block + n_block.get(v_cl.getProcessUnitID());
// std::cout << "ID: " << v_cl.getProcessUnitID() << "; Start block: " << start_block << "; " << "Stop block: " << stop_block << std::endl;
if (mpi_rank >= mpi_size_old)
load_block(start_block,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,loc_grid_old,gdb_ext_old);
else
{
size_t n_bl = 0;
size_t lb = start_block;
for ( ; lb < stop_block ; lb++, n_bl++)
load_block(lb,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,loc_grid_old,gdb_ext_old);
if (n_bl < max_block)
load_block(-1,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,loc_grid_old,gdb_ext_old);
}
////////////////////////////////////
//std::cout << "LOAD: sum: " << sum << std::endl;
// Close the dataset.
H5Dclose(dataset);
H5Dclose(dataset_2);
// Close the file.
H5Fclose(file);
H5Pclose(plist_id);
}
};
#endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_GD_HPP_ */
/*
* HDF5_reader_vd.hpp
*
* Created on: May 1, 2017
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_VD_HPP_
#define OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_VD_HPP_
template <>
class HDF5_reader<VECTOR_DIST>
{
private:
template<unsigned int dim, typename St,typename prp>
bool load_block(long int bid,
hssize_t mpi_size_old,
int * metadata_out,
openfpm::vector<size_t> metadata_accum,
hid_t plist_id,
hid_t dataset_2,
size_t & g_m,
openfpm::vector<Point<dim,St>> & v_pos,
openfpm::vector<prp> & v_prp)
{
hsize_t offset[1];
hsize_t block[1];
if (bid < mpi_size_old && bid != -1)
{
offset[0] = metadata_accum.get(bid);
block[0] = metadata_out[bid];
}
else
{
offset[0] = 0;
block[0] = 0;
}
hsize_t count[1] = {1};
//Select file dataspace
hid_t file_dataspace_id_2 = H5Dget_space(dataset_2);
if (file_dataspace_id_2 < 0) {return false;}
herr_t err = H5Sselect_hyperslab(file_dataspace_id_2, H5S_SELECT_SET, offset, NULL, count, block);
if (err < 0) {return false;}
hsize_t mdim_2[1] = {block[0]};
//Create data space in memory
hid_t mem_dataspace_id_2 = H5Screate_simple(1, mdim_2, NULL);
if (mem_dataspace_id_2 < 0) {return false;}
size_t sum = 0;
for (int i = 0; i < mpi_size_old; i++)
sum += metadata_out[i];
// allocate the memory
HeapMemory pmem;
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(block[0],pmem));
mem.incRef();
// Read the dataset.
err = H5Dread(dataset_2, H5T_NATIVE_CHAR, mem_dataspace_id_2, file_dataspace_id_2, plist_id, (char *)mem.getPointer());
if (err < 0) {return false;}
mem.allocate(pmem.size());
Unpack_stat ps;
openfpm::vector<Point<dim, St>> v_pos_unp;
openfpm::vector<prp> v_prp_unp;
Unpacker<decltype(v_pos_unp),HeapMemory>::unpack(mem,v_pos_unp,ps,1);
Unpacker<decltype(v_prp_unp),HeapMemory>::unpack(mem,v_prp_unp,ps,1);
mem.decRef();
delete &mem;
for (size_t i = 0; i < v_pos_unp.size(); i++)
v_pos.add(v_pos_unp.get(i));
for (size_t i = 0; i < v_prp_unp.size(); i++)
v_prp.add(v_prp_unp.get(i));
g_m = v_pos.size();
H5Sclose(file_dataspace_id_2);
H5Sclose(mem_dataspace_id_2);
return true;
}
public:
template<unsigned int dim, typename St, typename prp> inline bool load(const std::string & filename,
openfpm::vector<Point<dim,St>> & v_pos,
openfpm::vector<prp> & v_prp,
size_t & g_m)
{
Vcluster & v_cl = create_vcluster();
v_pos.clear();
v_prp.clear();
g_m = 0;
MPI_Comm comm = v_cl.getMPIComm();
MPI_Info info = MPI_INFO_NULL;
int mpi_rank = v_cl.getProcessUnitID();
// Set up file access property list with parallel I/O access
hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
if (plist_id == -1) {return false;}
herr_t err = H5Pset_fapl_mpio(plist_id, comm, info);
if (err < 0)
return false;
//Open a file
hid_t file = H5Fopen (filename.c_str(), H5F_ACC_RDONLY, plist_id);
if (file < 0) {return false;}
H5Pclose(plist_id);
//Open dataset
hid_t dataset = H5Dopen (file, "metadata", H5P_DEFAULT);
if (dataset < 0) {return false;}
//Create property list for collective dataset read
plist_id = H5Pcreate(H5P_DATASET_XFER);
if (plist_id == -1) {return false;}
H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
//Select file dataspace
hid_t file_dataspace_id = H5Dget_space(dataset);
if (file_dataspace_id < 0) {return false;}
hssize_t mpi_size_old = H5Sget_select_npoints (file_dataspace_id);
if (mpi_size_old < 0) {return false;}
//Where to read metadata
int metadata_out[mpi_size_old];
for (int i = 0; i < mpi_size_old; i++)
{metadata_out[i] = 0;}
//Size for data space in memory
hsize_t mdim[1] = {(size_t)mpi_size_old};
//Create data space in memory
hid_t mem_dataspace_id = H5Screate_simple(1, mdim, NULL);
if (mem_dataspace_id < 0) {return false;}
// Read the dataset.
err = H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace_id, file_dataspace_id, plist_id, metadata_out);
if (err < 0) {return false;}
openfpm::vector<size_t> metadata_accum;
metadata_accum.resize(mpi_size_old);
metadata_accum.get(0) = 0;
for (int i = 1 ; i < mpi_size_old ; i++)
metadata_accum.get(i) = metadata_accum.get(i-1) + metadata_out[i-1];
//Open dataset
hid_t dataset_2 = H5Dopen (file, "vector_dist", H5P_DEFAULT);
if (dataset_2 < 0) {return false;}
//Create property list for collective dataset read
plist_id = H5Pcreate(H5P_DATASET_XFER);
if (plist_id == -1) {return false;}
err = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
if (err < 0) {return false;}
openfpm::vector<size_t> n_block;
n_block.resize(v_cl.getProcessingUnits());
for(size_t i = 0 ; i < n_block.size() ; i++)
n_block.get(i) = mpi_size_old / v_cl.getProcessingUnits();
size_t rest_block = mpi_size_old % v_cl.getProcessingUnits();
size_t max_block;
if (rest_block != 0)
max_block = n_block.get(0) + 1;
else
max_block = n_block.get(0);
//for(size_t i = 0 ; i < n_block.size() ; i++)
for(size_t i = 0 ; i < rest_block ; i++)
n_block.get(i) += 1;
size_t start_block = 0;
size_t stop_block = 0;
if (v_cl.getProcessUnitID() != 0)
{
for(size_t i = 0 ; i < v_cl.getProcessUnitID() ; i++)
start_block += n_block.get(i);
}
stop_block = start_block + n_block.get(v_cl.getProcessUnitID());
if (mpi_rank >= mpi_size_old)
load_block(start_block,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,g_m,v_pos,v_prp);
else
{
size_t n_bl = 0;
size_t lb = start_block;
for ( ; lb < stop_block ; lb++, n_bl++)
load_block(lb,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,g_m,v_pos,v_prp);
if (n_bl < max_block)
load_block(-1,mpi_size_old,metadata_out,metadata_accum,plist_id,dataset_2,g_m,v_pos,v_prp);
}
// Close open object
H5Sclose(mem_dataspace_id);
H5Sclose(file_dataspace_id);
// Close the dataset.
H5Dclose(dataset);
H5Dclose(dataset_2);
// Close the file.
H5Fclose(file);
H5Pclose(plist_id);
return true;
}
};
#endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_READER_VD_HPP_ */
/*
* HDF5_wr.hpp
*
* Created on: May 1, 2017
* Author: i-bird
*/
#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_WR_HPP_
#define OPENFPM_IO_SRC_HDF5_WR_HDF5_WR_HPP_
#define VECTOR_DIST 1
#define GRID_DIST 2
#include "HDF5_writer.hpp"
#include "HDF5_reader.hpp"
#endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_WR_HPP_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment