[Beignet] [PATCH] Refine the output and add dynamic statistics.

Song, Ruiling ruiling.song at intel.com
Tue Mar 25 20:09:15 PDT 2014


I think you can print case name before case running, after case finished, print success or fail.
How about this?

-----Original Message-----
From: Song, Ruiling 
Sent: Tuesday, March 25, 2014 10:20 AM
To: Sun, Yi; beignet at lists.freedesktop.org
Cc: Sun, Yi; Shui, YangweiX
Subject: RE: [Beignet] [PATCH] Refine the output and add dynamic statistics.

Although dynamic statistics looks good to me.
Still one minor comment, if a case hang, it is not easy to find which case hang through the log.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Yi Sun
Sent: Tuesday, March 18, 2014 9:15 AM
To: beignet at lists.freedesktop.org
Cc: Sun, Yi; Shui, YangweiX
Subject: [Beignet] [PATCH] Refine the output and add dynamic statistics.

From: Yangwei Shui <yangweix.shui at intel.com>

1. Add two parameter(passCount and failCount) in Class UTest, to count passed case number and failed case  number

2. Print dynamic statistics about case running in stdout, the style looks like follows:

  ......
  compiler_bool_cross_basic_block()    [SUCCESS]
  compiler_private_data_overflow()    [SUCCESS]
  compiler_getelementptr_bitcast()    [SUCCESS]
  test_load_program_from_bin()    [SUCCESS]
  enqueue_copy_buf()    [SUCCESS]
run/total: 655/655; pass: 628; fail: 25; pass rate: 0.961832

3. If ./utest_run &> log, the log will be a little messy, tring the following command to analyse the log:

  sed 's/\r/\n/g' log | egrep "\w*\(\)" | sed -e 's/\s//g'

  After analysed:
  -----------------
......
builtin_minmag_float2()[SUCCESS]
builtin_minmag_float4()[SUCCESS]
builtin_minmag_float8()[SUCCESS]
builtin_minmag_float16()[SUCCESS]
builtin_nextafter_float()[FAILED]
builtin_nextafter_float2()[FAILED]
builtin_nextafter_float4()[FAILED]
......

Signed-off-by: Yi Sun <yi.sun at intel.com>
Signed-off-by: Yangwei Shui <yangweix.shui at intel.com>

diff --git a/utests/compiler_basic_arithmetic.cpp b/utests/compiler_basic_arithmetic.cpp
index 0e5ec41..ba05de0 100644
--- a/utests/compiler_basic_arithmetic.cpp
+++ b/utests/compiler_basic_arithmetic.cpp
@@ -15,7 +15,6 @@ static void test_exec(const char* kernel_name)
 
   // Setup kernel and buffers
   OCL_CREATE_KERNEL_FROM_FILE("compiler_basic_arithmetic", kernel_name); -std::cout <<"kernel name: " << kernel_name << std::endl;
   buf_data[0] = (T*) malloc(sizeof(T) * n);
   buf_data[1] = (T*) malloc(sizeof(T) * n);
   for (uint32_t i = 0; i < n; ++i) ((T*)buf_data[0])[i] = (T) rand(); diff --git a/utests/utest.cpp b/utests/utest.cpp index 718916f..ef0c5cf 100644
--- a/utests/utest.cpp
+++ b/utests/utest.cpp
@@ -28,8 +28,17 @@
 #include <iostream>
 #include <cstring>
 
+#define OUTPUT_LINE_LEN 70
+
 using namespace std;
 vector<UTest> *UTest::utestList = NULL;
+/* Initialisation
+   Passed case number: passCount
+   Failed case number: failCount
+*/
+int UTest::passCount = 0;
+int UTest::failCount = 0;
+
 void releaseUTestList(void) { delete UTest::utestList; }
 
 UTest::UTest(Function fn, const char *name, bool haveIssue, bool needDestroyProgram) @@ -76,13 +85,23 @@ void UTest::runAll(void) {  }
 
 void UTest::runAllNoIssue(void) {
+  char spaceList[OUTPUT_LINE_LEN] = {};
   if (utestList == NULL) return;
   for (size_t i = 0; i < utestList->size(); ++i) {
     const UTest &utest = (*utestList)[i];
     if (utest.fn == NULL || utest.haveIssue) continue;
-    std::cout << utest.name << ":" << std::endl;
+
+    //A string contain OUTPUT_LINE_LEN spaces, to hide the statistic line in stdout
+    for (size_t j = 0; j < OUTPUT_LINE_LEN; j++) spaceList[j] = ' ';
+    printf("\r%s\r",spaceList);
+
     (utest.fn)();
-    std::cout << std::endl;
+
+    //Dynamic statistics of running cases
+    printf("\nrun/total: %zu/%zu; pass: %d; fail: %d; pass rate: %f",
+      i+1, utestList->size(), passCount, failCount, 1-(float)failCount/(float)utestList->size());
+    fflush(stdout);
+
     cl_kernel_destroy(utest.needDestroyProgram);
     cl_buffer_destroy();
   }
diff --git a/utests/utest.hpp b/utests/utest.hpp index 01d4a8c..7b5bd42 100644
--- a/utests/utest.hpp
+++ b/utests/utest.hpp
@@ -58,6 +58,10 @@ struct UTest
   static void runAll(void);
   /*! List all test cases */
   static void listAllCases(void);
+  /*! Count passed case number */
+  static int passCount;
+  /*! Count failed case number */
+  static int failCount;
 };
 
 /*! Register a new unit test */
@@ -84,11 +88,13 @@ struct UTest
  do { \
     try { \
       EXPR; \
-      std::cout << "  " << #EXPR << "    [SUCCESS]" << std::endl; \
+      std::cout << "  " << #EXPR << "    [SUCCESS]"; \
+      UTest::passCount += 1; \
     } \
     catch (Exception e) { \
-      std::cout << "  " << #EXPR << "    [FAILED]" << std::endl; \
-      std::cout << "    " << e.what() << std::endl; \
+      std::cout << "  " << #EXPR << "    [FAILED]"; \
+      std::cout << "\n   " << e.what(); \
+      UTest::failCount += 1; \
     } \
   } while (0)
 
@@ -96,10 +102,12 @@ struct UTest
  do { \
     try { \
       EXPR; \
-      std::cout << "  " << #EXPR << "    [FAILED]" <<  std::endl; \
+      std::cout << "  " << #EXPR << "    [FAILED]"; \
+      UTest::failCount += 1; \
     } \
     catch (gbe::Exception e) { \
-      std::cout << "  " << #EXPR << "    [SUCCESS]" << std::endl; \
+      std::cout << "  " << #EXPR << "    [SUCCESS]"; \
+      UTest::passCount += 1; \
     } \
   } while (0)
 
--
1.8.5.3

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list