Linkgraph: Enable MCF custom allocator only for GCC 4.9+
Earlier compilers don't use std::allocator_traits to query allocators.
This commit is contained in:
@@ -1413,6 +1413,11 @@ make_compiler_cflags() {
|
|||||||
flags="$flags -Wno-free-nonheap-object"
|
flags="$flags -Wno-free-nonheap-object"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $cc_version -ge 49 ]; then
|
||||||
|
# Enable use of C++11 custom allocators
|
||||||
|
CFLAGS="$CFLAGS -DCUSTOM_ALLOCATOR"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$enable_lto" != "0" ]; then
|
if [ "$enable_lto" != "0" ]; then
|
||||||
# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
|
# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
|
||||||
has_lto=`$1 -dumpspecs | grep '\%{flto'`
|
has_lto=`$1 -dumpspecs | grep '\%{flto'`
|
||||||
|
@@ -261,6 +261,7 @@ bool CapacityAnnotation::IsBetter(const CapacityAnnotation *base, uint cap,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CUSTOM_ALLOCATOR
|
||||||
/**
|
/**
|
||||||
* Storage for AnnoSetAllocator instances
|
* Storage for AnnoSetAllocator instances
|
||||||
*/
|
*/
|
||||||
@@ -334,6 +335,7 @@ struct AnnoSetAllocator {
|
|||||||
store.last_freed = p;
|
store.last_freed = p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation wrapper class which also stores an iterator to the AnnoSet node which points to this annotation
|
* Annotation wrapper class which also stores an iterator to the AnnoSet node which points to this annotation
|
||||||
@@ -341,7 +343,12 @@ struct AnnoSetAllocator {
|
|||||||
*/
|
*/
|
||||||
template<class Tannotation>
|
template<class Tannotation>
|
||||||
struct AnnosWrapper : public Tannotation {
|
struct AnnosWrapper : public Tannotation {
|
||||||
|
#ifdef CUSTOM_ALLOCATOR
|
||||||
typename std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator, AnnoSetAllocator<AnnoSetItem<Tannotation> > >::iterator self_iter;
|
typename std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator, AnnoSetAllocator<AnnoSetItem<Tannotation> > >::iterator self_iter;
|
||||||
|
#else
|
||||||
|
typename std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator>::iterator self_iter;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
AnnosWrapper(NodeID n, bool source = false) : Tannotation(n, source) {}
|
AnnosWrapper(NodeID n, bool source = false) : Tannotation(n, source) {}
|
||||||
};
|
};
|
||||||
@@ -358,11 +365,16 @@ struct AnnosWrapper : public Tannotation {
|
|||||||
template<class Tannotation, class Tedge_iterator>
|
template<class Tannotation, class Tedge_iterator>
|
||||||
void MultiCommodityFlow::Dijkstra(NodeID source_node, PathVector &paths)
|
void MultiCommodityFlow::Dijkstra(NodeID source_node, PathVector &paths)
|
||||||
{
|
{
|
||||||
|
#ifdef CUSTOM_ALLOCATOR
|
||||||
typedef std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator, AnnoSetAllocator<AnnoSetItem<Tannotation> > > AnnoSet;
|
typedef std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator, AnnoSetAllocator<AnnoSetItem<Tannotation> > > AnnoSet;
|
||||||
Tedge_iterator iter(this->job);
|
|
||||||
uint size = this->job.Size();
|
|
||||||
AnnoSetAllocatorStore annos_store;
|
AnnoSetAllocatorStore annos_store;
|
||||||
AnnoSet annos = AnnoSet(typename Tannotation::Comparator(), AnnoSetAllocator<Tannotation *>(annos_store));
|
AnnoSet annos = AnnoSet(typename Tannotation::Comparator(), AnnoSetAllocator<Tannotation *>(annos_store));
|
||||||
|
#else
|
||||||
|
typedef std::set<AnnoSetItem<Tannotation>, typename Tannotation::Comparator> AnnoSet;
|
||||||
|
AnnoSet annos = AnnoSet(typename Tannotation::Comparator());
|
||||||
|
#endif
|
||||||
|
Tedge_iterator iter(this->job);
|
||||||
|
uint size = this->job.Size();
|
||||||
paths.resize(size, NULL);
|
paths.resize(size, NULL);
|
||||||
for (NodeID node = 0; node < size; ++node) {
|
for (NodeID node = 0; node < size; ++node) {
|
||||||
AnnosWrapper<Tannotation> *anno = new AnnosWrapper<Tannotation>(node, node == source_node);
|
AnnosWrapper<Tannotation> *anno = new AnnosWrapper<Tannotation>(node, node == source_node);
|
||||||
|
Reference in New Issue
Block a user