8 changed files with 38 additions and 214 deletions
			
			
		- 
					2README.md
- 
					4src/storm-dft-cli/storm-dft.cpp
- 
					8src/storm-dft/api/storm-dft.h
- 
					48src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
- 
					138src/storm/solver/InPlaceMultiplier.cpp
- 
					41src/storm/solver/InPlaceMultiplier.h
- 
					1src/storm/solver/Multiplier.cpp
- 
					2src/test/storm-dft/api/DftModelCheckerTest.cpp
| @ -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<typename ValueType> | |||
|         InPlaceMultiplier<ValueType>::InPlaceMultiplier(storm::storage::SparseMatrix<ValueType> const& matrix) : Multiplier<ValueType>(matrix) { | |||
|             // Intentionally left empty.
 | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         bool InPlaceMultiplier<ValueType>::parallelize(Environment const& env) const { | |||
| #ifdef STORM_HAVE_INTELTBB
 | |||
|             return storm::settings::getModule<storm::settings::modules::CoreSettings>().isUseIntelTbbSet(); | |||
| #else
 | |||
|             return false; | |||
| #endif
 | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiply(Environment const& env, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const { | |||
|             std::vector<ValueType>* target = &result; | |||
|             if (&x == &result) { | |||
|                 if (this->cachedVector) { | |||
|                     this->cachedVector->resize(x.size()); | |||
|                 } else { | |||
|                     this->cachedVector = std::make_unique<std::vector<ValueType>>(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<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiplyGaussSeidel(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const* b) const { | |||
|             this->matrix.multiplyWithVectorBackward(x, x, b); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint_fast64_t>* choices) const { | |||
|             std::vector<ValueType>* target = &result; | |||
|             if (&x == &result) { | |||
|                 if (this->cachedVector) { | |||
|                     this->cachedVector->resize(x.size()); | |||
|                 } else { | |||
|                     this->cachedVector = std::make_unique<std::vector<ValueType>>(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<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType>& x, std::vector<ValueType> const* b, std::vector<uint_fast64_t>* choices) const { | |||
|             this->matrix.multiplyAndReduceBackward(dir, rowGroupIndices, x, b, x, choices); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiplyRow(uint64_t const& rowIndex, std::vector<ValueType> const& x, ValueType& value) const { | |||
|             for (auto const& entry : this->matrix.getRow(rowIndex)) { | |||
|                 value += entry.getValue() * x[entry.getColumn()]; | |||
|             } | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multiplyRow2(uint64_t const& rowIndex, std::vector<ValueType> const& x1, ValueType& val1, std::vector<ValueType> 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<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multAdd(std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const { | |||
|             this->matrix.multiplyWithVector(x, result, b); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices) const { | |||
|             this->matrix.multiplyAndReduce(dir, rowGroupIndices, x, b, result, choices); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multAddParallel(std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& 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<typename ValueType> | |||
|         void InPlaceMultiplier<ValueType>::multAddReduceParallel(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* 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<double>; | |||
| #ifdef STORM_HAVE_CARL
 | |||
|         template class InPlaceMultiplier<storm::RationalNumber>; | |||
|         template class InPlaceMultiplier<storm::RationalFunction>; | |||
| #endif
 | |||
|          | |||
|     } | |||
| } | |||
| @ -1,41 +0,0 @@ | |||
| #pragma once | |||
| 
 | |||
| #include "storm/solver/Multiplier.h" | |||
| 
 | |||
| #include "storm/solver/OptimizationDirection.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|         template<typename ValueType> | |||
|         class SparseMatrix; | |||
|     } | |||
|      | |||
|     namespace solver { | |||
|          | |||
|         template<typename ValueType> | |||
|         class InPlaceMultiplier : public Multiplier<ValueType> { | |||
|         public: | |||
|             InPlaceMultiplier(storm::storage::SparseMatrix<ValueType> const& matrix); | |||
|              | |||
|             virtual void multiply(Environment const& env, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const override; | |||
|             virtual void multiplyGaussSeidel(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const* b) const override; | |||
|             virtual void multiplyAndReduce(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint_fast64_t>* choices = nullptr) const override; | |||
|             virtual void multiplyAndReduceGaussSeidel(Environment const& env, OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType>& x, std::vector<ValueType> const* b, std::vector<uint_fast64_t>* choices = nullptr) const override; | |||
|             virtual void multiplyRow(uint64_t const& rowIndex, std::vector<ValueType> const& x, ValueType& value) const override; | |||
|             virtual void multiplyRow2(uint64_t const& rowIndex, std::vector<ValueType> const& x1, ValueType& val1, std::vector<ValueType> const& x2, ValueType& val2) const override; | |||
| 
 | |||
| 
 | |||
|         private: | |||
|             bool parallelize(Environment const& env) const; | |||
|              | |||
|             void multAdd(std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result) const; | |||
|              | |||
|             void multAddReduce(storm::solver::OptimizationDirection const& dir, std::vector<uint64_t> const& rowGroupIndices, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices = nullptr) const; | |||
|              | |||
|             void multAddParallel(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, std::vector<ValueType> const& x, std::vector<ValueType> const* b, std::vector<ValueType>& result, std::vector<uint64_t>* choices = nullptr) const; | |||
|              | |||
|         }; | |||
|          | |||
|     } | |||
| } | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue