From 79c40126f3d7d0ba3e48a807ed33292e3ad0e16f Mon Sep 17 00:00:00 2001 From: PBerger Date: Tue, 24 Sep 2013 01:48:27 +0200 Subject: [PATCH] Fixed a bug in the SparseMatrix.h where the multi threaded implementation would crash sometimes Added a new definition to CMakeLists.txt for MSVC as to undefine the MIN/MAX macros Former-commit-id: 5a3d12e9203712edb04b6093a9e7a7fd7a595ee6 --- CMakeLists.txt | 2 ++ src/storage/SparseMatrix.h | 21 +++++++++++---------- src/utility/OsDetection.h | 6 +++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2095c18e..311fb0515 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,8 @@ elseif(MSVC) add_definitions(/bigobj) # required by GTest and PrismGrammar::createIntegerVariable add_definitions(/D_VARIADIC_MAX=10) + # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max + add_definitions(/DNOMINMAX) # MSVC does not do strict-aliasing, so no option needed else(CLANG) diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index d53a5ab97..25935c1fd 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -1,23 +1,24 @@ #ifndef STORM_STORAGE_SPARSEMATRIX_H_ #define STORM_STORAGE_SPARSEMATRIX_H_ -#include -#include -#include -#include -#include -#include -#include - // To detect whether the usage of TBB is possible, this include is neccessary #include "storm-config.h" #ifdef STORM_HAVE_INTELTBB -# include // This fixes a potential dependency ordering problem between GMM and TBB +# include "utility/OsDetection.h" // This fixes a potential dependency ordering problem between GMM and TBB +# include # include "tbb/tbb.h" # include #endif +#include +#include +#include +#include +#include +#include +#include + #include "src/exceptions/InvalidStateException.h" #include "src/exceptions/InvalidArgumentException.h" #include "src/exceptions/OutOfRangeException.h" @@ -1545,7 +1546,7 @@ private: tbbHelper_MatrixRowVectorScalarProduct(M const* matrixA, V const* vectorX, V * resultVector) : matrixA(matrixA), vectorX(vectorX), resultVector(resultVector) {} void operator() (const tbb::blocked_range& r) const { - for (uint_fast64_t row = r.begin(); row <= r.end(); ++row) { + for (uint_fast64_t row = r.begin(); row < r.end(); ++row) { uint_fast64_t index = matrixA->rowIndications.at(row); uint_fast64_t indexEnd = matrixA->rowIndications.at(row + 1); diff --git a/src/utility/OsDetection.h b/src/utility/OsDetection.h index 8fb6c7c6e..1969a6de7 100644 --- a/src/utility/OsDetection.h +++ b/src/utility/OsDetection.h @@ -19,7 +19,11 @@ # include // Required by storm.cpp, Memory Usage #elif defined _WIN32 || defined _WIN64 # define WINDOWS -# define NOMINMAX +# ifndef NOMINMAX +# define NOMINMAX +# undef min +# undef max +# endif # include # include # include