Commit 9ad7b3bb authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Better forced inline tuning

parent cd45a52e
...@@ -378,7 +378,7 @@ namespace boost { ...@@ -378,7 +378,7 @@ namespace boost {
} }
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline
typename filtered_graph<G, EP, VP>::degree_size_type typename filtered_graph<G, EP, VP>::degree_size_type
out_degree(typename filtered_graph<G, EP, VP>::vertex_descriptor u, out_degree(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
const filtered_graph<G, EP, VP>& g) const filtered_graph<G, EP, VP>& g)
...@@ -414,7 +414,7 @@ namespace boost { ...@@ -414,7 +414,7 @@ namespace boost {
} }
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename filtered_graph<G, EP, VP>::in_adjacency_iterator, std::pair<typename filtered_graph<G, EP, VP>::in_adjacency_iterator,
typename filtered_graph<G, EP, VP>::in_adjacency_iterator> typename filtered_graph<G, EP, VP>::in_adjacency_iterator>
in_neighbours(typename filtered_graph<G, EP, VP>::vertex_descriptor u, in_neighbours(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
...@@ -428,7 +428,7 @@ template <typename G, typename EP, typename VP> ...@@ -428,7 +428,7 @@ template <typename G, typename EP, typename VP>
} }
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename filtered_graph<G, EP, VP>::adjacency_iterator, std::pair<typename filtered_graph<G, EP, VP>::adjacency_iterator,
typename filtered_graph<G, EP, VP>::adjacency_iterator> typename filtered_graph<G, EP, VP>::adjacency_iterator>
adjacent_vertices(typename filtered_graph<G, EP, VP>::vertex_descriptor u, adjacent_vertices(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
...@@ -439,7 +439,7 @@ template <typename G, typename EP, typename VP> ...@@ -439,7 +439,7 @@ template <typename G, typename EP, typename VP>
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename filtered_graph<G, EP, VP>::in_edge_iterator, std::pair<typename filtered_graph<G, EP, VP>::in_edge_iterator,
typename filtered_graph<G, EP, VP>::in_edge_iterator> typename filtered_graph<G, EP, VP>::in_edge_iterator>
in_edges(typename filtered_graph<G, EP, VP>::vertex_descriptor u, in_edges(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
...@@ -453,7 +453,7 @@ template <typename G, typename EP, typename VP> ...@@ -453,7 +453,7 @@ template <typename G, typename EP, typename VP>
} }
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline
typename filtered_graph<G, EP, VP>::degree_size_type typename filtered_graph<G, EP, VP>::degree_size_type
in_degree(typename filtered_graph<G, EP, VP>::vertex_descriptor u, in_degree(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
const filtered_graph<G, EP, VP>& g) const filtered_graph<G, EP, VP>& g)
...@@ -466,7 +466,7 @@ template <typename G, typename EP, typename VP> ...@@ -466,7 +466,7 @@ template <typename G, typename EP, typename VP>
} }
template <typename G, typename EP, typename VP> template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) inline
std::pair<typename filtered_graph<G, EP, VP>::edge_descriptor, bool> std::pair<typename filtered_graph<G, EP, VP>::edge_descriptor, bool>
edge(typename filtered_graph<G, EP, VP>::vertex_descriptor u, edge(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
typename filtered_graph<G, EP, VP>::vertex_descriptor v, typename filtered_graph<G, EP, VP>::vertex_descriptor v,
......
...@@ -542,18 +542,18 @@ struct graph_property_type<adj_list<Vertex> > ...@@ -542,18 +542,18 @@ struct graph_property_type<adj_list<Vertex> >
//======================================================================== //========================================================================
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::vertex_iterator, std::pair<typename adj_list<Vertex>::vertex_iterator,
typename adj_list<Vertex>::vertex_iterator> typename adj_list<Vertex>::vertex_iterator>
vertices(const adj_list<Vertex>& g) vertices(const adj_list<Vertex>& g)
{ {
typedef typename adj_list<Vertex>::vertex_iterator vi_t; typedef typename adj_list<Vertex>::vertex_iterator vi_t;
return std::make_pair(vi_t(0), vi_t(g._out_edges.size())); return {vi_t(0), vi_t(g._out_edges.size())};
} }
template <class Vertex> template <class Vertex>
inline inline __attribute__((flatten))
std::pair<typename adj_list<Vertex>::edge_iterator, std::pair<typename adj_list<Vertex>::edge_iterator,
typename adj_list<Vertex>::edge_iterator> typename adj_list<Vertex>::edge_iterator>
edges(const adj_list<Vertex>& g) edges(const adj_list<Vertex>& g)
...@@ -580,7 +580,7 @@ edges(const adj_list<Vertex>& g) ...@@ -580,7 +580,7 @@ edges(const adj_list<Vertex>& g)
g._out_edges.end(), g._out_edges.end(),
last_vi, last_vi,
ei_end); ei_end);
return std::make_pair(ebegin, eend); return {ebegin, eend};
} }
template <class Vertex> template <class Vertex>
...@@ -600,10 +600,9 @@ edge(Vertex s, Vertex t, const adj_list<Vertex>& g) ...@@ -600,10 +600,9 @@ edge(Vertex s, Vertex t, const adj_list<Vertex>& g)
auto iter = std::find_if(oes.begin(), oes.end(), auto iter = std::find_if(oes.begin(), oes.end(),
[&](const auto& e) -> bool {return e.first == t;}); [&](const auto& e) -> bool {return e.first == t;});
if (iter != oes.end()) if (iter != oes.end())
return std::make_pair(edge_descriptor(s, t, iter->second, false), return {edge_descriptor(s, t, iter->second, false), true};
true);
Vertex v = graph_traits<adj_list<Vertex> >::null_vertex(); Vertex v = graph_traits<adj_list<Vertex> >::null_vertex();
return std::make_pair(edge_descriptor(v, v, v, false), false); return {edge_descriptor(v, v, v, false), false};
} }
template <class Vertex> template <class Vertex>
...@@ -628,55 +627,51 @@ size_t degree(Vertex v, const adj_list<Vertex>& g) ...@@ -628,55 +627,51 @@ size_t degree(Vertex v, const adj_list<Vertex>& g)
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::out_edge_iterator, std::pair<typename adj_list<Vertex>::out_edge_iterator,
typename adj_list<Vertex>::out_edge_iterator> typename adj_list<Vertex>::out_edge_iterator>
out_edges(Vertex v, const adj_list<Vertex>& g) out_edges(Vertex v, const adj_list<Vertex>& g)
{ {
typedef typename adj_list<Vertex>::out_edge_iterator ei_t; typedef typename adj_list<Vertex>::out_edge_iterator ei_t;
auto& edges = g._out_edges[v]; auto& edges = g._out_edges[v];
return std::make_pair(ei_t(v, edges.begin()), return {ei_t(v, edges.begin()), ei_t(v, edges.end())};
ei_t(v, edges.end()));
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::in_edge_iterator, std::pair<typename adj_list<Vertex>::in_edge_iterator,
typename adj_list<Vertex>::in_edge_iterator> typename adj_list<Vertex>::in_edge_iterator>
in_edges(Vertex v, const adj_list<Vertex>& g) in_edges(Vertex v, const adj_list<Vertex>& g)
{ {
typedef typename adj_list<Vertex>::in_edge_iterator ei_t; typedef typename adj_list<Vertex>::in_edge_iterator ei_t;
auto& edges = g._in_edges[v]; auto& edges = g._in_edges[v];
return std::make_pair(ei_t(v, edges.begin()), return {ei_t(v, edges.begin()), ei_t(v, edges.end())};
ei_t(v, edges.end()));
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::adjacency_iterator, std::pair<typename adj_list<Vertex>::adjacency_iterator,
typename adj_list<Vertex>::adjacency_iterator> typename adj_list<Vertex>::adjacency_iterator>
out_neighbours(Vertex v, const adj_list<Vertex>& g) out_neighbours(Vertex v, const adj_list<Vertex>& g)
{ {
typedef typename adj_list<Vertex>::adjacency_iterator ai_t; typedef typename adj_list<Vertex>::adjacency_iterator ai_t;
auto& edges = g._out_edges[v]; auto& edges = g._out_edges[v];
return std::make_pair(ai_t(edges.begin()), return {ai_t(edges.begin()), ai_t(edges.end())};
ai_t(edges.end()));
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::adjacency_iterator, std::pair<typename adj_list<Vertex>::adjacency_iterator,
typename adj_list<Vertex>::adjacency_iterator> typename adj_list<Vertex>::adjacency_iterator>
in_neighbours(Vertex v, const adj_list<Vertex>& g) in_neighbours(Vertex v, const adj_list<Vertex>& g)
{ {
typedef typename adj_list<Vertex>::adjacency_iterator ai_t; typedef typename adj_list<Vertex>::adjacency_iterator ai_t;
auto& edges = g._in_edges[v]; auto& edges = g._in_edges[v];
return std::make_pair(ai_t(edges.begin()), return {ai_t(edges.begin()), ai_t(edges.end())};
ai_t(edges.end()));
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename adj_list<Vertex>::adjacency_iterator, std::pair<typename adj_list<Vertex>::adjacency_iterator,
typename adj_list<Vertex>::adjacency_iterator> typename adj_list<Vertex>::adjacency_iterator>
adjacent_vertices(Vertex v, const adj_list<Vertex>& g) adjacent_vertices(Vertex v, const adj_list<Vertex>& g)
...@@ -700,7 +695,7 @@ size_t num_edges(const adj_list<Vertex>& g) ...@@ -700,7 +695,7 @@ size_t num_edges(const adj_list<Vertex>& g)
} }
template <class Vertex> template <class Vertex>
inline __attribute__((always_inline)) inline __attribute__((always_inline)) __attribute__((flatten))
Vertex add_vertex(adj_list<Vertex>& g) Vertex add_vertex(adj_list<Vertex>& g)
{ {
g._out_edges.emplace_back(); g._out_edges.emplace_back();
...@@ -709,7 +704,7 @@ Vertex add_vertex(adj_list<Vertex>& g) ...@@ -709,7 +704,7 @@ Vertex add_vertex(adj_list<Vertex>& g)
} }
template <class Vertex, class Pred> template <class Vertex, class Pred>
inline void clear_vertex(Vertex v, adj_list<Vertex>& g, Pred&& pred) void clear_vertex(Vertex v, adj_list<Vertex>& g, Pred&& pred)
{ {
if (!g._keep_epos) if (!g._keep_epos)
{ {
...@@ -798,7 +793,7 @@ inline void clear_vertex(Vertex v, adj_list<Vertex>& g, Pred&& pred) ...@@ -798,7 +793,7 @@ inline void clear_vertex(Vertex v, adj_list<Vertex>& g, Pred&& pred)
} }
template <class Vertex> template <class Vertex>
inline void clear_vertex(Vertex v, adj_list<Vertex>& g) void clear_vertex(Vertex v, adj_list<Vertex>& g)
{ {
clear_vertex(v, g, [](auto&&){ return true; }); clear_vertex(v, g, [](auto&&){ return true; });
} }
...@@ -806,7 +801,7 @@ inline void clear_vertex(Vertex v, adj_list<Vertex>& g) ...@@ -806,7 +801,7 @@ inline void clear_vertex(Vertex v, adj_list<Vertex>& g)
// O(V + E) // O(V + E)
template <class Vertex> template <class Vertex>
inline void remove_vertex(Vertex v, adj_list<Vertex>& g) void remove_vertex(Vertex v, adj_list<Vertex>& g)
{ {
clear_vertex(v, g); clear_vertex(v, g);
g._out_edges.erase(g._out_edges.begin() + v); g._out_edges.erase(g._out_edges.begin() + v);
...@@ -832,7 +827,7 @@ inline void remove_vertex(Vertex v, adj_list<Vertex>& g) ...@@ -832,7 +827,7 @@ inline void remove_vertex(Vertex v, adj_list<Vertex>& g)
// O(k + k_last) // O(k + k_last)
template <class Vertex> template <class Vertex>
inline void remove_vertex_fast(Vertex v, adj_list<Vertex>& g) void remove_vertex_fast(Vertex v, adj_list<Vertex>& g)
{ {
Vertex back = g._out_edges.size() - 1; Vertex back = g._out_edges.size() - 1;
...@@ -888,7 +883,6 @@ inline void remove_vertex_fast(Vertex v, adj_list<Vertex>& g) ...@@ -888,7 +883,6 @@ inline void remove_vertex_fast(Vertex v, adj_list<Vertex>& g)
} }
template <class Vertex> template <class Vertex>
inline
typename std::pair<typename adj_list<Vertex>::edge_descriptor, bool> typename std::pair<typename adj_list<Vertex>::edge_descriptor, bool>
add_edge(Vertex s, Vertex t, adj_list<Vertex>& g) add_edge(Vertex s, Vertex t, adj_list<Vertex>& g)
{ {
...@@ -919,12 +913,11 @@ add_edge(Vertex s, Vertex t, adj_list<Vertex>& g) ...@@ -919,12 +913,11 @@ add_edge(Vertex s, Vertex t, adj_list<Vertex>& g)
} }
typedef typename adj_list<Vertex>::edge_descriptor edge_descriptor; typedef typename adj_list<Vertex>::edge_descriptor edge_descriptor;
return std::make_pair(edge_descriptor(s, t, idx, false), true); return {edge_descriptor(s, t, idx, false), true};
} }
template <class Vertex> template <class Vertex>
inline void remove_edge(Vertex s, Vertex t, void remove_edge(Vertex s, Vertex t, adj_list<Vertex>& g)
adj_list<Vertex>& g)
{ {
if (!g._keep_epos) if (!g._keep_epos)
{ {
...@@ -955,8 +948,8 @@ inline void remove_edge(Vertex s, Vertex t, ...@@ -955,8 +948,8 @@ inline void remove_edge(Vertex s, Vertex t,
} }
template <class Vertex> template <class Vertex>
inline void remove_edge(const typename adj_list<Vertex>::edge_descriptor& e, void remove_edge(const typename adj_list<Vertex>::edge_descriptor& e,
adj_list<Vertex>& g) adj_list<Vertex>& g)
{ {
auto& s = e.s; auto& s = e.s;
auto& t = e.t; auto& t = e.t;
......
...@@ -661,7 +661,6 @@ public: ...@@ -661,7 +661,6 @@ public:
template <class Ks> template <class Ks>
double get_delta_deg_dl_dist_change(size_t v, size_t r, Ks& ks, int diff) double get_delta_deg_dl_dist_change(size_t v, size_t r, Ks& ks, int diff)
{ {
auto get_Se = [&](int delta, int kin, int kout) auto get_Se = [&](int delta, int kin, int kout)
{ {
double S = 0; double S = 0;
...@@ -920,6 +919,7 @@ public: ...@@ -920,6 +919,7 @@ public:
typedef typename graph_traits<BGraph>::vertex_descriptor vertex_t; typedef typename graph_traits<BGraph>::vertex_descriptor vertex_t;
typedef typename graph_traits<BGraph>::edge_descriptor edge_t; typedef typename graph_traits<BGraph>::edge_descriptor edge_t;
__attribute__((flatten))
const auto& get_me(vertex_t r, vertex_t s) const const auto& get_me(vertex_t r, vertex_t s) const
{ {
if (!is_directed::apply<BGraph>::type::value && r > s) if (!is_directed::apply<BGraph>::type::value && r > s)
...@@ -1009,6 +1009,7 @@ public: ...@@ -1009,6 +1009,7 @@ public:
} }
template <class... DVals> template <class... DVals>
__attribute__((flatten))
void insert_delta(size_t t, size_t s, DVals... delta) void insert_delta(size_t t, size_t s, DVals... delta)
{ {
insert_delta_imp(t, s, typename is_directed::apply<Graph>::type(), insert_delta_imp(t, s, typename is_directed::apply<Graph>::type(),
......
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