From f844b36811f74500217096ca214548b0ba2a9467 Mon Sep 17 00:00:00 2001 From: Brian Kelley Date: Thu, 10 Feb 2022 14:30:08 -0700 Subject: [PATCH] Replace std::abs with ArithTraits::abs --- .../KokkosBatched_Test_Gemm_Cuda.cpp | 15 ++++++---- .../KokkosBatched_Test_Gemv_Host.hpp | 7 +++-- .../do-not-use/KokkosBatched_Test_LU_Cuda.cpp | 12 +++++--- .../KokkosBatched_Test_Trsm_Cuda.cpp | 12 +++++--- .../KokkosBatched_Test_Trsm_Host.hpp | 16 +++++----- .../sparse/KokkosSparse_spmv_blockcrs.cpp | 12 ++++---- perf_test/sparse/KokkosSparse_spmv_bsr.cpp | 12 ++++---- src/batched/KokkosBatched_Util.hpp | 1 - .../KokkosBatched_Test_BlockCrs_Util.hpp | 3 +- .../KokkosBatched_GMRES_TeamVector_Impl.hpp | 4 ++- .../impl/KokkosBatched_GMRES_Team_Impl.hpp | 4 ++- test_common/KokkosBatched_Test_BlockCrs.hpp | 30 ++++++++++++------- 12 files changed, 79 insertions(+), 49 deletions(-) diff --git a/perf_test/batched/do-not-use/KokkosBatched_Test_Gemm_Cuda.cpp b/perf_test/batched/do-not-use/KokkosBatched_Test_Gemm_Cuda.cpp index d4ea2af160..5bc5e9d1b7 100644 --- a/perf_test/batched/do-not-use/KokkosBatched_Test_Gemm_Cuda.cpp +++ b/perf_test/batched/do-not-use/KokkosBatched_Test_Gemm_Cuda.cpp @@ -328,7 +328,8 @@ void Gemm(const int NN, const int BlkSize) { for (int i = 0, iend = cref.extent(0); i < iend; ++i) for (int j = 0, jend = cref.extent(1); j < jend; ++j) for (int k = 0, kend = cref.extent(2); k < kend; ++k) - diff += std::abs(cref(i, j, k) - csol(i, j, k)); + diff += Kokkos::ArithTraits::abs(cref(i, j, k) - + csol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Range" << " BlkSize = " << std::setw(3) << BlkSize << " TeamSize = N/A" @@ -396,7 +397,8 @@ void Gemm(const int NN, const int BlkSize) { for (int i = 0, iend = cref.extent(0); i < iend; ++i) for (int j = 0, jend = cref.extent(1); j < jend; ++j) for (int k = 0, kend = cref.extent(2); k < kend; ++k) - diff += std::abs(cref(i, j, k) - csol(i, j, k)); + diff += Kokkos::ArithTraits::abs(cref(i, j, k) - + csol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V1" << " BlkSize = " << std::setw(3) << BlkSize @@ -470,7 +472,8 @@ void Gemm(const int NN, const int BlkSize) { for (int i = 0, iend = cref.extent(0); i < iend; ++i) for (int j = 0, jend = cref.extent(1); j < jend; ++j) for (int k = 0, kend = cref.extent(2); k < kend; ++k) - diff += std::abs(cref(i, j, k) - csol(i, j, k)); + diff += Kokkos::ArithTraits::abs(cref(i, j, k) - + csol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V2" << " BlkSize = " << std::setw(3) << BlkSize @@ -553,7 +556,8 @@ void Gemm(const int NN, const int BlkSize) { for (int i = 0, iend = cref.extent(0); i < iend; ++i) for (int j = 0, jend = cref.extent(1); j < jend; ++j) for (int k = 0, kend = cref.extent(2); k < kend; ++k) - diff += std::abs(cref(i, j, k) - csol(i, j, k)); + diff += Kokkos::ArithTraits::abs(cref(i, j, k) - + csol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V3" << " BlkSize = " << std::setw(3) << BlkSize @@ -627,7 +631,8 @@ void Gemm(const int NN, const int BlkSize) { for (int i = 0, iend = cref.extent(0); i < iend; ++i) for (int j = 0, jend = cref.extent(1); j < jend; ++j) for (int k = 0, kend = cref.extent(2); k < kend; ++k) - diff += std::abs(cref(i, j, k) - csol(i, j, k)); + diff += Kokkos::ArithTraits::abs(cref(i, j, k) - + csol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team HM" << " BlkSize = " << std::setw(3) << BlkSize diff --git a/perf_test/batched/do-not-use/KokkosBatched_Test_Gemv_Host.hpp b/perf_test/batched/do-not-use/KokkosBatched_Test_Gemv_Host.hpp index f913aa5740..9480b810ba 100644 --- a/perf_test/batched/do-not-use/KokkosBatched_Test_Gemv_Host.hpp +++ b/perf_test/batched/do-not-use/KokkosBatched_Test_Gemv_Host.hpp @@ -202,7 +202,8 @@ void Gemv(const int NN) { for (int i = 0, iend = yref.extent(0); i < iend; ++i) for (int j = 0, jend = yref.extent(1); j < jend; ++j) for (int k = 0, kend = yref.extent(2); k < kend; ++k) - diff += std::abs(yref(i, j, k) - y(i, j, k)); + diff += Kokkos::ArithTraits::abs(yref(i, j, k) - + y(i, j, k)); std::cout << std::setw(12) << "Plain" << " BlkSize = " << std::setw(3) << BlkSize @@ -274,8 +275,8 @@ void Gemv(const int NN) { for (int i = 0, iend = yref.extent(0); i < iend; ++i) for (int j = 0, jend = yref.extent(1); j < jend; ++j) for (int k = 0, kend = yref.extent(2); k < kend; ++k) - diff += std::abs(yref(i, j, k) - - y(i / VectorLength, j, k)[i % VectorLength]); + diff += Kokkos::ArithTraits::abs( + yref(i, j, k) - y(i / VectorLength, j, k)[i % VectorLength]); std::cout << std::setw(12) << "Serial SIMD" << " BlkSize = " << std::setw(3) << BlkSize diff --git a/perf_test/batched/do-not-use/KokkosBatched_Test_LU_Cuda.cpp b/perf_test/batched/do-not-use/KokkosBatched_Test_LU_Cuda.cpp index 1514bb9fcd..6cf9ec5725 100644 --- a/perf_test/batched/do-not-use/KokkosBatched_Test_LU_Cuda.cpp +++ b/perf_test/batched/do-not-use/KokkosBatched_Test_LU_Cuda.cpp @@ -307,7 +307,8 @@ void LU(const int NN, const int BlkSize) { for (int i = 0, iend = aref.extent(0); i < iend; ++i) for (int j = 0, jend = aref.extent(1); j < jend; ++j) for (int k = 0, kend = aref.extent(2); k < kend; ++k) - diff += std::abs(aref(i, j, k) - asol(i, j, k)); + diff += Kokkos::ArithTraits::abs(aref(i, j, k) - + asol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Range" << " BlkSize = " << std::setw(3) << BlkSize << " TeamSize = N/A" @@ -367,7 +368,8 @@ void LU(const int NN, const int BlkSize) { for (int i = 0, iend = aref.extent(0); i < iend; ++i) for (int j = 0, jend = aref.extent(1); j < jend; ++j) for (int k = 0, kend = aref.extent(2); k < kend; ++k) - diff += std::abs(aref(i, j, k) - asol(i, j, k)); + diff += Kokkos::ArithTraits::abs(aref(i, j, k) - + asol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V1" << " BlkSize = " << std::setw(3) << BlkSize @@ -438,7 +440,8 @@ void LU(const int NN, const int BlkSize) { for (int i = 0, iend = aref.extent(0); i < iend; ++i) for (int j = 0, jend = aref.extent(1); j < jend; ++j) for (int k = 0, kend = aref.extent(2); k < kend; ++k) - diff += std::abs(aref(i, j, k) - asol(i, j, k)); + diff += Kokkos::ArithTraits::abs(aref(i, j, k) - + asol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V2" << " BlkSize = " << std::setw(3) << BlkSize @@ -516,7 +519,8 @@ void LU(const int NN, const int BlkSize) { for (int i = 0, iend = aref.extent(0); i < iend; ++i) for (int j = 0, jend = aref.extent(1); j < jend; ++j) for (int k = 0, kend = aref.extent(2); k < kend; ++k) - diff += std::abs(aref(i, j, k) - asol(i, j, k)); + diff += Kokkos::ArithTraits::abs(aref(i, j, k) - + asol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V3" << " BlkSize = " << std::setw(3) << BlkSize diff --git a/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Cuda.cpp b/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Cuda.cpp index de6fb2582e..6000bc7c9d 100644 --- a/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Cuda.cpp +++ b/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Cuda.cpp @@ -476,7 +476,8 @@ void Trsm(const int NN, const int BlkSize, const int NumCols) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - bsol(i, j, k)); + diff += Kokkos::ArithTraits::abs(bref(i, j, k) - + bsol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Range" << " BlkSize = " << std::setw(3) << BlkSize @@ -540,7 +541,8 @@ void Trsm(const int NN, const int BlkSize, const int NumCols) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - bsol(i, j, k)); + diff += Kokkos::ArithTraits::abs(bref(i, j, k) - + bsol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V1" << " BlkSize = " << std::setw(3) << BlkSize @@ -614,7 +616,8 @@ void Trsm(const int NN, const int BlkSize, const int NumCols) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - bsol(i, j, k)); + diff += Kokkos::ArithTraits::abs(bref(i, j, k) - + bsol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V2" << " BlkSize = " << std::setw(3) << BlkSize @@ -694,7 +697,8 @@ void Trsm(const int NN, const int BlkSize, const int NumCols) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - bsol(i, j, k)); + diff += Kokkos::ArithTraits::abs(bref(i, j, k) - + bsol(i, j, k)); std::cout << std::setw(8) << "Kokkos" << std::setw(8) << "Team V3" << " BlkSize = " << std::setw(3) << BlkSize diff --git a/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Host.hpp b/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Host.hpp index 6b57b534b7..0770055cb0 100644 --- a/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Host.hpp +++ b/perf_test/batched/do-not-use/KokkosBatched_Test_Trsm_Host.hpp @@ -209,7 +209,7 @@ void Trsm(const int NN) { for (int i = 0, iend = b.extent(0); i < iend; ++i) for (int j = 0, jend = b.extent(1); j < jend; ++j) for (int k = 0, kend = b.extent(2); k < kend; ++k) - sum += std::abs(bmat(i, j, k)); + sum += Kokkos::ArithTraits::abs(bmat(i, j, k)); std::cout << std::setw(10) << "MKL TRSM" << " BlkSize = " << std::setw(3) << BlkSize @@ -327,7 +327,8 @@ void Trsm(const int NN) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - b(i, j, k)); + diff += Kokkos::ArithTraits::abs(bref(i, j, k) - + b(i, j, k)); std::cout << std::setw(10) << "MKL Batch" << " BlkSize = " << std::setw(3) << BlkSize @@ -443,8 +444,8 @@ void Trsm(const int NN) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - - b(i / VectorLength, j, k)[i % VectorLength]); + diff += Kokkos::ArithTraits::abs( + bref(i, j, k) - b(i / VectorLength, j, k)[i % VectorLength]); std::cout << std::setw(10) << "MKL Cmpt" << " BlkSize = " << std::setw(3) << BlkSize @@ -523,7 +524,8 @@ void Trsm(const int NN) { // for (int i=0,iend=bref.extent(0);i::abs(bref(i,j,k) - + // b(i,j,k)); // std::cout << std::setw(10) << "KK Scalar" // << " BlkSize = " << std::setw(3) << BlkSize @@ -599,8 +601,8 @@ void Trsm(const int NN) { for (int i = 0, iend = bref.extent(0); i < iend; ++i) for (int j = 0, jend = bref.extent(1); j < jend; ++j) for (int k = 0, kend = bref.extent(2); k < kend; ++k) - diff += std::abs(bref(i, j, k) - - b(i / VectorLength, j, k)[i % VectorLength]); + diff += Kokkos::ArithTraits::abs( + bref(i, j, k) - b(i / VectorLength, j, k)[i % VectorLength]); std::cout << std::setw(10) << "KK Vector" << " BlkSize = " << std::setw(3) << BlkSize diff --git a/perf_test/sparse/KokkosSparse_spmv_blockcrs.cpp b/perf_test/sparse/KokkosSparse_spmv_blockcrs.cpp index b453792935..1eb7f0b8da 100644 --- a/perf_test/sparse/KokkosSparse_spmv_blockcrs.cpp +++ b/perf_test/sparse/KokkosSparse_spmv_blockcrs.cpp @@ -223,9 +223,9 @@ int test_blockcrs_matrix_single_vec( Kokkos::deep_copy(h_yblockcrs, yblockcrs); double error = 0.0, maxNorm = 0.0; for (size_t ir = 0; ir < h_ycrs.extent(0); ++ir) { - maxNorm = std::max(maxNorm, std::abs(static_cast(h_ycrs(ir)))); - error = std::max( - error, std::abs(static_cast(h_ycrs(ir) - h_yblockcrs(ir)))); + maxNorm = std::max(maxNorm, Kokkos::ArithTraits::abs(h_ycrs(ir))); + error = std::max(error, Kokkos::ArithTraits::abs( + h_ycrs(ir) - h_yblockcrs(ir))); } double tol = @@ -356,9 +356,9 @@ int test_blockcrs_matrix_vec( double error = 0.0, maxNorm = 0.0; for (size_t ir = 0; ir < h_ycrs.extent(0); ++ir) { maxNorm = - std::max(maxNorm, std::abs(static_cast(h_ycrs(ir, jc)))); - error = std::max(error, std::abs(static_cast( - h_ycrs(ir, jc) - h_yblockcrs(ir, jc)))); + std::max(maxNorm, Kokkos::ArithTraits::abs(h_ycrs(ir, jc))); + error = std::max(error, Kokkos::ArithTraits::abs( + h_ycrs(ir, jc) - h_yblockcrs(ir, jc))); } if (error > tol * maxNorm) { num_errors += 1; diff --git a/perf_test/sparse/KokkosSparse_spmv_bsr.cpp b/perf_test/sparse/KokkosSparse_spmv_bsr.cpp index 9f63004b8d..e10c6748a7 100644 --- a/perf_test/sparse/KokkosSparse_spmv_bsr.cpp +++ b/perf_test/sparse/KokkosSparse_spmv_bsr.cpp @@ -241,9 +241,9 @@ int test_bsr_matrix_single_vec( Kokkos::deep_copy(h_ybsr, ybsr); double error = 0.0, maxNorm = 0.0; for (size_t ir = 0; ir < h_ycrs.extent(0); ++ir) { - maxNorm = std::max(maxNorm, std::abs(static_cast(h_ycrs(ir)))); - error = std::max(error, - std::abs(static_cast(h_ycrs(ir) - h_ybsr(ir)))); + maxNorm = std::max(maxNorm, Kokkos::ArithTraits::abs(h_ycrs(ir))); + error = std::max( + error, Kokkos::ArithTraits::abs(h_ycrs(ir) - h_ybsr(ir))); } double tol = @@ -405,9 +405,9 @@ int test_bsr_matrix_vec( double error = 0.0, maxNorm = 0.0; for (size_t ir = 0; ir < h_ycrs.extent(0); ++ir) { maxNorm = - std::max(maxNorm, std::abs(static_cast(h_ycrs(ir, jc)))); - error = std::max(error, std::abs(static_cast(h_ycrs(ir, jc) - - h_ybsr(ir, jc)))); + std::max(maxNorm, Kokkos::ArithTraits::abs(h_ycrs(ir, jc))); + error = std::max(error, Kokkos::ArithTraits::abs( + h_ycrs(ir, jc) - h_ybsr(ir, jc))); } if (error > tol * maxNorm) { num_errors += 1; diff --git a/src/batched/KokkosBatched_Util.hpp b/src/batched/KokkosBatched_Util.hpp index 9b9aefd856..da43220b72 100644 --- a/src/batched/KokkosBatched_Util.hpp +++ b/src/batched/KokkosBatched_Util.hpp @@ -65,7 +65,6 @@ struct is_same_mag_type { }; // to use double, std::complex, Kokkos::complex -using std::abs; using std::max; using std::min; diff --git a/src/batched/dense/KokkosBatched_Test_BlockCrs_Util.hpp b/src/batched/dense/KokkosBatched_Test_BlockCrs_Util.hpp index 91b2fc3784..77fa690908 100644 --- a/src/batched/dense/KokkosBatched_Test_BlockCrs_Util.hpp +++ b/src/batched/dense/KokkosBatched_Test_BlockCrs_Util.hpp @@ -805,7 +805,8 @@ class ExtractBlockTridiagMatrices { const auto eps = 1e2 * std::numeric_limits::epsilon(); for (ordinal_type ii = 0; ii < blocksize; ++ii) for (ordinal_type jj = 0; jj < blocksize; ++jj) - if (std::abs(tdiag_val(T, ij, k, ii, jj) - A(c, ii, jj)) >= eps) + if (Kokkos::ArithTraits::abs(tdiag_val(T, ij, k, ii, jj) - + A(c, ii, jj)) >= eps) return false; return true; } diff --git a/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp index 6c869d0bce..8e45b97556 100644 --- a/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp @@ -252,7 +252,9 @@ struct TeamVectorGMRES { G(l, j + 1) = 0.; } - if (mask(l) == 1. && std::abs(G(l, j + 1)) / beta(l) < tolerance) { + if (mask(l) == 1. && + Kokkos::ArithTraits::abs(G(l, j + 1)) / beta(l) < + tolerance) { mask(l) = 0.; G(l, j + 1) = 0.; } diff --git a/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp index 0792c167bd..4b4bd06bc0 100644 --- a/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp @@ -249,7 +249,9 @@ struct TeamGMRES { G(l, j + 1) = 0.; } - if (mask(l) == 1. && std::abs(G(l, j + 1)) / beta(l) < tolerance) { + if (mask(l) == 1. && + Kokkos::ArithTraits::abs(G(l, j + 1)) / beta(l) < + tolerance) { mask(l) = 0.; G(l, j + 1) = 0.; } diff --git a/test_common/KokkosBatched_Test_BlockCrs.hpp b/test_common/KokkosBatched_Test_BlockCrs.hpp index e587352101..32734da625 100644 --- a/test_common/KokkosBatched_Test_BlockCrs.hpp +++ b/test_common/KokkosBatched_Test_BlockCrs.hpp @@ -497,18 +497,26 @@ class FactorizeBlockTridiagMatrices { for (ordinal_type t = 0; t < _ntridiag; ++t) { for (ordinal_type ii = 0; ii < _blocksize; ++ii) for (ordinal_type jj = 0; jj < _blocksize; ++jj) { - norm += std::abs(tdiag_val(A, t, 0, ii, jj)); - diff += std::abs(tdiag_val(AA, t, 0, ii, jj)); + norm += + Kokkos::ArithTraits::abs(tdiag_val(A, t, 0, ii, jj)); + diff += + Kokkos::ArithTraits::abs(tdiag_val(AA, t, 0, ii, jj)); } for (ordinal_type i = 1; i < _m; ++i) for (ordinal_type ii = 0; ii < _blocksize; ++ii) for (ordinal_type jj = 0; jj < _blocksize; ++jj) { - norm += std::abs(tdiag_val(A, t, i, ii, jj)); - diff += std::abs(tdiag_val(AA, t, i, ii, jj)); - norm += std::abs(tdiag_val(B, t, i - 1, ii, jj)); - diff += std::abs(tdiag_val(BB, t, i - 1, ii, jj)); - norm += std::abs(tdiag_val(C, t, i - 1, ii, jj)); - diff += std::abs(tdiag_val(CC, t, i - 1, ii, jj)); + norm += Kokkos::ArithTraits::abs( + tdiag_val(A, t, i, ii, jj)); + diff += Kokkos::ArithTraits::abs( + tdiag_val(AA, t, i, ii, jj)); + norm += Kokkos::ArithTraits::abs( + tdiag_val(B, t, i - 1, ii, jj)); + diff += Kokkos::ArithTraits::abs( + tdiag_val(BB, t, i - 1, ii, jj)); + norm += Kokkos::ArithTraits::abs( + tdiag_val(C, t, i - 1, ii, jj)); + diff += Kokkos::ArithTraits::abs( + tdiag_val(CC, t, i - 1, ii, jj)); } } // std::cout << "tridiag factor check norm = " << norm << " diff = " << @@ -1046,8 +1054,10 @@ class SolveBlockTridiagMatrices { for (ordinal_type jvec = 0; jvec < _nvectors; ++jvec) for (ordinal_type i = 0; i < _m; ++i) for (ordinal_type ii = 0; ii < _blocksize; ++ii) { - norm += std::abs(tdiag_val(bb, t, jvec, i, ii)); - diff += std::abs(tdiag_val(rr, t, jvec, i, ii)); + norm += Kokkos::ArithTraits::abs( + tdiag_val(bb, t, jvec, i, ii)); + diff += Kokkos::ArithTraits::abs( + tdiag_val(rr, t, jvec, i, ii)); } // std::cout << "tridiag solve check norm = " << norm << " diff = " <<