[Openmp-commits] [PATCH] D119988: [OpenMP][Offloading] Fix test case issues in bug49334.cpp

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 17 07:22:54 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG092a5bb72ba8: [OpenMP][Offloading] Fix test case issues in bug49334.cpp (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119988/new/

https://reviews.llvm.org/D119988

Files:
  openmp/libomptarget/test/offloading/bug49334.cpp


Index: openmp/libomptarget/test/offloading/bug49334.cpp
===================================================================
--- openmp/libomptarget/test/offloading/bug49334.cpp
+++ openmp/libomptarget/test/offloading/bug49334.cpp
@@ -50,8 +50,7 @@
       }
   }
 
-  long Compare(const std::vector<float> &matrix) const {
-    long fail = 0;
+  void Compare(const std::vector<float> &matrix) const {
     for (int i = 0; i < nBlocksPerCol; i++)
       for (int j = 0; j < nBlocksPerRow; j++) {
         float *CurrBlock = GetBlock(i, j);
@@ -61,13 +60,10 @@
             int currj = j * rowsPerBlock + jj;
             float m_value = matrix[curri + currj * nCols];
             float bm_value = CurrBlock[ii + jj * colsPerBlock];
-            if (std::fabs(bm_value - m_value) >
-                std::numeric_limits<float>::epsilon()) {
-              fail++;
-            }
+            assert(std::fabs(bm_value - m_value) <
+                   std::numeric_limits<float>::epsilon());
           }
       }
-    return fail;
   }
 
   float *GetBlock(int i, int j) const {
@@ -77,7 +73,7 @@
 };
 
 constexpr const int BS = 16;
-constexpr const int N = 256;
+constexpr const int N = 16;
 
 int BlockMatMul_TargetNowait(BlockMatrix &A, BlockMatrix &B, BlockMatrix &C) {
 #pragma omp parallel
@@ -130,20 +126,19 @@
   }
 
   auto BlockedA = BlockMatrix(BS, BS, N, N);
-  BlockedA.Initialize(a);
-  BlockedA.Compare(a);
   auto BlockedB = BlockMatrix(BS, BS, N, N);
+  auto BlockedC = BlockMatrix(BS, BS, N, N);
+  BlockedA.Initialize(a);
   BlockedB.Initialize(b);
+  BlockedC.Initialize(c);
+  BlockedA.Compare(a);
   BlockedB.Compare(b);
+  BlockedC.Compare(c);
 
   Matmul(a, b, c);
-
-  auto BlockedC = BlockMatrix(BS, BS, N, N);
   BlockMatMul_TargetNowait(BlockedA, BlockedB, BlockedC);
 
-  if (BlockedC.Compare(c) > 0) {
-    return 1;
-  }
+  BlockedC.Compare(c);
 
   std::cout << "PASS\n";
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119988.409648.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220217/a95e5cbd/attachment-0001.bin>


More information about the Openmp-commits mailing list