dehnert
7 years ago
21 changed files with 884 additions and 384 deletions
-
84resources/3rdparty/gmm-5.2/include/gmm/gmm_blas.h
-
116src/storm/adapters/GmmxxAdapter.cpp
-
19src/storm/adapters/GmmxxAdapter.h
-
18src/storm/settings/modules/CoreSettings.cpp
-
11src/storm/settings/modules/CoreSettings.h
-
11src/storm/solver/GmmxxLinearEquationSolver.cpp
-
8src/storm/solver/GmmxxLinearEquationSolver.h
-
221src/storm/solver/GmmxxMultiplier.cpp
-
31src/storm/solver/GmmxxMultiplier.h
-
2src/storm/solver/LinearEquationSolver.cpp
-
5src/storm/solver/LinearEquationSolver.h
-
21src/storm/solver/NativeLinearEquationSolver.cpp
-
11src/storm/solver/NativeLinearEquationSolver.h
-
101src/storm/solver/NativeMultiplier.cpp
-
31src/storm/solver/NativeMultiplier.h
-
2src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp
-
254src/storm/storage/SparseMatrix.cpp
-
42src/storm/storage/SparseMatrix.h
-
57src/storm/utility/VectorHelper.cpp
-
25src/storm/utility/VectorHelper.h
-
198src/storm/utility/vector.h
@ -0,0 +1,221 @@ |
|||
#include "storm/solver/GmmxxMultiplier.h"
|
|||
|
|||
#include "storm/adapters/RationalNumberAdapter.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/exceptions/NotSupportedException.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
|
|||
template<typename T> |
|||
GmmxxMultiplier<T>::GmmxxMultiplier() : storm::utility::VectorHelper<T>() { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAdd(gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result) const { |
|||
if (this->parallelize()) { |
|||
multAddParallel(matrix, x, b, result); |
|||
} else { |
|||
if (b) { |
|||
gmm::mult_add(matrix, x, *b, result); |
|||
} else { |
|||
gmm::mult(matrix, x, result); |
|||
} |
|||
} |
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddGaussSeidelBackward(gmm::csr_matrix<T> const& matrix, std::vector<T>& x, std::vector<T> const* b) const { |
|||
STORM_LOG_ASSERT(matrix.nr == matrix.nc, "Expecting square matrix."); |
|||
if (b) { |
|||
gmm::mult_add_by_row_bwd(matrix, x, *b, x, gmm::abstract_dense()); |
|||
} else { |
|||
gmm::mult_by_row_bwd(matrix, x, x, gmm::abstract_dense()); |
|||
} |
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices) const { |
|||
std::vector<T>* target = &result; |
|||
std::unique_ptr<std::vector<T>> temporary; |
|||
if (&x == &result) { |
|||
STORM_LOG_WARN("Using temporary in 'multAddReduce'."); |
|||
temporary = std::make_unique<std::vector<T>>(x.size()); |
|||
target = temporary.get(); |
|||
} |
|||
|
|||
if (this->parallelize()) { |
|||
multAddReduceParallel(dir, rowGroupIndices, matrix, x, b, *target, choices); |
|||
} else { |
|||
multAddReduceHelper(dir, rowGroupIndices, matrix, x, b, *target, choices); |
|||
} |
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddReduceGaussSeidel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T>& x, std::vector<T> const* b, std::vector<uint64_t>* choices) const { |
|||
multAddReduceHelper(dir, rowGroupIndices, matrix, x, b, x, choices); |
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddReduceHelper(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices) const { |
|||
typedef std::vector<T> VectorType; |
|||
typedef gmm::csr_matrix<T> MatrixType; |
|||
|
|||
typename gmm::linalg_traits<VectorType>::const_iterator add_it, add_ite; |
|||
if (b) { |
|||
add_it = gmm::vect_end(*b) - 1; |
|||
add_ite = gmm::vect_begin(*b) - 1; |
|||
} |
|||
typename gmm::linalg_traits<VectorType>::iterator target_it = gmm::vect_end(result) - 1; |
|||
typename gmm::linalg_traits<MatrixType>::const_row_iterator itr = mat_row_const_end(matrix) - 1; |
|||
typename std::vector<uint64_t>::iterator choice_it; |
|||
if (choices) { |
|||
choice_it = choices->end() - 1; |
|||
} |
|||
|
|||
uint64_t choice; |
|||
for (auto row_group_it = rowGroupIndices.end() - 2, row_group_ite = rowGroupIndices.begin() - 1; row_group_it != row_group_ite; --row_group_it, --choice_it, --target_it) { |
|||
T currentValue = b ? *add_it : storm::utility::zero<T>(); |
|||
currentValue += vect_sp(gmm::linalg_traits<MatrixType>::row(itr), x); |
|||
|
|||
if (choices) { |
|||
choice = *(row_group_it + 1) - 1 - *row_group_it; |
|||
*choice_it = choice; |
|||
} |
|||
|
|||
--itr; |
|||
if (b) { |
|||
--add_it; |
|||
} |
|||
|
|||
for (uint64_t row = *row_group_it + 1, rowEnd = *(row_group_it + 1); row < rowEnd; ++row, --itr) { |
|||
T newValue = b ? *add_it : storm::utility::zero<T>(); |
|||
newValue += vect_sp(gmm::linalg_traits<MatrixType>::row(itr), x); |
|||
|
|||
if (choices) { |
|||
--choice; |
|||
} |
|||
|
|||
if ((dir == OptimizationDirection::Minimize && newValue < currentValue) || (dir == OptimizationDirection::Maximize && newValue > currentValue)) { |
|||
currentValue = newValue; |
|||
if (choices) { |
|||
*choice_it = choice; |
|||
} |
|||
} |
|||
if (b) { |
|||
--add_it; |
|||
} |
|||
} |
|||
|
|||
// Write back final value.
|
|||
*target_it = currentValue; |
|||
} |
|||
} |
|||
|
|||
template<> |
|||
void GmmxxMultiplier<storm::RationalFunction>::multAddReduceHelper(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<storm::RationalFunction> const& matrix, std::vector<storm::RationalFunction> const& x, std::vector<storm::RationalFunction> const* b, std::vector<storm::RationalFunction>& result, std::vector<uint64_t>* choices) const { |
|||
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Operation not supported for this data type."); |
|||
} |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddParallel(gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result) const { |
|||
#ifdef STORM_HAVE_INTELTBB
|
|||
if (b) { |
|||
gmm::mult_add_parallel(matrix, x, *b, result); |
|||
} else { |
|||
gmm::mult_parallel(matrix, x, result); |
|||
} |
|||
#else
|
|||
STORM_LOG_WARN("Storm was built without support for Intel TBB, defaulting to sequential version."); |
|||
multAdd(matrix, x, b, result); |
|||
#endif
|
|||
} |
|||
|
|||
template<typename T> |
|||
class TbbMultAddReduceFunctor { |
|||
public: |
|||
TbbMultAddReduceFunctor(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices) : dir(dir), rowGroupIndices(rowGroupIndices), matrix(matrix), x(x), b(b), result(result), choices(choices) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
void operator()(tbb::blocked_range<unsigned long> const& range) const { |
|||
auto groupIt = rowGroupIndices.begin() + range.begin(); |
|||
auto groupIte = rowGroupIndices.begin() + range.end(); |
|||
|
|||
auto itr = mat_row_const_begin(matrix) + *groupIt; |
|||
typename std::vector<T>::const_iterator bIt; |
|||
if (b) { |
|||
bIt = b->begin() + *groupIt; |
|||
} |
|||
typename std::vector<uint64_t>::iterator choiceIt; |
|||
if (choices) { |
|||
choiceIt = choices->begin() + range.begin(); |
|||
} |
|||
|
|||
auto resultIt = result.begin() + range.begin(); |
|||
|
|||
for (; groupIt != groupIte; ++groupIt, ++resultIt, ++choiceIt) { |
|||
T currentValue = vect_sp(gmm::linalg_traits<gmm::csr_matrix<T>>::row(itr), x, typename gmm::linalg_traits<gmm::csr_matrix<T>>::storage_type(), typename gmm::linalg_traits<std::vector<T>>::storage_type()); |
|||
if (b) { |
|||
currentValue += *bIt; |
|||
++bIt; |
|||
} |
|||
if (choices) { |
|||
*choiceIt = 0; |
|||
} |
|||
|
|||
++itr; |
|||
|
|||
for (auto itre = mat_row_const_begin(matrix) + *(groupIt + 1); itr != itre; ++itr) { |
|||
T newValue = vect_sp(gmm::linalg_traits<gmm::csr_matrix<T>>::row(itr), x, typename gmm::linalg_traits<gmm::csr_matrix<T>>::storage_type(), typename gmm::linalg_traits<std::vector<T>>::storage_type()); |
|||
if (b) { |
|||
newValue += *bIt; |
|||
++bIt; |
|||
} |
|||
|
|||
if ((dir == OptimizationDirection::Minimize && newValue < currentValue) || (dir == OptimizationDirection::Maximize && newValue > currentValue)) { |
|||
currentValue = newValue; |
|||
if (choices) { |
|||
*choiceIt = std::distance(mat_row_const_begin(matrix), itr) - *groupIt; |
|||
} |
|||
} |
|||
} |
|||
|
|||
*resultIt = currentValue; |
|||
} |
|||
} |
|||
|
|||
private: |
|||
storm::solver::OptimizationDirection dir; |
|||
std::vector<uint64_t> const& rowGroupIndices; |
|||
gmm::csr_matrix<T> const& matrix; |
|||
std::vector<T> const& x; |
|||
std::vector<T> const* b; |
|||
std::vector<T>& result; |
|||
std::vector<uint64_t>* choices; |
|||
}; |
|||
|
|||
template<typename T> |
|||
void GmmxxMultiplier<T>::multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices) const { |
|||
tbb::parallel_for(tbb::blocked_range<unsigned long>(0, rowGroupIndices.size() - 1, 10), TbbMultAddReduceFunctor<T>(dir, rowGroupIndices, matrix, x, b, result, choices)); |
|||
} |
|||
|
|||
template<> |
|||
void GmmxxMultiplier<storm::RationalFunction>::multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<storm::RationalFunction> const& matrix, std::vector<storm::RationalFunction> const& x, std::vector<storm::RationalFunction> const* b, std::vector<storm::RationalFunction>& result, std::vector<uint64_t>* choices) const { |
|||
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "This operation is not supported."); |
|||
} |
|||
|
|||
template class GmmxxMultiplier<double>; |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class GmmxxMultiplier<storm::RationalNumber>; |
|||
template class GmmxxMultiplier<storm::RationalFunction>; |
|||
#endif
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/utility/VectorHelper.h" |
|||
|
|||
#include "storm/adapters/GmmxxAdapter.h" |
|||
|
|||
#include "storm-config.h" |
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
|
|||
template<class T> |
|||
class GmmxxMultiplier : public storm::utility::VectorHelper<T> { |
|||
public: |
|||
GmmxxMultiplier(); |
|||
|
|||
void multAdd(gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result) const; |
|||
void multAddGaussSeidelBackward(gmm::csr_matrix<T> const& matrix, std::vector<T>& x, std::vector<T> const* b) const; |
|||
|
|||
void multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices = nullptr) const; |
|||
void multAddReduceGaussSeidel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T>& x, std::vector<T> const* b, std::vector<uint64_t>* choices = nullptr) const; |
|||
|
|||
void multAddParallel(gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result) const; |
|||
void multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices = nullptr) const; |
|||
|
|||
private: |
|||
void multAddReduceHelper(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, gmm::csr_matrix<T> const& matrix, std::vector<T> const& x, std::vector<T> const* b, std::vector<T>& result, std::vector<uint64_t>* choices = nullptr) const; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,101 @@ |
|||
#include "storm/solver/NativeMultiplier.h"
|
|||
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "storm/storage/SparseMatrix.h"
|
|||
|
|||
#include "storm/adapters/RationalNumberAdapter.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
|
|||
template<typename ValueType> |
|||
NativeMultiplier<ValueType>::NativeMultiplier() : storm::utility::VectorHelper<ValueType>() { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAdd(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const { |
|||
std::vector<ValueType>* target = &result; |
|||
std::unique_ptr<std::vector<ValueType>> temporary; |
|||
if (&x == &result) { |
|||
STORM_LOG_WARN("Using temporary in 'multAdd'."); |
|||
temporary = std::make_unique<std::vector<ValueType>>(x.size()); |
|||
target = temporary.get(); |
|||
} |
|||
|
|||
if (this->parallelize()) { |
|||
multAddParallel(matrix, x, b, result); |
|||
} else { |
|||
matrix.multiplyWithVector(x, result, b); |
|||
} |
|||
|
|||
if (target == temporary.get()) { |
|||
std::swap(result, *temporary); |
|||
} |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAddGaussSeidelBackward(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType>& x, std::vector<ValueType> const* b) const { |
|||
matrix.multiplyWithVectorBackward(x, x, b); |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices) const { |
|||
std::vector<ValueType>* target = &result; |
|||
std::unique_ptr<std::vector<ValueType>> temporary; |
|||
if (&x == &result) { |
|||
STORM_LOG_WARN("Using temporary in 'multAddReduce'."); |
|||
temporary = std::make_unique<std::vector<ValueType>>(x.size()); |
|||
target = temporary.get(); |
|||
} |
|||
|
|||
if (this->parallelize()) { |
|||
multAddReduceParallel(dir, rowGroupIndices, matrix, x, b, *target, choices); |
|||
} else { |
|||
matrix.multiplyAndReduce(dir, rowGroupIndices, x, b, *target, choices); |
|||
} |
|||
|
|||
if (target == temporary.get()) { |
|||
std::swap(result, *temporary); |
|||
} |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAddReduceGaussSeidelBackward(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType>& x, std::vector<ValueType> const* b, std::vector<uint64_t>* choices) const { |
|||
matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices); |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAddParallel(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const { |
|||
#ifdef STORM_HAVE_INTELTBB
|
|||
matrix.multiplyWithVectorParallel(x, result, b); |
|||
#else
|
|||
STORM_LOG_WARN("Storm was built without support for Intel TBB, defaulting to sequential version."); |
|||
multAdd(matrix, x, b, result); |
|||
#endif
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NativeMultiplier<ValueType>::multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices) const { |
|||
#ifdef STORM_HAVE_INTELTBB
|
|||
matrix.multiplyAndReduceParallel(dir, rowGroupIndices, x, b, result, choices); |
|||
#else
|
|||
STORM_LOG_WARN("Storm was built without support for Intel TBB, defaulting to sequential version."); |
|||
multAddReduce(dir, rowGroupIndices, x, b, result, choices); |
|||
#endif
|
|||
} |
|||
|
|||
|
|||
template class NativeMultiplier<double>; |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class NativeMultiplier<storm::RationalNumber>; |
|||
template class NativeMultiplier<storm::RationalFunction>; |
|||
#endif
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/utility/VectorHelper.h" |
|||
|
|||
#include "storm/solver/OptimizationDirection.h" |
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
template<typename ValueType> |
|||
class SparseMatrix; |
|||
} |
|||
|
|||
namespace solver { |
|||
|
|||
template<typename ValueType> |
|||
class NativeMultiplier : public storm::utility::VectorHelper<ValueType> { |
|||
public: |
|||
NativeMultiplier(); |
|||
|
|||
void multAdd(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const; |
|||
void multAddGaussSeidelBackward(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType>& x, std::vector<ValueType> const* b) const; |
|||
|
|||
void multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices = nullptr) const; |
|||
void multAddReduceGaussSeidelBackward(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType>& x, std::vector<ValueType> const* b, std::vector<uint64_t>* choices = nullptr) const; |
|||
|
|||
void multAddParallel(storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const; |
|||
void multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, storm::storage::SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices = nullptr) const; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
#include "storm/utility/VectorHelper.h"
|
|||
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/CoreSettings.h"
|
|||
|
|||
#include "storm/adapters/RationalNumberAdapter.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "storm/utility/vector.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
#include "storm/exceptions/InvalidSettingsException.h"
|
|||
#include "storm/exceptions/NotSupportedException.h"
|
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
template<typename ValueType> |
|||
VectorHelper<ValueType>::VectorHelper() : doParallelize(storm::settings::getModule<storm::settings::modules::CoreSettings>().isUseIntelTbbSet()) { |
|||
#ifndef STORM_HAVE_INTELTBB
|
|||
STORM_LOG_THROW(!parallelize, storm::exceptions::InvalidSettingsException, "Cannot parallelize without TBB."); |
|||
#endif
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
bool VectorHelper<ValueType>::parallelize() const { |
|||
return doParallelize; |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void VectorHelper<ValueType>::reduceVector(storm::solver::OptimizationDirection dir, std::vector<ValueType> const& source, std::vector<ValueType>& target, std::vector<uint_fast64_t> const& rowGrouping, std::vector<uint_fast64_t>* choices) const { |
|||
#ifdef STORM_HAVE_INTELTBB
|
|||
if (this->parallelize()) { |
|||
storm::utility::vector::reduceVectorMinOrMaxParallel(dir, source, target, rowGrouping, choices); |
|||
} else { |
|||
storm::utility::vector::reduceVectorMinOrMax(dir, source, target, rowGrouping, choices); |
|||
} |
|||
#else
|
|||
storm::utility::vector::reduceVectorMinOrMax(dir, source, target, rowGrouping, choices); |
|||
#endif
|
|||
} |
|||
|
|||
template<> |
|||
void VectorHelper<storm::RationalFunction>::reduceVector(storm::solver::OptimizationDirection dir, std::vector<storm::RationalFunction> const& source, std::vector<storm::RationalFunction>& target, std::vector<uint_fast64_t> const& rowGrouping, std::vector<uint_fast64_t>* choices) const { |
|||
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "This operation is not supported."); |
|||
} |
|||
|
|||
template class VectorHelper<double>; |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class VectorHelper<storm::RationalNumber>; |
|||
template class VectorHelper<storm::RationalFunction>; |
|||
#endif
|
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
#pragma once |
|||
|
|||
#include <vector> |
|||
#include <cstdint> |
|||
|
|||
#include "storm/solver/OptimizationDirection.h" |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
template<typename ValueType> |
|||
class VectorHelper { |
|||
public: |
|||
VectorHelper(); |
|||
|
|||
void reduceVector(storm::solver::OptimizationDirection dir, std::vector<ValueType> const& source, std::vector<ValueType>& target, std::vector<uint_fast64_t> const& rowGrouping, std::vector<uint_fast64_t>* choices = nullptr) const; |
|||
|
|||
bool parallelize() const; |
|||
|
|||
private: |
|||
// A flag that stores whether the parallelization to be used. |
|||
bool doParallelize; |
|||
}; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue