add tbb version guard to fix clang build
(cherry picked from commit 9b912f6b14d2cf715d17208df35b8253d5e648e7)release/4.3a0
parent
c9bcceef2f
commit
6ec13bdcd5
|
@ -200,6 +200,11 @@ find_package(TBB 4.4 COMPONENTS tbb tbbmalloc)
|
||||||
# Set up variables if we're using TBB
|
# Set up variables if we're using TBB
|
||||||
if(TBB_FOUND AND GTSAM_WITH_TBB)
|
if(TBB_FOUND AND GTSAM_WITH_TBB)
|
||||||
set(GTSAM_USE_TBB 1) # This will go into config.h
|
set(GTSAM_USE_TBB 1) # This will go into config.h
|
||||||
|
if (${TBB_VERSION_MAJOR} GREATER_EQUAL 2020)
|
||||||
|
set(TBB_GREATER_EQUAL_2020 1)
|
||||||
|
else()
|
||||||
|
set(TBB_GREATER_EQUAL_2020 0)
|
||||||
|
endif()
|
||||||
# all definitions and link requisites will go via imported targets:
|
# all definitions and link requisites will go via imported targets:
|
||||||
# tbb & tbbmalloc
|
# tbb & tbbmalloc
|
||||||
list(APPEND GTSAM_ADDITIONAL_LIBRARIES tbb tbbmalloc)
|
list(APPEND GTSAM_ADDITIONAL_LIBRARIES tbb tbbmalloc)
|
||||||
|
|
|
@ -51,7 +51,11 @@ namespace gtsam {
|
||||||
Key key;
|
Key key;
|
||||||
size_t n;
|
size_t n;
|
||||||
boost::tie(key, n) = v;
|
boost::tie(key, n) = v;
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
values_.emplace(key, x.segment(j, n));
|
values_.emplace(key, x.segment(j, n));
|
||||||
|
#else
|
||||||
|
values_.insert(std::make_pair(key, x.segment(j, n)));
|
||||||
|
#endif
|
||||||
j += n;
|
j += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +64,11 @@ namespace gtsam {
|
||||||
VectorValues::VectorValues(const Vector& x, const Scatter& scatter) {
|
VectorValues::VectorValues(const Vector& x, const Scatter& scatter) {
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (const SlotEntry& v : scatter) {
|
for (const SlotEntry& v : scatter) {
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
values_.emplace(v.key, x.segment(j, v.dimension));
|
values_.emplace(v.key, x.segment(j, v.dimension));
|
||||||
|
#else
|
||||||
|
values_.insert(std::make_pair(v.key, x.segment(j, v.dimension)));
|
||||||
|
#endif
|
||||||
j += v.dimension;
|
j += v.dimension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +78,11 @@ namespace gtsam {
|
||||||
{
|
{
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
for(const KeyValuePair& v: other)
|
for(const KeyValuePair& v: other)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(v.first, Vector::Zero(v.second.size()));
|
result.values_.emplace(v.first, Vector::Zero(v.second.size()));
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(v.first, Vector::Zero(v.second.size())));
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +98,11 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
VectorValues::iterator VectorValues::emplace(Key j, const Vector& value) {
|
VectorValues::iterator VectorValues::emplace(Key j, const Vector& value) {
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
std::pair<iterator, bool> result = values_.emplace(j, value);
|
std::pair<iterator, bool> result = values_.emplace(j, value);
|
||||||
|
#else
|
||||||
|
std::pair<iterator, bool> result = values_.insert(std::make_pair(j, value));
|
||||||
|
#endif
|
||||||
if(!result.second)
|
if(!result.second)
|
||||||
throw std::invalid_argument(
|
throw std::invalid_argument(
|
||||||
"Requested to emplace variable '" + DefaultKeyFormatter(j)
|
"Requested to emplace variable '" + DefaultKeyFormatter(j)
|
||||||
|
@ -266,7 +282,11 @@ namespace gtsam {
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
// The result.end() hint here should result in constant-time inserts
|
// The result.end() hint here should result in constant-time inserts
|
||||||
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(j1->first, j1->second + j2->second);
|
result.values_.emplace(j1->first, j1->second + j2->second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(j1->first, j1->second + j2->second));
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +344,11 @@ namespace gtsam {
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
// The result.end() hint here should result in constant-time inserts
|
// The result.end() hint here should result in constant-time inserts
|
||||||
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(j1->first, j1->second - j2->second);
|
result.values_.emplace(j1->first, j1->second - j2->second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(j1->first, j1->second - j2->second));
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +364,11 @@ namespace gtsam {
|
||||||
{
|
{
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
for(const VectorValues::KeyValuePair& key_v: v)
|
for(const VectorValues::KeyValuePair& key_v: v)
|
||||||
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
result.values_.emplace(key_v.first, a * key_v.second);
|
result.values_.emplace(key_v.first, a * key_v.second);
|
||||||
|
#else
|
||||||
|
result.values_.insert(std::make_pair(key_v.first, a * key_v.second));
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,11 @@ namespace gtsam {
|
||||||
* exist, it is inserted and an iterator pointing to the new element, along with 'true', is
|
* exist, it is inserted and an iterator pointing to the new element, along with 'true', is
|
||||||
* returned. */
|
* returned. */
|
||||||
std::pair<iterator, bool> tryInsert(Key j, const Vector& value) {
|
std::pair<iterator, bool> tryInsert(Key j, const Vector& value) {
|
||||||
return values_.emplace(j, value);
|
#ifdef TBB_GREATER_EQUAL_2020
|
||||||
|
return values_.emplace(j, value);
|
||||||
|
#else
|
||||||
|
return values_.insert(std::make_pair(j, value));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Erase the vector with the given key, or throw std::out_of_range if it does not exist */
|
/** Erase the vector with the given key, or throw std::out_of_range if it does not exist */
|
||||||
|
|
Loading…
Reference in New Issue