From 51e08bb1a5f8bf941a101c079c3527610c9a7af7 Mon Sep 17 00:00:00 2001 From: TimQu Date: Fri, 23 Mar 2018 09:31:03 +0100 Subject: [PATCH] removed old inPlaceMultiplier --- src/storm/solver/InPlaceMultiplier.cpp | 138 ------------------------- src/storm/solver/InPlaceMultiplier.h | 41 -------- src/storm/solver/Multiplier.cpp | 1 - 3 files changed, 180 deletions(-) delete mode 100644 src/storm/solver/InPlaceMultiplier.cpp delete mode 100644 src/storm/solver/InPlaceMultiplier.h diff --git a/src/storm/solver/InPlaceMultiplier.cpp b/src/storm/solver/InPlaceMultiplier.cpp deleted file mode 100644 index abfd4463a..000000000 --- a/src/storm/solver/InPlaceMultiplier.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "storm/solver/InPlaceMultiplier.h" - -#include "storm-config.h" - -#include "storm/environment/solver/MultiplierEnvironment.h" -#include "storm/settings/SettingsManager.h" -#include "storm/settings/modules/CoreSettings.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 - InPlaceMultiplier::InPlaceMultiplier(storm::storage::SparseMatrix const& matrix) : Multiplier(matrix) { - // Intentionally left empty. - } - - template - bool InPlaceMultiplier::parallelize(Environment const& env) const { -#ifdef STORM_HAVE_INTELTBB - return storm::settings::getModule().isUseIntelTbbSet(); -#else - return false; -#endif - } - - template - void InPlaceMultiplier::multiply(Environment const& env, std::vector const& x, std::vector const* b, std::vector& result) const { - std::vector* target = &result; - if (&x == &result) { - if (this->cachedVector) { - this->cachedVector->resize(x.size()); - } else { - this->cachedVector = std::make_unique>(x.size()); - } - target = this->cachedVector.get(); - } - if (parallelize(env)) { - multAddParallel(x, b, *target); - } else { - multAdd(x, b, *target); - } - if (&x == &result) { - std::swap(result, *this->cachedVector); - } - } - - template - void InPlaceMultiplier::multiplyGaussSeidel(Environment const& env, std::vector& x, std::vector const* b) const { - this->matrix.multiplyWithVectorBackward(x, x, b); - } - - template - void InPlaceMultiplier::multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices) const { - std::vector* target = &result; - if (&x == &result) { - if (this->cachedVector) { - this->cachedVector->resize(x.size()); - } else { - this->cachedVector = std::make_unique>(x.size()); - } - target = this->cachedVector.get(); - } - if (parallelize(env)) { - multAddReduceParallel(dir, rowGroupIndices, x, b, *target, choices); - } else { - multAddReduce(dir, rowGroupIndices, x, b, *target, choices); - } - if (&x == &result) { - std::swap(result, *this->cachedVector); - } - } - - template - void InPlaceMultiplier::multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector& x, std::vector const* b, std::vector* choices) const { - this->matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices); - } - - template - void InPlaceMultiplier::multiplyRow(uint64_t const& rowIndex, std::vector const& x, ValueType& value) const { - for (auto const& entry : this->matrix.getRow(rowIndex)) { - value += entry.getValue() * x[entry.getColumn()]; - } - } - - template - void InPlaceMultiplier::multiplyRow2(uint64_t const& rowIndex, std::vector const& x1, ValueType& val1, std::vector const& x2, ValueType& val2) const { - for (auto const& entry : this->matrix.getRow(rowIndex)) { - val1 += entry.getValue() * x1[entry.getColumn()]; - val2 += entry.getValue() * x2[entry.getColumn()]; - } - } - - - template - void InPlaceMultiplier::multAdd(std::vector const& x, std::vector const* b, std::vector& result) const { - this->matrix.multiplyWithVector(x, result, b); - } - - template - void InPlaceMultiplier::multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices) const { - this->matrix.multiplyAndReduce(dir, rowGroupIndices, x, b, result, choices); - } - - template - void InPlaceMultiplier::multAddParallel(std::vector const& x, std::vector const* b, std::vector& result) const { -#ifdef STORM_HAVE_INTELTBB - this->matrix.multiplyWithVectorParallel(x, result, b); -#else - STORM_LOG_WARN("Storm was built without support for Intel TBB, defaulting to sequential version."); - multAdd(x, b, result); -#endif - } - - template - void InPlaceMultiplier::multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices) const { -#ifdef STORM_HAVE_INTELTBB - this->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 InPlaceMultiplier; -#ifdef STORM_HAVE_CARL - template class InPlaceMultiplier; - template class InPlaceMultiplier; -#endif - - } -} diff --git a/src/storm/solver/InPlaceMultiplier.h b/src/storm/solver/InPlaceMultiplier.h deleted file mode 100644 index d02c74bfb..000000000 --- a/src/storm/solver/InPlaceMultiplier.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "storm/solver/Multiplier.h" - -#include "storm/solver/OptimizationDirection.h" - -namespace storm { - namespace storage { - template - class SparseMatrix; - } - - namespace solver { - - template - class InPlaceMultiplier : public Multiplier { - public: - InPlaceMultiplier(storm::storage::SparseMatrix const& matrix); - - virtual void multiply(Environment const& env, std::vector const& x, std::vector const* b, std::vector& result) const override; - virtual void multiplyGaussSeidel(Environment const& env, std::vector& x, std::vector const* b) const override; - virtual void multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices = nullptr) const override; - virtual void multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector& x, std::vector const* b, std::vector* choices = nullptr) const override; - virtual void multiplyRow(uint64_t const& rowIndex, std::vector const& x, ValueType& value) const override; - virtual void multiplyRow2(uint64_t const& rowIndex, std::vector const& x1, ValueType& val1, std::vector const& x2, ValueType& val2) const override; - - - private: - bool parallelize(Environment const& env) const; - - void multAdd(std::vector const& x, std::vector const* b, std::vector& result) const; - - void multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices = nullptr) const; - - void multAddParallel(std::vector const& x, std::vector const* b, std::vector& result) const; - void multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector const& rowGroupIndices, std::vector const& x, std::vector const* b, std::vector& result, std::vector* choices = nullptr) const; - - }; - - } -} diff --git a/src/storm/solver/Multiplier.cpp b/src/storm/solver/Multiplier.cpp index 0da52a06a..26bb4d85b 100644 --- a/src/storm/solver/Multiplier.cpp +++ b/src/storm/solver/Multiplier.cpp @@ -11,7 +11,6 @@ #include "storm/solver/SolverSelectionOptions.h" #include "storm/solver/NativeMultiplier.h" #include "storm/solver/GmmxxMultiplier.h" -#include "storm/solver/InPlaceMultiplier.h" #include "storm/environment/solver/MultiplierEnvironment.h" namespace storm {