silence compiler warnings due to type mismatch (GeneralMatrixMatrix.h, Parallelizer.h)
Submitted by Jeff Hammond
Assigned to Nobody
Link to original bugzilla bug (#1369)
Description
I apologize for this, but I have not yet reminded myself how to use Mercurial. I have a trivial (four line) patch against the Github mirror, which anyone can reproduce in seconds.
See https://github.com/jeffhammond/eigen/commit/1f9f77b1dfa3a74ad81ac2b649a3740ac35ec1b2 or below (from git format-patch 50015ab88ef680617747a3c25e956064b07430a9 && cat 0001-silence-compiler-warnings-due-to-type-mismatch.patch) for details.
From 1f9f77b1dfa3a74ad81ac2b649a3740ac35ec1b2 Mon Sep 17 00:00:00 2001
From: Jeff Hammond jeff.science@gmail.com
Date: Wed, 21 Dec 2016 21:51:17 -0800
Subject: [PATCH] silence compiler warnings due to type mismatch
-
omp thread ids are always int, so the return values of
the associated runtime functions should be stored in
int values, not Index values. -
because sync and users are compared or stored to from Index,
they need to be Index, not int, because Index can (and is in my case)
a ptrdiff_t, which is a 64b type (when int is a 32b type).
It is not clear why Index is not an int, but presumably Eigen supports
matrices of rank greater than INT_MAX.
how inter-thread synchronization works, but that is a problem for
another day.
The use of volatile qualifier on sync suggests unsafe assumptions aboutEigen/src/Core/products/GeneralMatrixMatrix.h | 4 ++--
Eigen/src/Core/products/Parallelizer.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h
index 61df3be57..75e56ea22 100644
--- a/Eigen/src/Core/products/GeneralMatrixMatrix.h
+++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h
@@ -83,8 +83,8 @@ static void run(Index rows, Index cols, Index depth,
if(info)
{
// this is the parallel version!
- Index tid = omp_get_thread_num();
- Index threads = omp_get_num_threads();
-
int tid = omp_get_thread_num();
-
int threads = omp_get_num_threads();
LhsScalar* blockA = blocking.blockA();
eigen_internal_assert(blockA!=0);
diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h
index 2a31e4cbe..4b4ca669a 100644
--- a/Eigen/src/Core/products/Parallelizer.h
+++ b/Eigen/src/Core/products/Parallelizer.h
@@ -75,8 +75,8 @@ template<typename Index> struct GemmParallelInfo
{
GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}
- int volatile sync;
- int volatile users;
-
Index volatile sync;
-
Index volatile users;
Index lhs_start;
Index lhs_length;
--
2.11.0