[clblas] 41/75: Revert "fixed compareMatrices to use GTEST_FLOAT_EQ"

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jan 24 23:30:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository clblas.

commit be56a613dca5462eb569dc0072769fb4da0cce7e
Author: Kent Knox <kent.knox at amd>
Date:   Wed Apr 13 13:20:36 2016 -0500

    Revert "fixed compareMatrices to use GTEST_FLOAT_EQ"
    
    This reverts commit 8491085874c29f2fbc4b5a1d8f70bc3e15b1f87a.
---
 src/tests/common.cpp       |  21 -----
 src/tests/include/common.h |   4 -
 src/tests/include/matrix.h | 217 +++++++++++++++++++++++++++++++++++++++------
 3 files changed, 191 insertions(+), 51 deletions(-)

diff --git a/src/tests/common.cpp b/src/tests/common.cpp
index 209a598..d0f21ba 100644
--- a/src/tests/common.cpp
+++ b/src/tests/common.cpp
@@ -18,7 +18,6 @@
 #include <iostream>
 #include <string.h>
 #include <clBLAS.h>
-#include <gtest/gtest.h>
 
 #include <common.h>
 
@@ -1017,23 +1016,3 @@ functionBlasLevel(BlasFunctionID funct) {
         return 0;
     }
 }
-
-
-template<>
-void gtestAssertElementsEqual( const float & a, const float & b) {
-  ASSERT_FLOAT_EQ(a, b);
-}
-template<>
-void gtestAssertElementsEqual( const double & a, const double & b) {
-  ASSERT_DOUBLE_EQ(a, b);
-}
-template<>
-void gtestAssertElementsEqual( const FloatComplex & a, const FloatComplex & b) {
-  ASSERT_FLOAT_EQ(CREAL(a), CREAL(b));
-  ASSERT_FLOAT_EQ(CIMAG(a), CIMAG(b));
-}
-template<>
-void gtestAssertElementsEqual( const DoubleComplex & a, const DoubleComplex & b) {
-  ASSERT_DOUBLE_EQ(CREAL(a), CREAL(b));
-  ASSERT_DOUBLE_EQ(CIMAG(a), CIMAG(b));
-}
\ No newline at end of file
diff --git a/src/tests/include/common.h b/src/tests/include/common.h
index 52f71b1..edbdb43 100644
--- a/src/tests/include/common.h
+++ b/src/tests/include/common.h
@@ -692,10 +692,6 @@ printTestParams(
     size_t offx,
     int incx);
 
-
-template<typename T>
-void gtestAssertElementsEqual( const T & a, const T & b);
-
 #endif  // __cplusplus
 
 #endif  /* COMMON_H_ */
diff --git a/src/tests/include/matrix.h b/src/tests/include/matrix.h
index ad84994..65757ad 100644
--- a/src/tests/include/matrix.h
+++ b/src/tests/include/matrix.h
@@ -298,7 +298,6 @@ reorderMatrix(
     }
 }
 
-
 template <typename T>
 static void
 compareMatrices(
@@ -316,42 +315,208 @@ compareMatrices(
 
     if( lda > 0 ) // General case
     {
-        for (m = 0; m < M; m++) {
-            for (n = 0; n < N; n++) {
-                a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
-                b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
-                gtestAssertElementsEqual(a, b);
+    for (m = 0; m < M; m++) {
+        for (n = 0; n < N; n++) {
+            a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
+            b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
+            delta = 0.0;
+            if (absDelta != NULL) {
+                delta = absDelta[m * N + n];
             }
+			if( module(a-b) > delta )		printf("m : %d\t n: %d\n", (int)m, (int)n);
+            ASSERT_NEAR(a, b, delta);
         }
     }
+    }
     else // Packed case
     {
-        if ( order == clblasColumnMajor)
-        {
-            for ( n = 0; n < N; n++)
-            {
-                for( m=n; m < M; m++)
-                {
-                    a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
-                    b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
-                    gtestAssertElementsEqual(a, b);
-                }
+	if ( order == clblasColumnMajor)
+	{
+		for ( n = 0; n < N; n++)
+		{
+			for( m=n; m < M; m++)
+			{
+            			a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
+			        b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+						if( module(a-b) > delta )		printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(a, b, delta);
+			}
+		}
+	}
+	else
+	{
+		for ( m = 0; m < M; m++)
+		{
+			for( n = 0; n <= m; n++)
+			{
+            			a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
+			        b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+						if( module(a-b) > delta )		printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(a, b, delta);
+			}
+		}
+	}
+    }
+}
+
+template<>
+__template_static void
+compareMatrices<FloatComplex>(
+    clblasOrder order,
+    size_t M,
+    size_t N,
+    const FloatComplex *A,
+    const FloatComplex *B,
+    size_t lda,
+    const cl_double *absDelta)
+{
+    size_t m = 0, n = 0;
+    FloatComplex a, b;
+    cl_double delta;
+
+if ( lda > 0 )
+{
+    for (m = 0; m < M; m++) {
+        for (n = 0; n < N; n++) {
+            a = getElement<FloatComplex>(order, clblasNoTrans, m, n, A, lda);
+            b = getElement<FloatComplex>(order, clblasNoTrans, m, n, B, lda);
+            delta = 0.0;
+            if (absDelta != NULL) {
+                delta = absDelta[m * N + n];
             }
+			if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+					printf("m : %d\t n: %d\n", (int)m, (int)n);
+            ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+            ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
         }
-        else
-        {
-            for ( m = 0; m < M; m++)
-            {
-                for( n = 0; n <= m; n++)
-                {
-                    a = getElement<T>(order, clblasNoTrans, m, n, A, lda);
-                    b = getElement<T>(order, clblasNoTrans, m, n, B, lda);
-                    gtestAssertElementsEqual(a, b);
-                }
+    }
+}
+    else // Packed case
+    {
+	if ( order == clblasColumnMajor)
+	{
+		for ( n = 0; n < N; n++)
+		{
+			for( m=n; m < M; m++)
+			{
+            			a = getElement<FloatComplex>(order, clblasNoTrans, m, n, A, lda);
+				        b = getElement<FloatComplex>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+            			if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+							printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+		            	ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
+			}
+		}
+	}
+	else
+	{
+		for ( m = 0; m < M; m++)
+		{
+			for( n = 0; n <= m; n++)
+			{
+            			a = getElement<FloatComplex>(order, clblasNoTrans, m, n, A, lda);
+			        b = getElement<FloatComplex>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+						if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+							printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+		            	ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
+			}
+		}
+	}
+    }
+
+}
+
+template<>
+__template_static void
+compareMatrices<DoubleComplex>(
+    clblasOrder order,
+    size_t M,
+    size_t N,
+    const DoubleComplex *A,
+    const DoubleComplex *B,
+    size_t lda,
+    const cl_double *absDelta)
+{
+    size_t m = 0, n = 0;
+    DoubleComplex a, b;
+    cl_double delta;
+if( lda > 0 )
+{
+    for (m = 0; m < M; m++) {
+        for (n = 0; n < N; n++) {
+            a = getElement<DoubleComplex>(order, clblasNoTrans, m, n, A, lda);
+            b = getElement<DoubleComplex>(order, clblasNoTrans, m, n, B, lda);
+            delta = 0.0;
+            if (absDelta != NULL) {
+                delta = absDelta[m * N + n];
             }
+			if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+					printf("m : %d\t n: %d\n", (int)m, (int)n);
+            ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+            ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
         }
     }
 }
+    else // Packed case
+    {
+	if ( order == clblasColumnMajor)
+	{
+		for ( n = 0; n < N; n++)
+		{
+			for( m=n; m < M; m++)
+			{
+            			a = getElement<DoubleComplex>(order, clblasNoTrans, m, n, A, lda);
+			        b = getElement<DoubleComplex>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+						if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+							printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+		            	ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
+			}
+		}
+	}
+	else
+	{
+		for ( m = 0; m < M; m++)
+		{
+			for( n = 0; n <= m; n++)
+			{
+            			a = getElement<DoubleComplex>(order, clblasNoTrans, m, n, A, lda);
+			        b = getElement<DoubleComplex>(order, clblasNoTrans, m, n, B, lda);
+            			delta = 0.0;
+            			if (absDelta != NULL) {
+                			//delta = absDelta[m * N + n];
+            			}
+						if( (module(CREAL(a) - CREAL(b)) > delta) || (module(CIMAG(a) - CIMAG(b)) > delta) )
+							printf("m : %d\t n: %d\n", (int)m, (int)n);
+            			ASSERT_NEAR(CREAL(a), CREAL(b), delta);
+		            	ASSERT_NEAR(CIMAG(a), CIMAG(b), delta);
+			}
+		}
+	}
+    }
+
+}
 
 template <typename T>
 static void

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clblas.git



More information about the debian-science-commits mailing list