59#ifndef DIST_MAP_GRAPH_HPP_
60#define DIST_MAP_GRAPH_HPP_
62#include "Vector/map_vector.hpp"
63#include "Graph/map_graph.hpp"
64#include <unordered_map>
65#include "Packer_Unpacker/Packer.hpp"
66#include "Packer_Unpacker/Unpacker.hpp"
67#include "VCluster/VCluster.hpp"
70#define DIST_GRAPH_ERROR 7001
72template<
typename V,
typename E,
76 template<
typename>
class layout_v_base,
77 template<
typename>
class layout_e_base,
84 typedef boost::fusion::vector<size_t, size_t> type;
88 static const unsigned int id = 0;
89 static const unsigned int gid = 1;
90 static const unsigned int max_prop = 2;
96 inline void setid(
size_t id_)
98 boost::fusion::at_c<0>(data) = id_;
101 inline void setgid(
size_t gid_)
103 boost::fusion::at_c<1>(data) = gid_;
106 template<
unsigned int id>
inline auto get() ->
decltype(boost::fusion::at_c < id > (data))
108 return boost::fusion::at_c<id>(data);
111 template<
unsigned int id>
inline auto get()
const ->
const decltype(boost::fusion::at_c < id > (data))
113 return boost::fusion::at_c<id>(data);
123 boost::fusion::at_c<0>(data) = p.template get<0>();
124 boost::fusion::at_c<1>(data) = p.template get<1>();
129 static bool noPointers()
138 typedef boost::fusion::vector<size_t, size_t> type;
142 static const unsigned int sgid = 0;
143 static const unsigned int dgid = 1;
144 static const unsigned int max_prop = 2;
150 template<
unsigned int id>
inline auto get() ->
decltype(boost::fusion::at_c < id > (data))
152 return boost::fusion::at_c<id>(data);
155 template<
unsigned int id>
inline auto get()
const ->
const decltype(boost::fusion::at_c < id > (data))
157 return boost::fusion::at_c<id>(data);
167 boost::fusion::at_c<0>(data) = p.template get<0>();
168 boost::fusion::at_c<1>(data) = p.template get<1>();
173 static bool noPointers()
202template<
typename V,
typename E =
no_edge,
245 std::unordered_map<size_t, size_t>
id2glb;
248 std::unordered_map<size_t, size_t>
glb2id;
325 template<
typename CheckPolicy = NoCheck>
inline size_t addEdge_(
size_t v1,
size_t v2)
328 if (CheckPolicy::valid(v1,
v.size()) ==
false)
329 {
return (
size_t)NO_EDGE;}
330 if (CheckPolicy::valid(v2,
v.size()) ==
false)
331 {
return (
size_t)NO_EDGE;}
334 size_t id_x_end =
v_l.template get<0>(v1);
340 for (
size_t s = 0; s < id_x_end; s++)
342 if (
e_l.template get<e_map::vid>(v1 *
v_slot + s) == v2)
344 std::cerr <<
"Error graph: the edge already exist\n";
360 for (
size_t i = 0; i <
v.size(); i++)
363 g_new.
v.set(i,
v, 2 * i);
374 if (id_x_end >=
e_l.size())
381 e_l.template get<e_map::vid>(v1 *
v_slot + id_x_end) = v2;
382 e_l.template get<e_map::eid>(v1 *
v_slot + id_x_end) =
e.size();
385 e.resize(
e.size() + 1);
386 e_m.resize(
e_m.size() + 1);
389 ++
v_l.template get<0>(v1);
404 static void *
gr_receive(
size_t msg_i,
size_t total_msg,
size_t total_p,
size_t i,
size_t ri,
size_t tag,
void * ptr)
408 v->get(i).allocate(msg_i);
410 return v->get(i).getPointer();
423 static void *
on_receive(
size_t msg_i,
size_t total_msg,
size_t total_p,
size_t i,
size_t ri,
size_t tag,
void * ptr)
427 v->get(i).resize(msg_i /
sizeof(
size_t));
429 return &(
v->get(i).get(0));
441 sgp.get(p).send_v.clear();
442 sgp.get(p).send_v_m.clear();
443 sgp.get(p).send_e.clear();
444 sgp.get(p).send_e_m.clear();
445 sgp.get(p).send_es.clear();
446 sgp.get(p).send_el.clear();
447 sgp.get(p).isEmpty =
true;
463 sgp.get(p).send_v = s_v;
464 sgp.get(p).send_v_m = s_v_m;
465 sgp.get(p).send_e = s_e;
466 sgp.get(p).send_e_m = s_e_m;
467 sgp.get(p).send_es = s_es;
468 sgp.get(p).send_el = s_el;
469 sgp.get(p).isEmpty =
true;
490 for (
size_t i = 0; i < this->
getNVertex(); ++i)
496 for (
size_t j = 0; j < this->
getNChilds(i); j++)
521 for (
size_t j = 0; j <
v_td.
size(); ++j)
523 if (i ==
v_td.get(j))
551 template<
bool addAsGhosts>
569 nvts +=
sgp.get(i).send_v.
size();
576 if (
sgp.get(i).isEmpty)
582 size_t vp_size =
sgp.get(pc).send_v.size();
589 for (
size_t j = 0; j < vp_size; j++)
601 for (
size_t k = 0; k <
sgp.get(pc).send_es.get(j); k++)
620 to_release.add(&pmem);
621 to_release_ext.add(&mem);
629 for (
size_t j = 0; j < vp_size; j++)
641 for (
size_t k = 0; k <
sgp.get(pc).send_es.get(j); k++)
647 Packer<
decltype(
sgp.get(pc).send_e_m.get(0)),
HeapMemory>::pack(mem,
sgp.get(pc).send_e_m.get(e_it), sts);
657 size.add(pmem.
size());
664 for (
int i = 0 ; i < to_release_ext.
size(); i++)
666 to_release_ext.get(i)->decRef();
667 delete to_release_ext.get(i);
669 delete to_release.get(i);
688 for (
size_t j = prev; j < prev + r_size; j++)
697 add_vertex(v_n, vm.template get<v_info::id>(), vm.template get<v_info::gid>());
700 ghs_map.insert( { vm.template get<v_info::gid>(),
false });
707 for (
size_t k = 0; k < s; k++)
722 addEdge(j, el_n, e_n, e_i);
757 for (
size_t i = 1; i <= recv.
size(); ++i)
780 std::unordered_map<size_t, IdnProc> on_toup;
785 std::map<size_t, size_t> old_glob2loc(
glb2loc.begin(),
glb2loc.end());
795 for (
auto it : old_glob2loc)
798 IdnProc nidpid = { j, p_id };
799 on_toup.insert( {
v_m.get(it.second).template get<v_info::id>(), nidpid });
802 on_info.get(
getInfoProc(it.first)).add(
v_m.get(it.second).template get<v_info::id>());
806 map_v(j,
v_m.get(it.second).template get<v_info::gid>(), it.second);
821 fillSendRecvStructs<size_t>(on_info, prc, size, ptr);
831 for (
size_t j = 0; j < on_vs.get(i).size() - 1; j += 2)
833 IdnProc nidpid = { on_vs.get(i).get(j + 1), i };
834 on_toup.insert( { on_vs.get(i).get(j), nidpid });
842 auto search = on_toup.find(
glbi_map.at(k.first).id);
843 if (search != on_toup.end())
845 GlobalVInfo t = { (search->second).
id, (search->second).pid };
870 vni.get(pid).add(vid);
875 rmi_m.insert( { vid,
glbi_map.at(vid).
id });
880 rmi_m.insert( { vid,
glb2id.at(vid) });
889 fillSendRecvStructs<size_t>(vni, prc, size, ptr);
901 for (
size_t i = 0; i < req_rmi.
size(); ++i)
903 for (
size_t j = 0; j < req_rmi.get(i).size(); ++j)
905 resp_rmi.get(i).add(
glbi_map.at(req_rmi.get(i).get(j)).id);
910 fillSendRecvStructs<size_t>(resp_rmi, prc, size, ptr);
916 for (
size_t i = 0; i < rmi.
size(); ++i)
918 for (
size_t j = 0; j < rmi.get(i).size(); ++j)
920 rmi_m.insert( { vni.get(i).get(j), rmi.get(i).get(j) });
944 info.
id =
v_m.get(i).template get<v_info::id>();
946 glbi_map.insert( {
v_m.get(i).
template get<v_info::gid>(), info });
984 for (
size_t i = 0; i < vec.size(); ++i)
989 size.add(vec.get(i).size() *
sizeof(T));
990 ptr.add(vec.get(i).getPointer());
1023 dup.
v.swap(
v.duplicate());
1024 dup.
v_m.swap(
v_m.duplicate());
1025 dup.
v_l.swap(
v_l.duplicate());
1029 dup.
e.swap(
e.duplicate());
1030 dup.
e_m.swap(
e_m.duplicate());
1031 dup.
e_l.swap(
e_l.duplicate());
1044 vcl(create_vcluster())
1055 :
vcl(create_vcluster())
1091 v_m.resize(n_vertex);
1093 v_l.resize(n_vertex);
1206 template<
unsigned int i>
auto vertex_p(
size_t id) ->
decltype(
v.template get<i>(
id) )
1208 return v.template get<i>(
id);
1221 return v.template get<i>(
id);
1247 return v.get(
id.get(0));
1261 return v.get(
id.get());
1271 auto vertex(
size_t id)
const ->
const decltype(
v.get(
id) )
1287 return v.get(
id.get(0));
1301 return v.get(
id.get());
1315 return v_m.get(
id.get());
1332 std::cerr << __FILE__ <<
":" << __LINE__ <<
" The vertex with global id " <<
id <<
" is not in this sub-graph. Try to call reqVertex(" <<
id <<
") and sync() first.\n";
1333 ACTION_ON_ERROR(DIST_GRAPH_ERROR);
1338 return v.get(
glb2loc.find(
id)->second);
1353 }
catch (
const std::out_of_range& oor)
1355 std::cerr <<
"The vertex with global id " <<
id <<
" is not in this sub-graph. Try to call reqVertex(" <<
id <<
") and sync() first.\n";
1375 }
catch (
const std::out_of_range& oor)
1377 std::cout <<
"Node not found by glb: " <<
id << std::endl;
1408 return v_m.get(i).template get<v_info::id>();
1418 return v_m.get(i).template get<v_info::gid>();
1428 auto search =
glb2id.find(
id);
1430 if (search !=
glb2id.end())
1449 void map_v(
size_t n,
size_t g,
size_t l)
1451 id2glb.insert( { n, g });
1452 glb2id.insert( { g, n });
1454 v_m.get(l).template get<v_info::id>() = n;
1485 return e.template get<i>(
id);
1496 template<
unsigned int i>
auto edge_p(
size_t id) ->
decltype (
e.template get<i>(
id) )
1498 return e.template get<i>(
id);
1510 return e.get(
id.get(0));
1522 return e.get(
e_l.template get<e_map::eid>(ek.pos *
v_slot + ek.pos_e));
1539 }
catch (
const std::out_of_range& oor)
1541 std::cout <<
"The source vertex of this edge is not in this graph.\n";
1544 return e.get(
e_l.template get<e_map::eid>(
v *
v_slot + ek.pos_e));
1556 auto edge(
size_t id)
const ->
const decltype (
e.get(
id) )
1570 return v_l.template get<0>(c);
1582 return v_l.template get<0>(c.get());
1597 }
catch (
const std::out_of_range& oor)
1599 std::cout <<
"The source vertex of this edge is not in this graph.\n";
1602 return v_l.template get<0>(
v);
1615 return e.get(
e_l.template get<e_map::eid>(
v *
v_slot + v_e));
1628 return e_m.get(
e_l.template get<e_map::eid>(
v *
v_slot + v_e));
1639 inline auto getEdge(
size_t v,
size_t v_e) ->
decltype(
e.get(0))
1644 }
catch (
const std::out_of_range& oor)
1646 std::cout <<
"The source vertex of this edge is not in this graph.\n";
1649 return e.get(
e_l.template get<e_map::eid>(
v *
v_slot + v_e));
1663 if (i >=
v_l.template get<0>(
v))
1665 std::cerr <<
"Error " << __FILE__ <<
" line: " << __LINE__ <<
" vertex " <<
v <<
" does not have edge " << i <<
" on processor " <<
vcl.
getProcessUnitID() <<
"\n";
1668 if (
e.size() <=
e_l.template get<e_map::eid>(
v *
v_slot + i))
1670 std::cerr <<
"Error " << __FILE__ <<
" " << __LINE__ <<
" vertex " <<
v <<
" does not have edge " << i <<
" on processor " <<
vcl.
getProcessUnitID() <<
" (" <<
e.size() <<
"<=" <<
e_l.template get<e_map::eid>(
v *
v_slot + i) <<
")\n";
1674 return e_l.template get<e_map::vid>(
v *
v_slot + i);
1687 return e_l.template get<e_map::vid>(i);
1701 if (i >=
v_l.template get<0>(
v.get()))
1703 std::cerr <<
"Error " << __FILE__ <<
" line: " << __LINE__ <<
" vertex " <<
v.get() <<
" does not have edge " << i <<
"\n";
1706 if (
e.size() <=
e_l.template get<e_map::eid>(
v.get() *
v_slot + i))
1708 std::cerr <<
"Error " << __FILE__ <<
" " << __LINE__ <<
" vertex " <<
v.get() <<
" does not have edge " << i <<
"\n";
1713 return e_l.template get<e_map::vid>(
v.get() *
v_slot + i);
1726 vm.template get<v_info::id>() = id;
1727 vm.template get<v_info::gid>() =
gid;
1761 vm.template get<v_info::id>() = id;
1762 vm.template get<v_info::gid>() =
gid;
1804 v_m.template get<v_info::id>(l) = i;
1806 v_m.template get<v_info::gid>(l) = g;
1812 glb2id.insert( { g, i });
1815 id2glb.insert( { i, g });
1818 inline auto addEdge(
size_t v1,
size_t v2,
size_t srcgid,
size_t dstgid) ->
decltype(
e.get(0))
1821 long int id_x_end = addEdge_<NoCheck>(v1, v2);
1823 if (id_x_end == NO_EDGE)
1827 e_m.template get<e_info::sgid>(id_x_end) = srcgid;
1828 e_m.template get<e_info::dgid>(id_x_end) = dstgid;
1831 return e.get(id_x_end);
1834 inline auto addEdge(
size_t v1,
size_t v2,
size_t srcgid,
size_t dstgid,
const E &
ed) ->
decltype(
e.get(0))
1837 long int id_x_end = addEdge_<NoCheck>(v1, v2);
1839 if (id_x_end == NO_EDGE)
1843 e.set(id_x_end,
ed);
1846 e_m.template get<e_info::sgid>(id_x_end) = srcgid;
1847 e_m.template get<e_info::dgid>(id_x_end) = dstgid;
1850 return e.get(id_x_end);
1856 long int id_x_end = addEdge_<NoCheck>(v1, v2);
1858 if (id_x_end == NO_EDGE)
1862 e.set(id_x_end,
ed);
1863 e_m.set(id_x_end, ei);
1866 return e.get(id_x_end);
1869 inline auto addEdge(
size_t v1,
size_t v2,
const E &
ed,
const e_info & ei) ->
decltype(
e.get(0))
1872 long int id_x_end = addEdge_<NoCheck>(v1, v2);
1874 if (id_x_end == NO_EDGE)
1878 e.set(id_x_end,
ed);
1879 e_m.set(id_x_end, ei);
1882 return e.get(id_x_end);
1893 size_t eid =
e_l.template get<e_map::eid>(v1 *
v_slot + s);
1894 return e_m.template get<e_info::sgid>(eid);
1905 size_t eid =
e_l.template get<e_map::eid>(v1 *
v_slot + s);
1906 return e_m.template get<e_info::dgid>(eid);
1914 template<
typename CheckPolicy = NoCheck>
inline void add_edge(
size_t v1,
size_t v2)
1926 EdgeReq er = { v1, v2, 0, 0 };
1933 long int id_x_end = addEdge_<CheckPolicy>(
glb2loc.at(v1),
glb2id.at(v2));
1936 if (id_x_end == NO_EDGE)
1940 e_m.get(id_x_end).template get<e_info::sgid>() = v1;
1941 e_m.get(id_x_end).template get<e_info::dgid>() = v2;
1953 for (
size_t i = 0; i <
e_queue.size(); ++i)
1964 long int id_x_end = addEdge_<>(req.v1n, req.v2n);
1967 if (id_x_end == NO_EDGE)
1971 e_m.get(id_x_end).template get<e_info::sgid>() = req.v1;
1972 e_m.get(id_x_end).template get<e_info::dgid>() = req.v2;
2002 size_t v_slot_tmp =
v_slot;
2030 size_t v_slot_tmp =
v_slot;
2032 g.v_slot = v_slot_tmp;
2044 return v.getIterator();
2108 auto search =
ghs_map.find(
id);
2148 e.resize(
e.size() - epos);
2149 e_m.resize(
e_m.size() - epos);
2163 template<
bool toRemove = true>
2169 std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" target processor is equal the local processor\n";
2174 if (
sgp.get(t).isEmpty)
2175 sgp.get(t).isEmpty =
false;
2181 sgp.get(t).send_v_m.add(
v_m.get(i));
2207 if (
sgp.get(i).isEmpty)
2226 exchangeVertices<false>();
2273 fillSendRecvStructs<size_t>(
vr_queue, prc, size, ptr);
2279 for (
size_t i = 0; i < resp.
size(); ++i)
2281 reqs.get(i).clear();
2283 for (
size_t j = 0; j < resp.get(i).size(); ++j)
2287 reqs.get(i).add(
glbi_map.at(resp.get(i).get(j)).pid);
2288 }
catch (
const std::out_of_range& oor)
2290 std::cout << resp.get(i).get(j) <<
" not found in global info map (proc: " <<
vcl.
getProcessUnitID() <<
")\n";
2296 fillSendRecvStructs<size_t>(reqs, prc, size, ptr);
2315 for (
size_t j = 0; j <
vr_queue.get(i).size(); ++j)
2317 reqs.get(resp.get(i).get(j)).add(
vr_queue.get(i).get(j));
2323 for (
size_t j = 0; j <
vr_queue.get(i).size(); ++j)
2331 fillSendRecvStructs<size_t>(reqs, prc, size, ptr);
2340 for (
size_t i = 0; i < resp.
size(); ++i)
2342 for (
size_t j = 0; j < resp.get(i).size(); ++j)
2346 q_move<false>(
glb2loc.at(resp.get(i).get(j)), i);
2347 }
catch (
const std::out_of_range& oor)
2349 std::cout << resp.get(i).get(j) <<
" not found in global to local map (proc: " <<
vcl.
getProcessUnitID() <<
")\n";
2355 exchangeVertices<true>();
2386template<
typename V,
typename E>
Simplified implementation of DistGraph_CSR.
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
openfpm::vector< idx_t > fvtxdist
Fixed distribution vector, it never changes, it maintains always the first decomposition and topology...
void setGlobalMap(size_t g, size_t l, size_t i)
map global id to local id
void initGlbimap()
Initialize the fixed structure for global mapping. See glbiv for details.
size_t getNVertex() const
Return the number of the vertices in this subgraph.
auto getEdge(size_t v, size_t v_e) -> decltype(e.get(0))
Get the vertex edge given the vertex global id as source.
auto getVertex(size_t id) const -> const decltype(v.get(0))
Function to access the vertexes.
void swap(DistGraph_CSR< V, E > &g)
Swap the memory of g with this graph.
void add_vertex(const V &vrt, size_t gid)
Add vertex vrt with global id and id properties.
DistGraph_CSR()
Constructor.
auto getVertex(size_t id) -> decltype(v.get(id))
Function to access the vertexes.
size_t getTotNVertex() const
Return the total number of the vertices.
void deleteGhosts()
Remove all the ghosts from this graph.
void q_move(size_t i, size_t t)
Prepare to send vertex i from the local processor to the target processor.
void init()
Once added all the vertices this function must be called to initialize all the properties,...
void swap(DistGraph_CSR< V, E > &&g)
Swap the memory of g with this graph.
auto vertex_p(size_t id) -> decltype(v.template get< i >(id))
operator to access the vertex
void initDistributionVector()
Initialize the vtxdist and the fvtxdist.
auto edge(grid_key_dx< 1 > id) const -> const decltype(e.get(id.get(0)))
Access the edge.
size_t addEdge_(size_t v1, size_t v2)
add edge on the graph
void remap()
Re-map received vertices in order to have ordered vertex ids.
void sync()
Execute all vertex requests and add them as ghosts inside this graph, they will be available until a ...
void initDistributionVector(openfpm::vector< idx_t > &v)
Operator to access the decomposition vector.
size_t getVertexId(size_t i) const
Get the id of a vertex given its index position.
static void * gr_receive(size_t msg_i, size_t total_msg, size_t total_p, size_t i, size_t ri, size_t tag, void *ptr)
Callback to set the size of the receiving vector.
void add_edge(size_t v1, size_t v2)
Add an edge between vertices v1 end v2, needs syncEdge() to complete the action.
std::unordered_map< size_t, size_t > glb2loc
Map to access the local vertex id given the global one.
openfpm::vector< size_t, Memory, layout_v_base, grow_p, openfpm::vect_isel< size_t >::value > v_l
Structure that store the number of adjacent vertex in e_l for each vertex.
size_t getChildDstGid(size_t v1, size_t s)
Get the global id of edge's destination vertex.
auto edge_p(size_t id) -> decltype(e.template get< i >(id))
Access the edge.
size_t v_slot
number of slot per vertex
auto edge(edge_key ek) const -> const decltype(e.get(0))
operator to access the edge
openfpm::vector< E, Memory, layout_e_base, grow_p, openfpm::vect_isel< E >::value > e_invalid
invalid edge element, when a function try to create an in valid edge this object is returned
auto vertex(grid_key_dx< 1 > id) const -> const decltype(v.get(id.get(0)))
operator to access the vertex
size_t getChildSrcGid(size_t v1, size_t s)
Get the global id of edge's source vertex.
void exchangeVertices()
Send and receive vertices and update current graph.
void clear()
operator to clear the whole graph
size_t getInfoProc(size_t vid)
Get the processor id of the processor containing the vertex with global id vid.
void fillSendRecvStructs(openfpm::vector< openfpm::vector< T > > &vec, openfpm::vector< size_t > &prc, openfpm::vector< size_t > &size, openfpm::vector< void * > &ptr)
Fill the prc, size and ptr structures with the data of vec.
edge_iterator< DistGraph_CSR< V, E, Memory > > getEdgeIterator() const
Get the vertex iterator.
auto getEdge(edge_key ek) const -> const decltype(e.get(0))
operator to access the edge
std::unordered_map< size_t, GlobalVInfo > glbi_map
TODO update description from pdf.
auto getVertexIterator() const -> decltype(v.getIterator())
Get the vertex iterator.
openfpm::vector< EdgeReq > e_queue
Queue of requests to add edges.
openfpm::vector< E, Memory, layout_e_base, grow_p, openfpm::vect_isel< E >::value >::container E_container
Object container for the edge, for example can be encap<...> (map_grid or openfpm::vector)
size_t getNEdge() const
Return the number of edges.
bool vertexIsInThisGraph(size_t id)
Check if the vertex with GLOBAL id is in this graph.
void deleteMovedVertices()
Remove from this graph the vertices that have been sent.
size_t nodeById(size_t id) const
operator to access the vertex position index by id property
auto vertex_p(grid_key_dx< 1 > id) -> decltype(v.template get< i >(id))
Access the vertex.
void resetExchange()
Init communication structures.
void redistribute()
Redistribute function that wraps different stages of the redistribution.
openfpm::vector< e_map, Memory, layout_e_base, grow_p, openfpm::vect_isel< e_map >::value > e_l
Structure that store for each vertex the adjacent the vertex id and edge id (for property into e)
Vcluster & vcl
Vcluster communication object.
std::unordered_map< size_t, size_t > glb2id
Map to access the vertex id given the global vertex id.
bool isGhost(size_t id)
Check if a vertex is a ghost vertex (not belonging to this processor)
std::unordered_map< size_t, size_t > id2glb
Map to access to the global vertex id given the vertex id.
openfpm::vector< V, Memory, layout_v_base, grow_p, openfpm::vect_isel< V >::value > v
Structure that store the vertex properties.
DistGraph_CSR(Vcluster<> &vcl, DistGraph_CSR< V, E, Memory > &&g)
Copy constructor.
DistGraph_CSR(size_t n_vertex, size_t n_slot)
Constructor.
DistGraph_CSR< V, E, Memory > & operator=(const DistGraph_CSR< V, E, Memory > &g)
Copy the graph.
auto vertex(openfpm::vector_key_iterator id) -> decltype(v.get(0))
operator to access the vertex
bool isToDelete(size_t i)
Check it the vertex i must be deleted or not.
auto edge_p(grid_key_dx< 1 > id) -> decltype(e.template get< i >(id))
Access the edge.
size_t getVProcessor(size_t v)
Get the processor of the the given vertex id, CAN be used BEFORE re-mapping starts.
void getDecompositionVector(openfpm::vector< idx_t > &v)
Operator to access the decomposition vector.
DistGraph_CSR< V, E, Memory, layout_v, layout_e, layout_v_base, layout_e_base, grow_p > duplicate() const
It duplicate the graph.
openfpm::vector< SendGraphPack > sgp
Pack storing that data to send to other processors.
size_t getNChilds(size_t c) const
Return the number of children of a vertex.
DistGraph_CSR(DistGraph_CSR &&dg)
Constructor.
bool moveQueueIsEmpty()
Check if the move queue is empty.
auto vertex(grid_key_dx< 1 > id) -> decltype(v.get(id.get(0)))
operator to access the vertex
void add_vertex(const V &vrt, size_t id, size_t gid)
Add vertex vrt with global id and id properties.
openfpm::vector< idx_t > vtxdist
Distribution vector.
size_t getChild(size_t v, size_t i) const
Get the child edge.
DistGraph_CSR(size_t n_vertex)
Constructor.
auto vertex(openfpm::vector_key_iterator id) const -> const decltype(v.get(0))
operator to access the vertex
void updateVtxdist()
Update the distribution vector vtxdist.
size_t getNEdge(size_t v) const
Return the number of children of a vertex given its global id.
auto edge(size_t id) const -> const decltype(e.get(id))
operator to access the edge
void reqVertex(size_t gid)
Put a vertex request in queue.
openfpm::vector< idx_t > * getVtxdist()
Operator to access the decomposition vector.
std::unordered_map< size_t, bool > ghs_map
Map containing the ghost vertices of this graph, if bool is false the ghost will be deleted in the ne...
openfpm::vector< V, Memory, layout_v_base, grow_p, openfpm::vect_isel< V >::value >::container V_container
Object container for the vertex, for example can be encap<...> (map_grid or openfpm::vector)
DistGraph_CSR(const DistGraph_CSR &dg)
Constructor.
openfpm::vector< size_t > v_td
Array containing the sent vertices and that will be deleted from the graph.
openfpm::vector< e_info, Memory, layout_e_base, grow_p, openfpm::vect_isel< e_info >::value > e_m
Structure that store the edge properties.
void add_vertex(const encapc< dim, V, Mem > &vrt, size_t id, size_t gid)
Add vertex vrt with global id and id properties.
DistGraph_CSR< V, E, Memory > & operator=(DistGraph_CSR< V, E, Memory > &&g)
Copy the graph.
auto vertex(size_t id) -> decltype(v.get(id))
Function to access the vertexes.
static void * on_receive(size_t msg_i, size_t total_msg, size_t total_p, size_t i, size_t ri, size_t tag, void *ptr)
Callback of the sendrecv to set the size of the array received.
auto vertex(size_t id) const -> const decltype(v.get(id))
Function to access the vertexes.
auto vertex_info(openfpm::vector_key_iterator id) const -> const decltype(v_m.get(0))
operator to access the vertex info
auto getChildInfo(size_t v, size_t v_e) -> decltype(e_m.get(0))
Get the vertex edge info.
size_t getNChilds(typename openfpm::vector< V, Memory, layout_v_base, grow_p, openfpm::vect_isel< V >::value >::iterator_key &c)
Return the number of childs of a vertex.
void map_v(size_t n, size_t g, size_t l)
operator to update all the hashmap
openfpm::vector< v_info, Memory, memory_traits_lin, grow_p, openfpm::vect_isel< v_info >::value > v_m
Structure that store the vertex id and global id.
openfpm::vector< openfpm::vector< size_t > > vr_queue
Queue of vertex requests.
openfpm::vector< E, Memory, layout_e_base, grow_p, openfpm::vect_isel< E >::value > e
Structure that store the edge properties.
void syncEdge()
Execute a synchronization through processor to finalize the add of the edges requested in the e_queue...
size_t getChild(size_t i) const
Get the child edge.
auto getChildEdge(size_t v, size_t v_e) -> decltype(e.get(0))
Get the vertex edge.
size_t getChild(typename openfpm::vector< V, Memory, layout_v_base, grow_p, openfpm::vect_isel< V >::value >::iterator_key &v, size_t i)
Get the child edge.
size_t getVertexGlobalId(size_t i) const
Get the id of a vertex given its index position.
virtual void incRef()
Increment the reference counter.
void * getPointerBase()
The the base pointer of the preallocate memory.
This class allocate, and destroy CPU memory.
virtual size_t size() const
the the size of the allocated memory
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
void execute()
Execute all the requests.
void sendrecvMultipleMessagesNBX(openfpm::vector< size_t > &prc, openfpm::vector< T > &data, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &recv_sz, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE)
Send and receive multiple messages.
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.
grid_key_dx is the key to access any element in the grid
Grow policy define how the vector should grow every time we exceed the size.
Implementation of 1-D std::vector like structure.
Structure to store a add request of an edge.
size_t v2n
destination vertex global index
size_t v1n
source vertex global index
Structure needed to get vertex position by global id.
Struct containing the (sub)graph to send.
bool isEmpty
Indicates if the pack is empty or not.
openfpm::vector< v_info > send_v_m
vertex info send buffer
openfpm::vector< size_t > send_es
For each vertex contain the number of children.
openfpm::vector< size_t > send_el
For each edge contain the child vertex id.
openfpm::vector< e_info > send_e_m
edge info send buffer
openfpm::vector< E > send_e
edge send buffer
openfpm::vector< V > send_v
vertex send buffer
Transform the boost::fusion::vector into memory specification (memory_traits)
It analyze the type given and it select correctly the implementation for vector.
Sub-domain vertex graph node.