From bcae22551784d010b1dcf53f73edd359210e58f3 Mon Sep 17 00:00:00 2001 From: Edward Smyth Date: Mon, 15 Jan 2024 09:29:14 -0500 Subject: [PATCH] GTestSuite: BLAS3 thresholds Modify thresholds to reflect number of operations that accumulate results into each output element. Different limits are set for early return and special cases. Constants are still subject to experimentation and change. AMD-Internal: [CPUPL-4378] Change-Id: I03cd8901e574f2e44e85ce8b0bc234e36edb4819 --- .../level3/gemm/cgemm_evt_testing.cpp | 15 ++++++- .../testsuite/level3/gemm/cgemm_generic.cpp | 15 ++++++- .../level3/gemm/dgemm_evt_testing.cpp | 14 ++++++- .../testsuite/level3/gemm/dgemm_generic.cpp | 15 ++++++- .../testsuite/level3/gemm/dgemm_ovr_undr.cpp | 15 +++++-- .../level3/gemm/sgemm_evt_testing.cpp | 16 ++++++- .../testsuite/level3/gemm/sgemm_generic.cpp | 15 ++++++- .../level3/gemm/zgemm_evt_testing.cpp | 15 ++++++- .../testsuite/level3/gemm/zgemm_generic.cpp | 17 ++++++-- .../gemm_compute/dgemm_compute_generic.cpp | 17 ++++++-- .../gemm_compute/sgemm_compute_generic.cpp | 16 +++++-- .../testsuite/level3/gemmt/cgemmt_generic.cpp | 15 ++++++- .../level3/gemmt/dgemmt_evt_testing.cpp | 12 +++++- .../testsuite/level3/gemmt/dgemmt_generic.cpp | 12 +++++- .../testsuite/level3/gemmt/sgemmt_generic.cpp | 14 ++++++- .../testsuite/level3/gemmt/zgemmt_generic.cpp | 15 ++++++- .../testsuite/level3/hemm/chemm_generic.cpp | 18 +++++++- .../testsuite/level3/hemm/zhemm_generic.cpp | 18 +++++++- .../testsuite/level3/her2k/cher2k_generic.cpp | 26 ++++++++---- gtestsuite/testsuite/level3/her2k/her2k.h | 34 +++++++-------- .../testsuite/level3/her2k/test_her2k.h | 22 +++++----- .../testsuite/level3/her2k/zher2k_generic.cpp | 26 ++++++++---- .../testsuite/level3/herk/cherk_generic.cpp | 26 ++++++++---- gtestsuite/testsuite/level3/herk/test_herk.h | 18 ++++---- .../testsuite/level3/herk/zherk_generic.cpp | 26 ++++++++---- .../testsuite/level3/symm/csymm_generic.cpp | 18 +++++++- .../testsuite/level3/symm/dsymm_generic.cpp | 17 +++++++- .../testsuite/level3/symm/ssymm_generic.cpp | 17 +++++++- .../testsuite/level3/symm/zsymm_generic.cpp | 18 +++++++- .../testsuite/level3/syr2k/csyr2k_generic.cpp | 27 ++++++++---- .../testsuite/level3/syr2k/dsyr2k_generic.cpp | 26 ++++++++---- .../testsuite/level3/syr2k/ssyr2k_generic.cpp | 26 ++++++++---- gtestsuite/testsuite/level3/syr2k/syr2k.h | 42 +++++++++---------- .../testsuite/level3/syr2k/test_syr2k.h | 22 +++++----- .../testsuite/level3/syr2k/zsyr2k_generic.cpp | 27 ++++++++---- .../testsuite/level3/syrk/csyrk_generic.cpp | 27 ++++++++---- .../testsuite/level3/syrk/dsyrk_generic.cpp | 26 ++++++++---- .../testsuite/level3/syrk/ssyrk_generic.cpp | 26 ++++++++---- gtestsuite/testsuite/level3/syrk/syrk.h | 40 +++++++++--------- gtestsuite/testsuite/level3/syrk/test_syrk.h | 18 ++++---- .../testsuite/level3/syrk/zsyrk_generic.cpp | 27 ++++++++---- .../testsuite/level3/trmm/ctrmm_generic.cpp | 15 ++++++- .../testsuite/level3/trmm/dtrmm_generic.cpp | 14 ++++++- .../testsuite/level3/trmm/strmm_generic.cpp | 14 ++++++- .../testsuite/level3/trmm/ztrmm_generic.cpp | 15 ++++++- .../testsuite/level3/trmm3/ctrmm3_generic.cpp | 18 +++++++- .../testsuite/level3/trmm3/dtrmm3_generic.cpp | 17 +++++++- .../testsuite/level3/trmm3/strmm3_generic.cpp | 17 +++++++- .../testsuite/level3/trmm3/ztrmm3_generic.cpp | 18 +++++++- .../level3/trsm/ctrsm_evt_testing.cpp | 15 ++++++- .../testsuite/level3/trsm/ctrsm_generic.cpp | 17 ++++++-- .../level3/trsm/dtrsm_evt_testing.cpp | 14 ++++++- .../testsuite/level3/trsm/dtrsm_generic.cpp | 14 ++++++- .../level3/trsm/strsm_evt_testing.cpp | 14 ++++++- .../testsuite/level3/trsm/strsm_generic.cpp | 16 +++++-- .../level3/trsm/ztrsm_evt_testing.cpp | 15 ++++++- .../testsuite/level3/trsm/ztrsm_generic.cpp | 17 ++++++-- .../testsuite/ukr/gemm/dgemm_ukernel.cpp | 28 ++++++++++++- gtestsuite/testsuite/ukr/gemm/test_gemm_ukr.h | 39 +++++++++++++++-- .../testsuite/ukr/gemm/zgemm_ukernel.cpp | 33 ++++++++++++++- gtestsuite/testsuite/ukr/trsm/ctrsm_ukr.cpp | 12 +++++- gtestsuite/testsuite/ukr/trsm/dtrsm_ukr.cpp | 24 +++++++++-- gtestsuite/testsuite/ukr/trsm/strsm_ukr.cpp | 22 +++++++++- gtestsuite/testsuite/ukr/trsm/ztrsm_ukr.cpp | 24 ++++++++++- 64 files changed, 999 insertions(+), 289 deletions(-) diff --git a/gtestsuite/testsuite/level3/gemm/cgemm_evt_testing.cpp b/gtestsuite/testsuite/level3/gemm/cgemm_evt_testing.cpp index 1faca3ca3..3c69c237b 100644 --- a/gtestsuite/testsuite/level3/gemm/cgemm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/gemm/cgemm_evt_testing.cpp @@ -113,8 +113,19 @@ TEST_P(cgemmEVT, NaNInfCheck) gtint_t ldb_inc = std::get<18>(GetParam()); gtint_t ldc_inc = std::get<19>(GetParam()); - // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- diff --git a/gtestsuite/testsuite/level3/gemm/cgemm_generic.cpp b/gtestsuite/testsuite/level3/gemm/cgemm_generic.cpp index 2dc039882..920860bdf 100644 --- a/gtestsuite/testsuite/level3/gemm/cgemm_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm/cgemm_generic.cpp @@ -77,7 +77,20 @@ TEST_P(cgemmAPI, FunctionalTest) gtint_t ldb_inc = std::get<9>(GetParam()); gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- diff --git a/gtestsuite/testsuite/level3/gemm/dgemm_evt_testing.cpp b/gtestsuite/testsuite/level3/gemm/dgemm_evt_testing.cpp index 89d741d6b..73b0b5ada 100644 --- a/gtestsuite/testsuite/level3/gemm/dgemm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/gemm/dgemm_evt_testing.cpp @@ -102,7 +102,17 @@ TEST_P(DGEMMEVT, ExceptionValueTest) gtint_t ldc_inc = std::get<19>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -490,4 +500,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0)) // increment to the leading dim of c ), ::DGEMMEVMatPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/gemm/dgemm_generic.cpp b/gtestsuite/testsuite/level3/gemm/dgemm_generic.cpp index ef5d21c2c..987580e2f 100644 --- a/gtestsuite/testsuite/level3/gemm/dgemm_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm/dgemm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -81,7 +81,18 @@ TEST_P(DGEMMTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (15*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemm/dgemm_ovr_undr.cpp b/gtestsuite/testsuite/level3/gemm/dgemm_ovr_undr.cpp index e01bab102..daff0a7e4 100644 --- a/gtestsuite/testsuite/level3/gemm/dgemm_ovr_undr.cpp +++ b/gtestsuite/testsuite/level3/gemm/dgemm_ovr_undr.cpp @@ -96,8 +96,17 @@ TEST_P(DGEMMOvrUndr, OverflowUnderflow) gtint_t bi = std::get<15>(GetParam()); gtint_t bj = std::get<16>(GetParam()); - // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -476,4 +485,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(105) // bj ), ::DGEMMOUTestPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/gemm/sgemm_evt_testing.cpp b/gtestsuite/testsuite/level3/gemm/sgemm_evt_testing.cpp index d613cc41b..10cf4deb2 100644 --- a/gtestsuite/testsuite/level3/gemm/sgemm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/gemm/sgemm_evt_testing.cpp @@ -97,8 +97,20 @@ TEST_P(sgemmEVT, NaNInfCheck) gtint_t lda_inc = std::get<17>(GetParam()); gtint_t ldb_inc = std::get<18>(GetParam()); gtint_t ldc_inc = std::get<19>(GetParam()); - // Set the threshold for the errors: - float thresh = 10*m*n*testinghelpers::getEpsilon(); + + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- diff --git a/gtestsuite/testsuite/level3/gemm/sgemm_generic.cpp b/gtestsuite/testsuite/level3/gemm/sgemm_generic.cpp index 65c02e8b9..2733de66c 100644 --- a/gtestsuite/testsuite/level3/gemm/sgemm_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm/sgemm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -81,7 +81,18 @@ TEST_P(SGemm, FunctionalTest) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (24*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemm/zgemm_evt_testing.cpp b/gtestsuite/testsuite/level3/gemm/zgemm_evt_testing.cpp index 9669a34a9..70ffc0173 100644 --- a/gtestsuite/testsuite/level3/gemm/zgemm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/gemm/zgemm_evt_testing.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -106,7 +106,18 @@ TEST_P(ZGEMMEVT, NaNInfCheck) gtint_t ldc_inc = std::get<19>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemm/zgemm_generic.cpp b/gtestsuite/testsuite/level3/gemm/zgemm_generic.cpp index 646d3710b..19bb16d20 100644 --- a/gtestsuite/testsuite/level3/gemm/zgemm_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm/zgemm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -80,7 +80,18 @@ TEST_P(ZGEMMAPI, FunctionalTest) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (15*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -383,4 +394,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0), gtint_t(500)) // increment to the leading dim of c ), ::ZGEMMPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/gemm_compute/dgemm_compute_generic.cpp b/gtestsuite/testsuite/level3/gemm_compute/dgemm_compute_generic.cpp index a648f53bc..c7542e7e5 100644 --- a/gtestsuite/testsuite/level3/gemm_compute/dgemm_compute_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm_compute/dgemm_compute_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -85,8 +85,19 @@ TEST_P(DGemmComputeTest, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - double intermediate = (double)m*n*k; - double thresh = 10*intermediate*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (7*k+1)*testinghelpers::getEpsilon(); + //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- diff --git a/gtestsuite/testsuite/level3/gemm_compute/sgemm_compute_generic.cpp b/gtestsuite/testsuite/level3/gemm_compute/sgemm_compute_generic.cpp index ea574eb72..243b6d648 100644 --- a/gtestsuite/testsuite/level3/gemm_compute/sgemm_compute_generic.cpp +++ b/gtestsuite/testsuite/level3/gemm_compute/sgemm_compute_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -86,8 +86,18 @@ TEST_P(SGemmComputeTest, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - float intermediate = (float)m*n*k; - float thresh = 10*intermediate*testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (8*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemmt/cgemmt_generic.cpp b/gtestsuite/testsuite/level3/gemmt/cgemmt_generic.cpp index 07aed996b..54ff0e6ab 100644 --- a/gtestsuite/testsuite/level3/gemmt/cgemmt_generic.cpp +++ b/gtestsuite/testsuite/level3/gemmt/cgemmt_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -81,7 +81,18 @@ TEST_P(cgemmtTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*n*k*testinghelpers::getEpsilon(); + // Check gtestsuite gemmt.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemmt/dgemmt_evt_testing.cpp b/gtestsuite/testsuite/level3/gemmt/dgemmt_evt_testing.cpp index c22f4480c..7eee53640 100644 --- a/gtestsuite/testsuite/level3/gemmt/dgemmt_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/gemmt/dgemmt_evt_testing.cpp @@ -85,7 +85,17 @@ TEST_P( dgemmtEVT, NaNInfCheck ) T cexval = std::get<13>(GetParam()); // Set the threshold for the errors: - double thresh = 10*n*k*testinghelpers::getEpsilon(); + // Check gtestsuite gemmt.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemmt/dgemmt_generic.cpp b/gtestsuite/testsuite/level3/gemmt/dgemmt_generic.cpp index 8bb03411d..d50ed4bec 100644 --- a/gtestsuite/testsuite/level3/gemmt/dgemmt_generic.cpp +++ b/gtestsuite/testsuite/level3/gemmt/dgemmt_generic.cpp @@ -83,7 +83,17 @@ TEST_P(dgemmtAPI, FunctionalTest) bool is_mem_test = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = 10*n*k*testinghelpers::getEpsilon(); + // Check gtestsuite gemmt.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemmt/sgemmt_generic.cpp b/gtestsuite/testsuite/level3/gemmt/sgemmt_generic.cpp index e067a684e..24144670f 100644 --- a/gtestsuite/testsuite/level3/gemmt/sgemmt_generic.cpp +++ b/gtestsuite/testsuite/level3/gemmt/sgemmt_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -81,7 +81,17 @@ TEST_P(sgemmtTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*n*k*testinghelpers::getEpsilon(); + // Check gtestsuite gemmt.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/gemmt/zgemmt_generic.cpp b/gtestsuite/testsuite/level3/gemmt/zgemmt_generic.cpp index 7c8a4c8ec..35added0a 100644 --- a/gtestsuite/testsuite/level3/gemmt/zgemmt_generic.cpp +++ b/gtestsuite/testsuite/level3/gemmt/zgemmt_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.s Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -81,7 +81,18 @@ TEST_P(zgemmtTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = (std::max)(n,k)*testinghelpers::getEpsilon(); + // Check gtestsuite gemmt.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/hemm/chemm_generic.cpp b/gtestsuite/testsuite/level3/hemm/chemm_generic.cpp index 173aa8777..6d4bc8b8c 100644 --- a/gtestsuite/testsuite/level3/hemm/chemm_generic.cpp +++ b/gtestsuite/testsuite/level3/hemm/chemm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,21 @@ TEST_P(chemmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite hemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/hemm/zhemm_generic.cpp b/gtestsuite/testsuite/level3/hemm/zhemm_generic.cpp index f509cb888..bfe287c12 100644 --- a/gtestsuite/testsuite/level3/hemm/zhemm_generic.cpp +++ b/gtestsuite/testsuite/level3/hemm/zhemm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,21 @@ TEST_P(zhemmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite hemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/her2k/cher2k_generic.cpp b/gtestsuite/testsuite/level3/her2k/cher2k_generic.cpp index b87a83395..80c12d105 100644 --- a/gtestsuite/testsuite/level3/her2k/cher2k_generic.cpp +++ b/gtestsuite/testsuite/level3/her2k/cher2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -64,9 +64,9 @@ TEST_P(cher2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -80,12 +80,22 @@ TEST_P(cher2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 2*m*k*testinghelpers::getEpsilon(); + // Check gtestsuite her2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == 0.0f || beta == 1.0f)) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_her2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_her2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class cher2kTestPrint { @@ -96,7 +106,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); scomplex alpha = std::get<6>(str.param); float beta = std::get<7>(str.param); @@ -113,7 +123,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -140,8 +150,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(scomplex{2.0, -1.0}, scomplex{-2.0, 3.0}), // alpha ::testing::Values(-3.0, 2.0), // beta ::testing::Values(gtint_t(0), gtint_t(5)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/her2k/her2k.h b/gtestsuite/testsuite/level3/her2k/her2k.h index 9033e6137..a7725ca8e 100644 --- a/gtestsuite/testsuite/level3/her2k/her2k.h +++ b/gtestsuite/testsuite/level3/her2k/her2k.h @@ -47,7 +47,7 @@ the matrix multiplication * @param[in] transb specifies the form of op( B ) to be used in the matrix multiplication - * @param[in] m specifies the number of rows and cols of the matrix + * @param[in] n specifies the number of rows and cols of the matrix op( A ) and rows of the matrix C and B * @param[in] k specifies the number of columns of the matrix op( B ) and the number of columns of the matrix C @@ -65,20 +65,20 @@ */ template::real_type> -static void her2k_(char uplo, char transa, gtint_t m, gtint_t k, T* alpha, +static void her2k_(char uplo, char transa, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, RT* beta, T* cp, gtint_t ldc ) { if constexpr (std::is_same::value) - cher2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + cher2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else if constexpr (std::is_same::value) - zher2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + zher2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else throw std::runtime_error("Error in testsuite/level3/her2k.h: Invalid typename in her2k_()."); } template::real_type> static void cblas_her2k(char storage, char uplo, char transa, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, RT* beta, T* cp, gtint_t ldc) { enum CBLAS_ORDER cblas_order; @@ -90,16 +90,16 @@ static void cblas_her2k(char storage, char uplo, char transa, testinghelpers::char_to_cblas_trans( transa, &cblas_transa ); if constexpr (std::is_same::value) - cblas_cher2k( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, bp, ldb, *beta, cp, ldc ); + cblas_cher2k( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, bp, ldb, *beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_zher2k( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, bp, ldb, *beta, cp, ldc ); + cblas_zher2k( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, bp, ldb, *beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/her2k.h: Invalid typename in cblas_her2k()."); } template::real_type> static void typed_her2k(char storage, char uplo, char trnsa, char trnsb, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, RT* beta, T* cp, gtint_t ldc) { trans_t transa, transb; @@ -114,7 +114,7 @@ static void typed_her2k(char storage, char uplo, char trnsa, char trnsb, rsa=rsb=rsc=1; csa=csb=csc=1; - /* a = m x k b = k x n c = m x n */ + /* a = n x k b = k x n c = n x n */ if( (storage == 'c') || (storage == 'C') ) { csa = lda ; csb = ldb ; @@ -127,19 +127,19 @@ static void typed_her2k(char storage, char uplo, char trnsa, char trnsb, } if constexpr (std::is_same::value) - bli_sher2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_sher2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_dher2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_dher2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_cher2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_cher2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_zher2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_zher2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else throw std::runtime_error("Error in testsuite/level3/her2k.h: Invalid typename in typed_her2k()."); } template::real_type> -static void her2k( char storage, char uplo, char transa, char transb, gtint_t m, gtint_t k, +static void her2k( char storage, char uplo, char transa, char transb, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, RT* beta, T* cp, gtint_t ldc ) { @@ -152,14 +152,14 @@ static void her2k( char storage, char uplo, char transa, char transb, gtint_t m, #ifdef TEST_BLAS if( storage == 'c' || storage == 'C' ) - her2k_( uplo, transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + her2k_( uplo, transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/her2k.h: BLAS interface cannot be tested for row-major order."); #elif TEST_CBLAS - cblas_her2k( storage, uplo, transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + cblas_her2k( storage, uplo, transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); #elif TEST_BLIS_TYPED - typed_her2k( storage, uplo, transa, transb, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + typed_her2k( storage, uplo, transa, transb, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); #else throw std::runtime_error("Error in testsuite/level3/her2k.h: No interfaces are set to be tested."); #endif diff --git a/gtestsuite/testsuite/level3/her2k/test_her2k.h b/gtestsuite/testsuite/level3/her2k/test_her2k.h index 18ab391cd..6c65ffd79 100644 --- a/gtestsuite/testsuite/level3/her2k/test_her2k.h +++ b/gtestsuite/testsuite/level3/her2k/test_her2k.h @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -42,23 +42,23 @@ template::real_type> void test_her2k( char storage, char uplo, char transa, char transb, - gtint_t m, gtint_t k, gtint_t lda_inc, gtint_t ldb_inc, gtint_t ldc_inc, + gtint_t n, gtint_t k, gtint_t lda_inc, gtint_t ldb_inc, gtint_t ldc_inc, T alpha, RT beta, double thresh ) { // Compute the leading dimensions of a, b, and c. - gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, m, k, lda_inc ); - gtint_t ldb = testinghelpers::get_leading_dimension( storage, transb, m, k, ldb_inc ); - gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', m, m, ldc_inc ); + gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, n, k, lda_inc ); + gtint_t ldb = testinghelpers::get_leading_dimension( storage, transb, n, k, ldb_inc ); + gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', n, n, ldc_inc ); //---------------------------------------------------------- // Initialize matrics with random numbers //---------------------------------------------------------- - std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, m, k, lda ); - std::vector b = testinghelpers::get_random_matrix( -5, 2, storage, transb, m, k, ldb ); + std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, n, k, lda ); + std::vector b = testinghelpers::get_random_matrix( -5, 2, storage, transb, n, k, ldb ); // Since matrix C, stored in c, is symmetric and we only use the upper or lower // part in the computation of her2k and zero-out the rest to ensure // that code operates as expected. - std::vector c = testinghelpers::get_random_matrix(-3, 5, storage, uplo, m, ldc ); + std::vector c = testinghelpers::get_random_matrix(-3, 5, storage, uplo, n, ldc ); // Create a copy of c so that we can check reference results. std::vector c_ref(c); @@ -66,17 +66,17 @@ void test_her2k( char storage, char uplo, char transa, char transb, //---------------------------------------------------------- // Call BLIS function //---------------------------------------------------------- - her2k( storage, uplo, transa, transb, m, k, &alpha, a.data(), lda, + her2k( storage, uplo, transa, transb, n, k, &alpha, a.data(), lda, b.data(), ldb, &beta, c.data(), ldc ); //---------------------------------------------------------- // Call reference implementation. //---------------------------------------------------------- - testinghelpers::ref_her2k( storage, uplo, transa, transb, m, k, &alpha, + testinghelpers::ref_her2k( storage, uplo, transa, transb, n, k, &alpha, a.data(), lda, b.data(), ldb, beta, c_ref.data(), ldc ); //---------------------------------------------------------- // check component-wise error. //---------------------------------------------------------- - computediff( storage, m, m, c.data(), c_ref.data(), ldc, thresh ); + computediff( storage, n, n, c.data(), c_ref.data(), ldc, thresh ); } diff --git a/gtestsuite/testsuite/level3/her2k/zher2k_generic.cpp b/gtestsuite/testsuite/level3/her2k/zher2k_generic.cpp index 2ae305c08..6013a9b99 100644 --- a/gtestsuite/testsuite/level3/her2k/zher2k_generic.cpp +++ b/gtestsuite/testsuite/level3/her2k/zher2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -64,9 +64,9 @@ TEST_P(zher2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -80,12 +80,22 @@ TEST_P(zher2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 2*m*k*testinghelpers::getEpsilon(); + // Check gtestsuite her2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == 0.0 || beta == 1.0)) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_her2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_her2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class zher2kTestPrint { @@ -96,7 +106,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); dcomplex alpha = std::get<6>(str.param); double beta = std::get<7>(str.param); @@ -113,7 +123,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -140,8 +150,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(dcomplex{2.0, -1.0}, dcomplex{-2.0, 3.0}), // alpha ::testing::Values(4.0, -1.0), // beta ::testing::Values(gtint_t(0), gtint_t(3)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/herk/cherk_generic.cpp b/gtestsuite/testsuite/level3/herk/cherk_generic.cpp index 868b637d3..f817ce2d5 100644 --- a/gtestsuite/testsuite/level3/herk/cherk_generic.cpp +++ b/gtestsuite/testsuite/level3/herk/cherk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -60,8 +60,8 @@ TEST_P(cherkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -75,12 +75,22 @@ TEST_P(cherkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite herk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == 0.0f || k == 0) && (beta == 0.0f || beta == 1.0f)) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_herk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_herk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class cherkTestPrint { @@ -90,7 +100,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); float alpha = std::get<5>(str.param); float beta = std::get<6>(str.param); @@ -106,7 +116,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -130,8 +140,8 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','c'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(-2.0, 3.0), // alpha ::testing::Values(4.0, -1.0), // beta ::testing::Values(gtint_t(0), gtint_t(2)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/herk/test_herk.h b/gtestsuite/testsuite/level3/herk/test_herk.h index a28336656..46f0bbfcb 100644 --- a/gtestsuite/testsuite/level3/herk/test_herk.h +++ b/gtestsuite/testsuite/level3/herk/test_herk.h @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -41,39 +41,39 @@ #include template::real_type> -void test_herk( char storage, char uplo, char transa, gtint_t m, gtint_t k, +void test_herk( char storage, char uplo, char transa, gtint_t n, gtint_t k, gtint_t lda_inc, gtint_t ldc_inc, RT alpha, RT beta, double thresh ) { // Compute the leading dimensions of a, b, and c. - gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, m, k, lda_inc ); - gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', m, m, ldc_inc ); + gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, n, k, lda_inc ); + gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', n, n, ldc_inc ); //---------------------------------------------------------- // Initialize matrics with random integer numbers. //---------------------------------------------------------- - std::vector a = testinghelpers::get_random_matrix( -5, 2, storage, transa, m, k, lda ); + std::vector a = testinghelpers::get_random_matrix( -5, 2, storage, transa, n, k, lda ); // Since matrix C, stored in c, is symmetric, we only use the upper or lower // part in the computation of herk and zero-out the rest to ensure // that code operates as expected. - std::vector c = testinghelpers::get_random_matrix( -8, 12, storage, uplo, m, ldc ); + std::vector c = testinghelpers::get_random_matrix( -8, 12, storage, uplo, n, ldc ); // Create a copy of c so that we can check reference results. std::vector c_ref(c); //---------------------------------------------------------- // Call BLIS function //---------------------------------------------------------- - herk( storage, uplo, transa, m, k, &alpha, a.data(), lda, + herk( storage, uplo, transa, n, k, &alpha, a.data(), lda, &beta, c.data(), ldc ); //---------------------------------------------------------- // Call reference implementation. //---------------------------------------------------------- - testinghelpers::ref_herk( storage, uplo, transa, m, k, alpha, + testinghelpers::ref_herk( storage, uplo, transa, n, k, alpha, a.data(), lda, beta, c_ref.data(), ldc ); //---------------------------------------------------------- // check component-wise error. //---------------------------------------------------------- - computediff( storage, m, m, c.data(), c_ref.data(), ldc, thresh ); + computediff( storage, n, n, c.data(), c_ref.data(), ldc, thresh ); } diff --git a/gtestsuite/testsuite/level3/herk/zherk_generic.cpp b/gtestsuite/testsuite/level3/herk/zherk_generic.cpp index b3d89854c..b35b39592 100644 --- a/gtestsuite/testsuite/level3/herk/zherk_generic.cpp +++ b/gtestsuite/testsuite/level3/herk/zherk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -60,8 +60,8 @@ TEST_P(zherkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -75,12 +75,22 @@ TEST_P(zherkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite herk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == 0.0 || k == 0) && (beta == 0.0 || beta == 1.0)) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_herk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_herk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class zherkTestPrint { @@ -90,7 +100,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); double alpha = std::get<5>(str.param); double beta = std::get<6>(str.param); @@ -106,7 +116,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -130,8 +140,8 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','c'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(2.0, -1.0), // alpha ::testing::Values(-3.0, 2.0), // beta ::testing::Values(gtint_t(0), gtint_t(4)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/symm/csymm_generic.cpp b/gtestsuite/testsuite/level3/symm/csymm_generic.cpp index 72e84c906..b119385ba 100644 --- a/gtestsuite/testsuite/level3/symm/csymm_generic.cpp +++ b/gtestsuite/testsuite/level3/symm/csymm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,21 @@ TEST_P(csymmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite symm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/symm/dsymm_generic.cpp b/gtestsuite/testsuite/level3/symm/dsymm_generic.cpp index 34d4fdb47..ca17969e4 100644 --- a/gtestsuite/testsuite/level3/symm/dsymm_generic.cpp +++ b/gtestsuite/testsuite/level3/symm/dsymm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,20 @@ TEST_P(dsymmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = 30*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite symm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/symm/ssymm_generic.cpp b/gtestsuite/testsuite/level3/symm/ssymm_generic.cpp index 749b7a7fc..2a31876f4 100644 --- a/gtestsuite/testsuite/level3/symm/ssymm_generic.cpp +++ b/gtestsuite/testsuite/level3/symm/ssymm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,20 @@ TEST_P(ssymmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = 8*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite symm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/symm/zsymm_generic.cpp b/gtestsuite/testsuite/level3/symm/zsymm_generic.cpp index a6c163816..569fa02a9 100644 --- a/gtestsuite/testsuite/level3/symm/zsymm_generic.cpp +++ b/gtestsuite/testsuite/level3/symm/zsymm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -83,7 +83,21 @@ TEST_P(zsymmTest, RandomData) gtint_t ldc_inc = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite symm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/syr2k/csyr2k_generic.cpp b/gtestsuite/testsuite/level3/syr2k/csyr2k_generic.cpp index 2ee790330..2a55fd117 100644 --- a/gtestsuite/testsuite/level3/syr2k/csyr2k_generic.cpp +++ b/gtestsuite/testsuite/level3/syr2k/csyr2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -63,9 +63,9 @@ TEST_P(csyr2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -79,12 +79,23 @@ TEST_P(csyr2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syr2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syr2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_syr2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class csyr2kTestPrint { @@ -95,7 +106,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); scomplex alpha = std::get<6>(str.param); scomplex beta = std::get<7>(str.param); @@ -112,7 +123,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -140,8 +151,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(scomplex{2.0, -1.0}, scomplex{-2.0, 3.0}), // alpha ::testing::Values(scomplex{-3.0, 2.0}, scomplex{4.0, -1.0}), // beta ::testing::Values(gtint_t(0), gtint_t(2)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/syr2k/dsyr2k_generic.cpp b/gtestsuite/testsuite/level3/syr2k/dsyr2k_generic.cpp index f990ef6ac..2b6379ca2 100644 --- a/gtestsuite/testsuite/level3/syr2k/dsyr2k_generic.cpp +++ b/gtestsuite/testsuite/level3/syr2k/dsyr2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -63,9 +63,9 @@ TEST_P(dsyr2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -79,12 +79,22 @@ TEST_P(dsyr2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syr2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syr2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_syr2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class dsyr2kTestPrint { @@ -95,7 +105,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); double alpha = std::get<6>(str.param); double beta = std::get<7>(str.param); @@ -112,7 +122,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -138,8 +148,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values( 1.0, -2.0), // alpha ::testing::Values(-1.0, 1.0), // beta ::testing::Values(gtint_t(0), gtint_t(4)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/syr2k/ssyr2k_generic.cpp b/gtestsuite/testsuite/level3/syr2k/ssyr2k_generic.cpp index 4b4cc8ccd..6fc5daf24 100644 --- a/gtestsuite/testsuite/level3/syr2k/ssyr2k_generic.cpp +++ b/gtestsuite/testsuite/level3/syr2k/ssyr2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -63,9 +63,9 @@ TEST_P(ssyr2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -79,12 +79,22 @@ TEST_P(ssyr2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = 10*m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syr2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syr2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_syr2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class ssyr2kTestPrint { @@ -95,7 +105,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); float alpha = std::get<6>(str.param); float beta = std::get<7>(str.param); @@ -112,7 +122,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -138,8 +148,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values( 1.0, -2.0), // alpha ::testing::Values(-1.0, 1.0), // beta ::testing::Values(gtint_t(0), gtint_t(7)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/syr2k/syr2k.h b/gtestsuite/testsuite/level3/syr2k/syr2k.h index 08b1e2567..88bbe05ec 100644 --- a/gtestsuite/testsuite/level3/syr2k/syr2k.h +++ b/gtestsuite/testsuite/level3/syr2k/syr2k.h @@ -47,7 +47,7 @@ the matrix multiplication * @param[in] transb specifies the form of op( B ) to be used in the matrix multiplication - * @param[in] m specifies the number of rows and cols of the matrix + * @param[in] n specifies the number of rows and cols of the matrix op( A ) and rows of the matrix C and B * @param[in] k specifies the number of columns of the matrix op( B ) and the number of columns of the matrix C @@ -65,24 +65,24 @@ */ template -static void syr2k_(char uplo, char transa, gtint_t m, gtint_t k, T* alpha, +static void syr2k_(char uplo, char transa, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, T* beta, T* cp, gtint_t ldc ) { if constexpr (std::is_same::value) - ssyr2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + ssyr2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else if constexpr (std::is_same::value) - dsyr2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + dsyr2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else if constexpr (std::is_same::value) - csyr2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + csyr2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else if constexpr (std::is_same::value) - zsyr2k_( &uplo, &transa, &m, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); + zsyr2k_( &uplo, &transa, &n, &k, alpha, ap, &lda, bp, &ldb, beta, cp, &ldc ); else throw std::runtime_error("Error in testsuite/level3/syr2k.h: Invalid typename in syr2k_()."); } template static void cblas_syr2k(char storage, char uplo, char transa, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, T* beta, T* cp, gtint_t ldc) { enum CBLAS_ORDER cblas_order; @@ -94,20 +94,20 @@ static void cblas_syr2k(char storage, char uplo, char transa, testinghelpers::char_to_cblas_trans( transa, &cblas_transa ); if constexpr (std::is_same::value) - cblas_ssyr2k( cblas_order, cblas_uplo, cblas_transa, m, k, *alpha, ap, lda, bp, ldb, *beta, cp, ldc ); + cblas_ssyr2k( cblas_order, cblas_uplo, cblas_transa, n, k, *alpha, ap, lda, bp, ldb, *beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_dsyr2k( cblas_order, cblas_uplo, cblas_transa, m, k, *alpha, ap, lda, bp, ldb, *beta, cp, ldc ); + cblas_dsyr2k( cblas_order, cblas_uplo, cblas_transa, n, k, *alpha, ap, lda, bp, ldb, *beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_csyr2k( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + cblas_csyr2k( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_zsyr2k( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + cblas_zsyr2k( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/syr2k.h: Invalid typename in cblas_syr2k()."); } template static void typed_syr2k(char storage, char uplo, char trnsa, char trnsb, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, T* beta, T* cp, gtint_t ldc) { trans_t transa, transb; @@ -122,7 +122,7 @@ static void typed_syr2k(char storage, char uplo, char trnsa, char trnsb, rsa=rsb=rsc=1; csa=csb=csc=1; - /* a = m x k b = k x n c = m x n */ + /* a = n x k b = k x n c = n x n */ if( (storage == 'c') || (storage == 'C') ) { csa = lda ; csb = ldb ; @@ -135,19 +135,19 @@ static void typed_syr2k(char storage, char uplo, char trnsa, char trnsb, } if constexpr (std::is_same::value) - bli_ssyr2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_ssyr2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_dsyr2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_dsyr2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_csyr2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_csyr2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_zsyr2k( blis_uplo, transa, transb, m, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); + bli_zsyr2k( blis_uplo, transa, transb, n, k, alpha, ap, rsa, csa, bp, rsb, csb, beta, cp, rsc, csc ); else throw std::runtime_error("Error in testsuite/level3/syr2k.h: Invalid typename in typed_syr2k()."); } template -static void syr2k( char storage, char uplo, char transa, char transb, gtint_t m, gtint_t k, +static void syr2k( char storage, char uplo, char transa, char transb, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* bp, gtint_t ldb, T* beta, T* cp, gtint_t ldc ) { @@ -160,14 +160,14 @@ static void syr2k( char storage, char uplo, char transa, char transb, gtint_t m, #ifdef TEST_BLAS if( storage == 'c' || storage == 'C' ) - syr2k_( uplo, transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + syr2k_( uplo, transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/syr2k.h: BLAS interface cannot be tested for row-major order."); #elif TEST_CBLAS - cblas_syr2k( storage, uplo, transa, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + cblas_syr2k( storage, uplo, transa, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); #elif TEST_BLIS_TYPED - typed_syr2k( storage, uplo, transa, transb, m, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); + typed_syr2k( storage, uplo, transa, transb, n, k, alpha, ap, lda, bp, ldb, beta, cp, ldc ); #else throw std::runtime_error("Error in testsuite/level3/syr2k.h: No interfaces are set to be tested."); #endif diff --git a/gtestsuite/testsuite/level3/syr2k/test_syr2k.h b/gtestsuite/testsuite/level3/syr2k/test_syr2k.h index da2dabb0a..27ce08b89 100644 --- a/gtestsuite/testsuite/level3/syr2k/test_syr2k.h +++ b/gtestsuite/testsuite/level3/syr2k/test_syr2k.h @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -41,24 +41,24 @@ #include template -void test_syr2k( char storage, char uplo, char transa, char transb, gtint_t m, +void test_syr2k( char storage, char uplo, char transa, char transb, gtint_t n, gtint_t k, gtint_t lda_inc, gtint_t ldb_inc, gtint_t ldc_inc, T alpha, T beta, double thresh ) { // Compute the leading dimensions of a, b, and c. - gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, m, k, lda_inc ); - gtint_t ldb = testinghelpers::get_leading_dimension( storage, transb, m, k, ldb_inc ); - gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', m, m, ldc_inc ); + gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, n, k, lda_inc ); + gtint_t ldb = testinghelpers::get_leading_dimension( storage, transb, n, k, ldb_inc ); + gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', n, n, ldc_inc ); //---------------------------------------------------------- // Initialize matrics with random integer numbers. //---------------------------------------------------------- - std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, m, k, lda ); - std::vector b = testinghelpers::get_random_matrix( -5, 2, storage, transb, m, k, ldb ); + std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, n, k, lda ); + std::vector b = testinghelpers::get_random_matrix( -5, 2, storage, transb, n, k, ldb ); // Since matrix C, stored in c, is symmetric and we only use the upper or lower // part in the computation of her2k and zero-out the rest to ensure // that code operates as expected. - std::vector c = testinghelpers::get_random_matrix(-3, 5, storage, uplo, m, ldc ); + std::vector c = testinghelpers::get_random_matrix(-3, 5, storage, uplo, n, ldc ); // Create a copy of c so that we can check reference results. std::vector c_ref(c); @@ -66,17 +66,17 @@ void test_syr2k( char storage, char uplo, char transa, char transb, gtint_t m, //---------------------------------------------------------- // Call BLIS function //---------------------------------------------------------- - syr2k( storage, uplo, transa, transb, m, k, &alpha, a.data(), lda, + syr2k( storage, uplo, transa, transb, n, k, &alpha, a.data(), lda, b.data(), ldb, &beta, c.data(), ldc ); //---------------------------------------------------------- // Call reference implementation. //---------------------------------------------------------- - testinghelpers::ref_syr2k( storage, uplo, transa, transb, m, k, alpha, + testinghelpers::ref_syr2k( storage, uplo, transa, transb, n, k, alpha, a.data(), lda, b.data(), ldb, beta, c_ref.data(), ldc ); //---------------------------------------------------------- // check component-wise error. //---------------------------------------------------------- - computediff( storage, m, m, c.data(), c_ref.data(), ldc, thresh ); + computediff( storage, n, n, c.data(), c_ref.data(), ldc, thresh ); } diff --git a/gtestsuite/testsuite/level3/syr2k/zsyr2k_generic.cpp b/gtestsuite/testsuite/level3/syr2k/zsyr2k_generic.cpp index 360087236..9ff6fe1fd 100644 --- a/gtestsuite/testsuite/level3/syr2k/zsyr2k_generic.cpp +++ b/gtestsuite/testsuite/level3/syr2k/zsyr2k_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -63,9 +63,9 @@ TEST_P(zsyr2kTest, RandomData) char transa = std::get<2>(GetParam()); // denotes whether matrix b is n,c,t,h char transb = std::get<3>(GetParam()); - // matrix size m - gtint_t m = std::get<4>(GetParam()); // matrix size n + gtint_t n = std::get<4>(GetParam()); + // matrix size k gtint_t k = std::get<5>(GetParam()); // specifies alpha value T alpha = std::get<6>(GetParam()); @@ -79,12 +79,23 @@ TEST_P(zsyr2kTest, RandomData) gtint_t ldc_inc = std::get<10>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syr2k.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (6*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syr2k( storage, uplo, transa, transb, m, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); + test_syr2k( storage, uplo, transa, transb, n, k, lda_inc, ldb_inc, ldc_inc, alpha, beta, thresh ); } class zsyr2kTestPrint { @@ -95,7 +106,7 @@ public: char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); char tsb = std::get<3>(str.param); - gtint_t m = std::get<4>(str.param); + gtint_t n = std::get<4>(str.param); gtint_t k = std::get<5>(str.param); dcomplex alpha = std::get<6>(str.param); dcomplex beta = std::get<7>(str.param); @@ -112,7 +123,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa + tsb; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -140,8 +151,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n'), // transa ::testing::Values('n'), // transb - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m ::testing::Range(gtint_t(10), gtint_t(31), 10), // n + ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(dcomplex{2.0, -1.0}, dcomplex{-2.0, 3.0}), // alpha ::testing::Values(dcomplex{-3.0, 2.0}, dcomplex{4.0, -1.0}), // beta ::testing::Values(gtint_t(0), gtint_t(2)), // increment to the leading dim of a diff --git a/gtestsuite/testsuite/level3/syrk/csyrk_generic.cpp b/gtestsuite/testsuite/level3/syrk/csyrk_generic.cpp index c87684393..6aa36c35b 100644 --- a/gtestsuite/testsuite/level3/syrk/csyrk_generic.cpp +++ b/gtestsuite/testsuite/level3/syrk/csyrk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -59,8 +59,8 @@ TEST_P(csyrkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -74,12 +74,23 @@ TEST_P(csyrkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syrk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syrk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_syrk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class csyrkTestPrint { @@ -89,7 +100,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); scomplex alpha = std::get<5>(str.param); scomplex beta = std::get<6>(str.param); @@ -105,7 +116,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -131,7 +142,7 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','t'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m + ::testing::Range(gtint_t(10), gtint_t(31), 10), // n ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(scomplex{2.0, -1.0}, scomplex{-2.0, 3.0}), // alpha ::testing::Values(scomplex{-3.0, 2.0}, scomplex{4.0, -1.0}), // beta diff --git a/gtestsuite/testsuite/level3/syrk/dsyrk_generic.cpp b/gtestsuite/testsuite/level3/syrk/dsyrk_generic.cpp index 05f1dc022..0e9f7cfb3 100644 --- a/gtestsuite/testsuite/level3/syrk/dsyrk_generic.cpp +++ b/gtestsuite/testsuite/level3/syrk/dsyrk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -59,8 +59,8 @@ TEST_P(dsyrkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -74,12 +74,22 @@ TEST_P(dsyrkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syrk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syrk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_syrk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class dsyrkTestPrint { @@ -89,7 +99,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); double alpha = std::get<5>(str.param); double beta = std::get<6>(str.param); @@ -105,7 +115,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -129,7 +139,7 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','t','c'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m + ::testing::Range(gtint_t(10), gtint_t(31), 10), // n ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values( 1.0, -2.0), // alpha ::testing::Values(-1.0, 1.0), // beta diff --git a/gtestsuite/testsuite/level3/syrk/ssyrk_generic.cpp b/gtestsuite/testsuite/level3/syrk/ssyrk_generic.cpp index 6ce9ab89b..2a5e8cfc1 100644 --- a/gtestsuite/testsuite/level3/syrk/ssyrk_generic.cpp +++ b/gtestsuite/testsuite/level3/syrk/ssyrk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -59,8 +59,8 @@ TEST_P(ssyrkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -74,12 +74,22 @@ TEST_P(ssyrkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syrk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syrk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_syrk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class ssyrkTestPrint { @@ -89,7 +99,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); float alpha = std::get<5>(str.param); float beta = std::get<6>(str.param); @@ -105,7 +115,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); str_name = str_name + "_a" + alpha_str; @@ -129,7 +139,7 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','t','c'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m + ::testing::Range(gtint_t(10), gtint_t(31), 10), // n ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values( 1.0, -2.0), // alpha ::testing::Values(-1.0, 1.0), // beta diff --git a/gtestsuite/testsuite/level3/syrk/syrk.h b/gtestsuite/testsuite/level3/syrk/syrk.h index ba9d99ffe..5dda847bc 100644 --- a/gtestsuite/testsuite/level3/syrk/syrk.h +++ b/gtestsuite/testsuite/level3/syrk/syrk.h @@ -60,24 +60,24 @@ */ template -static void syrk_(char uplo, char transa, gtint_t m, gtint_t k, T* alpha, +static void syrk_(char uplo, char transa, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* beta, T* cp, gtint_t ldc ) { if constexpr (std::is_same::value) - ssyrk_( &uplo, &transa, &m, &k, alpha, ap, &lda, beta, cp, &ldc ); + ssyrk_( &uplo, &transa, &n, &k, alpha, ap, &lda, beta, cp, &ldc ); else if constexpr (std::is_same::value) - dsyrk_( &uplo, &transa, &m, &k, alpha, ap, &lda, beta, cp, &ldc ); + dsyrk_( &uplo, &transa, &n, &k, alpha, ap, &lda, beta, cp, &ldc ); else if constexpr (std::is_same::value) - csyrk_( &uplo, &transa, &m, &k, alpha, ap, &lda, beta, cp, &ldc ); + csyrk_( &uplo, &transa, &n, &k, alpha, ap, &lda, beta, cp, &ldc ); else if constexpr (std::is_same::value) - zsyrk_( &uplo, &transa, &m, &k, alpha, ap, &lda, beta, cp, &ldc ); + zsyrk_( &uplo, &transa, &n, &k, alpha, ap, &lda, beta, cp, &ldc ); else throw std::runtime_error("Error in testsuite/level3/syrk.h: Invalid typename in syrk_()."); } template static void cblas_syrk(char storage, char uplo, char trnsa, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* beta, T* cp, gtint_t ldc) { enum CBLAS_ORDER cblas_order; @@ -89,20 +89,20 @@ static void cblas_syrk(char storage, char uplo, char trnsa, testinghelpers::char_to_cblas_trans( trnsa, &cblas_transa ); if constexpr (std::is_same::value) - cblas_ssyrk( cblas_order, cblas_uplo, cblas_transa, m, k, *alpha, ap, lda, *beta, cp, ldc ); + cblas_ssyrk( cblas_order, cblas_uplo, cblas_transa, n, k, *alpha, ap, lda, *beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_dsyrk( cblas_order, cblas_uplo, cblas_transa, m, k, *alpha, ap, lda, *beta, cp, ldc ); + cblas_dsyrk( cblas_order, cblas_uplo, cblas_transa, n, k, *alpha, ap, lda, *beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_csyrk( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, beta, cp, ldc ); + cblas_csyrk( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, beta, cp, ldc ); else if constexpr (std::is_same::value) - cblas_zsyrk( cblas_order, cblas_uplo, cblas_transa, m, k, alpha, ap, lda, beta, cp, ldc ); + cblas_zsyrk( cblas_order, cblas_uplo, cblas_transa, n, k, alpha, ap, lda, beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/syrk.h: Invalid typename in cblas_syrk()."); } template static void typed_syrk(char storage, char uplo, char trnsa, - gtint_t m, gtint_t k, T* alpha, T* ap, gtint_t lda, + gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* beta, T* cp, gtint_t ldc) { trans_t transa; @@ -115,7 +115,7 @@ static void typed_syrk(char storage, char uplo, char trnsa, rsa=rsc=1; csa=csc=1; - /* a = m x k c = m x m */ + /* a = n x k c = n x n */ if( (storage == 'c') || (storage == 'C') ) { csa = lda ; csc = ldc ; @@ -126,19 +126,19 @@ static void typed_syrk(char storage, char uplo, char trnsa, } if constexpr (std::is_same::value) - bli_ssyrk( blis_uplo, transa, m, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); + bli_ssyrk( blis_uplo, transa, n, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_dsyrk( blis_uplo, transa, m, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); + bli_dsyrk( blis_uplo, transa, n, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_csyrk( blis_uplo, transa, m, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); + bli_csyrk( blis_uplo, transa, n, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); else if constexpr (std::is_same::value) - bli_zsyrk( blis_uplo, transa, m, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); + bli_zsyrk( blis_uplo, transa, n, k, alpha, ap, rsa, csa, beta, cp, rsc, csc ); else throw std::runtime_error("Error in testsuite/level3/syrk.h: Invalid typename in typed_syrk()."); } template -static void syrk( char storage, char uplo, char transa, gtint_t m, gtint_t k, +static void syrk( char storage, char uplo, char transa, gtint_t n, gtint_t k, T* alpha, T* ap, gtint_t lda, T* beta, T* cp, gtint_t ldc ) { @@ -150,13 +150,13 @@ static void syrk( char storage, char uplo, char transa, gtint_t m, gtint_t k, #ifdef TEST_BLAS if( storage == 'c' || storage == 'C' ) - syrk_( uplo, transa, m, k, alpha, ap, lda, beta, cp, ldc ); + syrk_( uplo, transa, n, k, alpha, ap, lda, beta, cp, ldc ); else throw std::runtime_error("Error in testsuite/level3/syrk.h: BLAS interface cannot be tested for row-major order."); #elif TEST_CBLAS - cblas_syrk( storage, uplo, transa, m, k, alpha, ap, lda, beta, cp, ldc ); + cblas_syrk( storage, uplo, transa, n, k, alpha, ap, lda, beta, cp, ldc ); #elif TEST_BLIS_TYPED - typed_syrk( storage, uplo, transa, m, k, alpha, ap, lda, beta, cp, ldc ); + typed_syrk( storage, uplo, transa, n, k, alpha, ap, lda, beta, cp, ldc ); #else throw std::runtime_error("Error in testsuite/level3/syrk.h: No interfaces are set to be tested."); #endif diff --git a/gtestsuite/testsuite/level3/syrk/test_syrk.h b/gtestsuite/testsuite/level3/syrk/test_syrk.h index 464f60882..160055c57 100644 --- a/gtestsuite/testsuite/level3/syrk/test_syrk.h +++ b/gtestsuite/testsuite/level3/syrk/test_syrk.h @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -41,36 +41,36 @@ #include template -void test_syrk( char storage, char uplo, char transa, gtint_t m, gtint_t k, +void test_syrk( char storage, char uplo, char transa, gtint_t n, gtint_t k, gtint_t lda_inc, gtint_t ldc_inc, T alpha, T beta, double thresh ) { // Compute the leading dimensions of a, b, and c. - gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, m, k, lda_inc ); - gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', m, m, ldc_inc ); + gtint_t lda = testinghelpers::get_leading_dimension( storage, transa, n, k, lda_inc ); + gtint_t ldc = testinghelpers::get_leading_dimension( storage, 'n', n, n, ldc_inc ); //---------------------------------------------------------- // Initialize matrics with random integer numbers. //---------------------------------------------------------- - std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, m, k, lda ); + std::vector a = testinghelpers::get_random_matrix( -2, 8, storage, transa, n, k, lda ); // Since matrix C, stored in c, is symmetric, we only use the upper or lower // part in the computation of syrk and zero-out the rest to ensure // that code operates as expected. - std::vector c = testinghelpers::get_random_matrix( -3, 5, storage, uplo, m, ldc ); + std::vector c = testinghelpers::get_random_matrix( -3, 5, storage, uplo, n, ldc ); // Create a copy of c so that we can check reference results. std::vector c_ref(c); //---------------------------------------------------------- // Call BLIS function //---------------------------------------------------------- - syrk( storage, uplo, transa, m, k, &alpha, a.data(), lda, + syrk( storage, uplo, transa, n, k, &alpha, a.data(), lda, &beta, c.data(), ldc ); //---------------------------------------------------------- // Call reference implementation. //---------------------------------------------------------- - testinghelpers::ref_syrk( storage, uplo, transa, m, k, alpha, + testinghelpers::ref_syrk( storage, uplo, transa, n, k, alpha, a.data(), lda, beta, c_ref.data(), ldc ); //---------------------------------------------------------- // check component-wise error. //---------------------------------------------------------- - computediff( storage, m, m, c.data(), c_ref.data(), ldc, thresh ); + computediff( storage, n, n, c.data(), c_ref.data(), ldc, thresh ); } diff --git a/gtestsuite/testsuite/level3/syrk/zsyrk_generic.cpp b/gtestsuite/testsuite/level3/syrk/zsyrk_generic.cpp index 406d137d4..0c26de8b5 100644 --- a/gtestsuite/testsuite/level3/syrk/zsyrk_generic.cpp +++ b/gtestsuite/testsuite/level3/syrk/zsyrk_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -59,8 +59,8 @@ TEST_P(zsyrkTest, RandomData) char uplo = std::get<1>(GetParam()); // denotes whether matrix a is n,c,t,h char transa = std::get<2>(GetParam()); - // matrix size m - gtint_t m = std::get<3>(GetParam()); + // matrix size n + gtint_t n = std::get<3>(GetParam()); // matrix size k gtint_t k = std::get<4>(GetParam()); // specifies alpha value @@ -74,12 +74,23 @@ TEST_P(zsyrkTest, RandomData) gtint_t ldc_inc = std::get<8>(GetParam()); // Set the threshold for the errors: - double thresh = m*k*testinghelpers::getEpsilon(); + // Check gtestsuite syrk.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters //---------------------------------------------------------- - test_syrk( storage, uplo, transa, m, k, lda_inc, ldc_inc, alpha, beta, thresh ); + test_syrk( storage, uplo, transa, n, k, lda_inc, ldc_inc, alpha, beta, thresh ); } class zsyrkTestPrint { @@ -89,7 +100,7 @@ public: char sfm = std::get<0>(str.param); char uplo = std::get<1>(str.param); char tsa = std::get<2>(str.param); - gtint_t m = std::get<3>(str.param); + gtint_t n = std::get<3>(str.param); gtint_t k = std::get<4>(str.param); dcomplex alpha = std::get<5>(str.param); dcomplex beta = std::get<6>(str.param); @@ -105,7 +116,7 @@ public: str_name = str_name + "_" + sfm+sfm+sfm; str_name = str_name + "_" + uplo; str_name = str_name + "_" + tsa; - str_name = str_name + "_" + std::to_string(m); + str_name = str_name + "_" + std::to_string(n); str_name = str_name + "_" + std::to_string(k); std::string alpha_str = ( alpha.real > 0) ? std::to_string(int(alpha.real)) : ("m" + std::to_string(int(std::abs(alpha.real)))); alpha_str = alpha_str + "pi" + (( alpha.imag > 0) ? std::to_string(int(alpha.imag)) : ("m" + std::to_string(int(std::abs(alpha.imag))))); @@ -131,7 +142,7 @@ INSTANTIATE_TEST_SUITE_P( ), // storage format ::testing::Values('u','l'), // u:upper, l:lower ::testing::Values('n','t'), // transa - ::testing::Range(gtint_t(10), gtint_t(31), 10), // m + ::testing::Range(gtint_t(10), gtint_t(31), 10), // n ::testing::Range(gtint_t(10), gtint_t(31), 10), // k ::testing::Values(dcomplex{2.0, -1.0}, dcomplex{-2.0, 3.0}), // alpha ::testing::Values(dcomplex{-3.0, 2.0}, dcomplex{4.0, -1.0}), // beta diff --git a/gtestsuite/testsuite/level3/trmm/ctrmm_generic.cpp b/gtestsuite/testsuite/level3/trmm/ctrmm_generic.cpp index 5887027a5..ddfd6ff5c 100644 --- a/gtestsuite/testsuite/level3/trmm/ctrmm_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm/ctrmm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,18 @@ TEST_P(ctrmmTest, RandomData) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm/dtrmm_generic.cpp b/gtestsuite/testsuite/level3/trmm/dtrmm_generic.cpp index 1c9c251bd..1fcc033ad 100644 --- a/gtestsuite/testsuite/level3/trmm/dtrmm_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm/dtrmm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,17 @@ TEST_P(dtrmmTest, RandomData) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm/strmm_generic.cpp b/gtestsuite/testsuite/level3/trmm/strmm_generic.cpp index 6851e1f52..d2a40c386 100644 --- a/gtestsuite/testsuite/level3/trmm/strmm_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm/strmm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,17 @@ TEST_P(strmmTest, RandomData) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = 20*m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm/ztrmm_generic.cpp b/gtestsuite/testsuite/level3/trmm/ztrmm_generic.cpp index d6ad3e02c..0163efda2 100644 --- a/gtestsuite/testsuite/level3/trmm/ztrmm_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm/ztrmm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,18 @@ TEST_P(ztrmmTest, RandomData) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm3/ctrmm3_generic.cpp b/gtestsuite/testsuite/level3/trmm3/ctrmm3_generic.cpp index 839c47298..d6cea18f0 100644 --- a/gtestsuite/testsuite/level3/trmm3/ctrmm3_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm3/ctrmm3_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -88,7 +88,21 @@ TEST_P(ctrmm3Test, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm3.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm3/dtrmm3_generic.cpp b/gtestsuite/testsuite/level3/trmm3/dtrmm3_generic.cpp index 343a57366..f0480fc9d 100644 --- a/gtestsuite/testsuite/level3/trmm3/dtrmm3_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm3/dtrmm3_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -88,7 +88,20 @@ TEST_P(dtrmm3Test, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm3.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm3/strmm3_generic.cpp b/gtestsuite/testsuite/level3/trmm3/strmm3_generic.cpp index 2d52b620e..3e5615d55 100644 --- a/gtestsuite/testsuite/level3/trmm3/strmm3_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm3/strmm3_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -88,7 +88,20 @@ TEST_P(strmm3Test, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm3.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trmm3/ztrmm3_generic.cpp b/gtestsuite/testsuite/level3/trmm3/ztrmm3_generic.cpp index 6ef3931d7..b982117c1 100644 --- a/gtestsuite/testsuite/level3/trmm3/ztrmm3_generic.cpp +++ b/gtestsuite/testsuite/level3/trmm3/ztrmm3_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -88,7 +88,21 @@ TEST_P(ztrmm3Test, RandomData) gtint_t ldc_inc = std::get<12>(GetParam()); // Set the threshold for the errors: - double thresh = m*n*testinghelpers::getEpsilon(); + // Check gtestsuite trmm3.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if (alpha == testinghelpers::ZERO() && + (beta == testinghelpers::ZERO() || beta == testinghelpers::ONE())) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = (3*m+1)*testinghelpers::getEpsilon(); + else + thresh = (3*n+1)*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trsm/ctrsm_evt_testing.cpp b/gtestsuite/testsuite/level3/trsm/ctrsm_evt_testing.cpp index 66a452934..2704af1fb 100644 --- a/gtestsuite/testsuite/level3/trsm/ctrsm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/trsm/ctrsm_evt_testing.cpp @@ -85,7 +85,18 @@ TEST_P(ctrsmEVT, NaNInfCheck) EVT_TYPE b_init = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = (std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -200,4 +211,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(NO_EVT) // EVT test for B ), ::ctrsmEVTPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/ctrsm_generic.cpp b/gtestsuite/testsuite/level3/trsm/ctrsm_generic.cpp index 1ebd39bf7..8c3c2dd84 100644 --- a/gtestsuite/testsuite/level3/trsm/ctrsm_generic.cpp +++ b/gtestsuite/testsuite/level3/trsm/ctrsm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,18 @@ TEST_P(ctrsmAPI, FunctionalTest) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = 1.5*(std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -220,4 +231,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0), gtint_t(93)) // increment to the leading dim of b ), ::ctrsmPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/dtrsm_evt_testing.cpp b/gtestsuite/testsuite/level3/trsm/dtrsm_evt_testing.cpp index 0e2484691..393de9422 100644 --- a/gtestsuite/testsuite/level3/trsm/dtrsm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/trsm/dtrsm_evt_testing.cpp @@ -85,7 +85,17 @@ TEST_P(dtrsmEVTTest, Unit_Tester) EVT_TYPE b_init = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = (std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -161,4 +171,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(NO_EVT, NaN, INF, NaN_INF) // EVT test for B ), ::dtrsmEVTTestPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/dtrsm_generic.cpp b/gtestsuite/testsuite/level3/trsm/dtrsm_generic.cpp index c44c12686..26032e842 100644 --- a/gtestsuite/testsuite/level3/trsm/dtrsm_generic.cpp +++ b/gtestsuite/testsuite/level3/trsm/dtrsm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-24, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,17 @@ TEST_P(dtrsmTest, Accuracy_test) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = 1.5*(std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters diff --git a/gtestsuite/testsuite/level3/trsm/strsm_evt_testing.cpp b/gtestsuite/testsuite/level3/trsm/strsm_evt_testing.cpp index d5719e525..230c09818 100644 --- a/gtestsuite/testsuite/level3/trsm/strsm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/trsm/strsm_evt_testing.cpp @@ -85,7 +85,17 @@ TEST_P(strsmEVT, NaNInfCheck) EVT_TYPE b_init = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = (std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -191,4 +201,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(NO_EVT) // EVT test for B ), ::strsmEVTPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/strsm_generic.cpp b/gtestsuite/testsuite/level3/trsm/strsm_generic.cpp index 253b01a0a..72ffb9e3a 100644 --- a/gtestsuite/testsuite/level3/trsm/strsm_generic.cpp +++ b/gtestsuite/testsuite/level3/trsm/strsm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,17 @@ TEST_P(strsmAPI, FunctionalTest) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = 1.5*(std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -222,4 +232,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0), gtint_t(39)) // increment to the leading dim of b ), ::strsmPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/ztrsm_evt_testing.cpp b/gtestsuite/testsuite/level3/trsm/ztrsm_evt_testing.cpp index c392a18e2..d9bc2ff6c 100644 --- a/gtestsuite/testsuite/level3/trsm/ztrsm_evt_testing.cpp +++ b/gtestsuite/testsuite/level3/trsm/ztrsm_evt_testing.cpp @@ -85,7 +85,18 @@ TEST_P(ztrsmEVT, NaNInfCheck) EVT_TYPE b_init = std::get<11>(GetParam()); // Set the threshold for the errors: - double thresh = (std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -200,4 +211,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(NO_EVT) // EVT test for B ), ::ztrsmEVTPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/level3/trsm/ztrsm_generic.cpp b/gtestsuite/testsuite/level3/trsm/ztrsm_generic.cpp index 749e4b2b1..3d9fa0c33 100644 --- a/gtestsuite/testsuite/level3/trsm/ztrsm_generic.cpp +++ b/gtestsuite/testsuite/level3/trsm/ztrsm_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -78,7 +78,18 @@ TEST_P(ztrsmAPI, FunctionalTest) gtint_t ldb_inc = std::get<9>(GetParam()); // Set the threshold for the errors: - double thresh = 1.5*(std::max)(m, n)*testinghelpers::getEpsilon(); + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + if ( side == 'l' || side == 'L' ) + thresh = 3*m*testinghelpers::getEpsilon(); + else + thresh = 3*n*testinghelpers::getEpsilon(); //---------------------------------------------------------- // Call test body using these parameters @@ -220,4 +231,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0), gtint_t(23)) // increment to the leading dim of b ), ::ztrsmPrint() - ); \ No newline at end of file + ); diff --git a/gtestsuite/testsuite/ukr/gemm/dgemm_ukernel.cpp b/gtestsuite/testsuite/ukr/gemm/dgemm_ukernel.cpp index 6c4e9fb32..df3380310 100644 --- a/gtestsuite/testsuite/ukr/gemm/dgemm_ukernel.cpp +++ b/gtestsuite/testsuite/ukr/gemm/dgemm_ukernel.cpp @@ -573,8 +573,20 @@ TEST_P(dgemmSmallUkernel, gemm_small) } // reset to default signal handler testinghelpers::ProtectedBuffer::stop_signal_handler(); + // Set the threshold for the errors: - double thresh = 10 * (std::max)(n,(std::max)(k,m)) * testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (4*k+1)*testinghelpers::getEpsilon(); // call reference implementation testinghelpers::ref_gemm( storage, 'n', 'n', m, n, k, alpha, @@ -612,7 +624,19 @@ TEST_P(dgemmSmallUkernel, gemm_small) ); // Set the threshold for the errors: - double thresh = 10 * (std::max)(n,(std::max)(k,m)) * testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (4*k+1)*testinghelpers::getEpsilon(); + // call reference implementation testinghelpers::ref_gemm( storage, 'n', 'n', m, n, k, alpha, a.data(), lda, b.data(), ldb, beta, c_ref.data(), ldc); diff --git a/gtestsuite/testsuite/ukr/gemm/test_gemm_ukr.h b/gtestsuite/testsuite/ukr/gemm/test_gemm_ukr.h index 512df55fb..66e3d0c0b 100644 --- a/gtestsuite/testsuite/ukr/gemm/test_gemm_ukr.h +++ b/gtestsuite/testsuite/ukr/gemm/test_gemm_ukr.h @@ -207,7 +207,20 @@ static void test_gemmnat_ukr( // storage of all matrices A, B and C. // since A is col-storage, A' will be row-storage } - double thresh = 10 * ((std::max)(k,gtint_t(1))) * testinghelpers::getEpsilon(); + + // Set the threshold for the errors: + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + // call reference implementation testinghelpers::ref_gemm( storage, transa, transb, m, n, k, alpha, buf_a, lda, buf_b, ldb, beta, (T*)buf_cref, ldc); @@ -324,7 +337,17 @@ static void test_gemmk1_ukr( FT ukr_fp, gtint_t m, gtint_t n, gtint_t k, char st testinghelpers::ProtectedBuffer::stop_signal_handler(); // Set the threshold for the errors: - double thresh = 10 * (std::max)(n,(std::max)(k,m)) * testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); // call reference implementation testinghelpers::ref_gemm( storage, 'n', 'n', m, n, k, alpha, @@ -551,7 +574,17 @@ static void test_gemmsup_ukr( FT ukr_fp, char trnsa, char trnsb, gtint_t m, gtin testinghelpers::ProtectedBuffer::stop_signal_handler(); // Set the threshold for the errors: - double thresh = 10 * ((std::max)(k,gtint_t(1))) * testinghelpers::getEpsilon(); + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); // call reference implementation testinghelpers::ref_gemm( storage, trnsa, trnsb, m, n, k, alpha, diff --git a/gtestsuite/testsuite/ukr/gemm/zgemm_ukernel.cpp b/gtestsuite/testsuite/ukr/gemm/zgemm_ukernel.cpp index 13e964d97..d7030fab7 100644 --- a/gtestsuite/testsuite/ukr/gemm/zgemm_ukernel.cpp +++ b/gtestsuite/testsuite/ukr/gemm/zgemm_ukernel.cpp @@ -61,7 +61,22 @@ TEST_P(zgemmUkrSUP, FunctionalTest) char transa = std::get<7>(GetParam()); // transa char transb = std::get<8>(GetParam()); // transb bool is_memory_test = std::get<9>(GetParam()); // is_memory_test - double thresh = 30 * ((std::max)(k,gtint_t(10))) * testinghelpers::getEpsilon(); // Set the threshold for the errors + + // Set the threshold for the errors: + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (63*k+1)*testinghelpers::getEpsilon(); + test_complex_gemmsup_ukr(storageC, transa, transb, m, n, k, alpha, beta, thresh, kern_ptr, is_memory_test); }// end of function @@ -993,7 +1008,21 @@ TEST_P(zgemmUkrNat, MicroKernelTest) gtint_t n = std::get<5>(GetParam()); // n zgemm_ukr_ft kern_ptr = std::get<6>(GetParam()); // pointer to the gemm kernel bool is_memory_test = std::get<7>(GetParam()); // is_memory_test - double thresh = 10 * ((std::max)(k,gtint_t(1))) * testinghelpers::getEpsilon(); // Set the threshold for the errors + + // Set the threshold for the errors: + // Check gtestsuite gemm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0) + thresh = 0.0; + else if ((alpha == testinghelpers::ZERO() || k == 0) && (beta == testinghelpers::ZERO() || + beta == testinghelpers::ONE())) + thresh = 0.0; + else + thresh = (3*k+1)*testinghelpers::getEpsilon(); + //thresh = (4*k+1)*testinghelpers::getEpsilon(); test_gemmnat_ukr(storage, m, n, k, alpha, beta, thresh, kern_ptr, is_memory_test); }// end of function diff --git a/gtestsuite/testsuite/ukr/trsm/ctrsm_ukr.cpp b/gtestsuite/testsuite/ukr/trsm/ctrsm_ukr.cpp index 63f6fc2ad..2f64323ce 100644 --- a/gtestsuite/testsuite/ukr/trsm/ctrsm_ukr.cpp +++ b/gtestsuite/testsuite/ukr/trsm/ctrsm_ukr.cpp @@ -69,7 +69,17 @@ TEST_P(ctrsmUkrSmall, AccuracyCheck) gtint_t ldb = std::get<9>(GetParam()); bool is_memory_test = std::get<10>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_small_ukr( ukr_fp, side, uploa, diaga, transa, m, n, alpha, lda, ldb, thresh, is_memory_test, BLIS_SCOMPLEX); } diff --git a/gtestsuite/testsuite/ukr/trsm/dtrsm_ukr.cpp b/gtestsuite/testsuite/ukr/trsm/dtrsm_ukr.cpp index a1b28d939..210c76fd5 100644 --- a/gtestsuite/testsuite/ukr/trsm/dtrsm_ukr.cpp +++ b/gtestsuite/testsuite/ukr/trsm/dtrsm_ukr.cpp @@ -81,8 +81,17 @@ TEST_P(DTRSMUkrTest, native_kernel) gtint_t ldc = std::get<8>(GetParam()); bool is_memory_test = std::get<9>(GetParam()); - double thresh = 2 * m * testinghelpers::getEpsilon(); - test_trsm_ukr( ukr_fp, storage, uploa, diaga, m, n, k, alpha, ldc, thresh, is_memory_test); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + + test_trsm_ukr( ukr_fp, storage, uploa, diaga, m, n, k, alpha, ldc, thresh, is_memory_test ); } TEST_P(DTRSMSmallUkrTest, small_kernel) @@ -100,7 +109,16 @@ TEST_P(DTRSMSmallUkrTest, small_kernel) gtint_t ldb = std::get<9>(GetParam()); bool is_memory_test = std::get<10>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_small_ukr( ukr_fp, side, uploa, diaga, transa, m, n, alpha, lda, ldb, thresh, is_memory_test, BLIS_DOUBLE); } diff --git a/gtestsuite/testsuite/ukr/trsm/strsm_ukr.cpp b/gtestsuite/testsuite/ukr/trsm/strsm_ukr.cpp index 62658b184..cbac73826 100644 --- a/gtestsuite/testsuite/ukr/trsm/strsm_ukr.cpp +++ b/gtestsuite/testsuite/ukr/trsm/strsm_ukr.cpp @@ -81,7 +81,16 @@ TEST_P(strsmUkrNat, AccuracyCheck) gtint_t ldc = std::get<8>(GetParam()); bool is_memory_test = std::get<9>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_ukr( ukr_fp, storage, uploa, diaga, m, n, k, alpha, ldc, thresh, is_memory_test); } @@ -100,7 +109,16 @@ TEST_P(strsmUkrSmall, AccuracyCheck) gtint_t ldb = std::get<9>(GetParam()); bool is_memory_test = std::get<10>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_small_ukr( ukr_fp, side, uploa, diaga, transa, m, n, alpha, lda, ldb, thresh, is_memory_test, BLIS_FLOAT); } diff --git a/gtestsuite/testsuite/ukr/trsm/ztrsm_ukr.cpp b/gtestsuite/testsuite/ukr/trsm/ztrsm_ukr.cpp index 31f5d6500..8a4b73591 100644 --- a/gtestsuite/testsuite/ukr/trsm/ztrsm_ukr.cpp +++ b/gtestsuite/testsuite/ukr/trsm/ztrsm_ukr.cpp @@ -81,7 +81,17 @@ TEST_P(ztrsmUkrNat, AccuracyCheck) gtint_t ldc = std::get<8>(GetParam()); bool is_memory_test = std::get<9>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_ukr( ukr_fp, storage, uploa, diaga, m, n, k, alpha, ldc, thresh, is_memory_test); } @@ -100,7 +110,17 @@ TEST_P(ztrsmUkrSmall, AccuracyCheck) gtint_t ldb = std::get<9>(GetParam()); bool is_memory_test = std::get<10>(GetParam()); - double thresh = 2 * (std::max)((std::max)(m, n), gtint_t(3)) * testinghelpers::getEpsilon(); + // Set the threshold for the errors: + // Check gtestsuite trsm.h or netlib source code for reminder of the + // functionality from which we estimate operation count per element + // of output, and hence the multipler for epsilon. + // No adjustment applied yet for complex data. + double thresh; + if (m == 0 || n == 0 || alpha == testinghelpers::ZERO()) + thresh = 0.0; + else + thresh = 3*m*testinghelpers::getEpsilon(); + test_trsm_small_ukr( ukr_fp, side, uploa, diaga, transa, m, n, alpha, lda, ldb, thresh, is_memory_test, BLIS_DCOMPLEX); }