[clblas] 48/61: enables apiCallCount for zgemm within client

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Fri Jul 24 22:49:48 UTC 2015


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

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

commit bd13b7b6c8c16349049093bf357327a7f1a39c5d
Author: David Tanner <guacamoleo at gmail.com>
Date:   Thu Jun 18 08:30:17 2015 -0500

    enables apiCallCount for zgemm within client
---
 src/client/clfunc_common.hpp |  2 +-
 src/client/clfunc_xgemm.hpp  | 32 +++++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/client/clfunc_common.hpp b/src/client/clfunc_common.hpp
index 01363a9..86f93c0 100644
--- a/src/client/clfunc_common.hpp
+++ b/src/client/clfunc_common.hpp
@@ -246,7 +246,7 @@ public:
         props_[2] = 0;
         ctx_ = clCreateContext(props_, 1, &device_, NULL, NULL, &err);
         OPENCL_V_THROW(err, "creating context");
-        queue_ = clCreateCommandQueue(ctx_, device_, 0, &err);
+        queue_ = clCreateCommandQueue(ctx_, device_, CL_QUEUE_PROFILING_ENABLE, &err);
 
 
         timer_id = timer.getUniqueID( "clfunc", 0 );
diff --git a/src/client/clfunc_xgemm.hpp b/src/client/clfunc_xgemm.hpp
index 87e5a02..27fa1f2 100644
--- a/src/client/clfunc_xgemm.hpp
+++ b/src/client/clfunc_xgemm.hpp
@@ -1013,12 +1013,15 @@ void
 xGemm<cl_double>::
 xGemm_Function(bool flush, cl_uint apiCallCount )
 {
-	clblasDgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
+  for (int i = 0; i < apiCallCount; i++)
+	{
+	  clblasDgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
                      buffer_.m_, buffer_.n_, buffer_.k_, buffer_.alpha_,
                      buffer_.buf_a_, buffer_.offA_, buffer_.lda_,
                      buffer_.buf_b_, buffer_.offB_, buffer_.ldb_,
                      buffer_.beta_, buffer_.buf_c_, buffer_.offC_,
                      buffer_.ldc_, 1, &queue_, 0, NULL, &event_);
+  }
 	//flush==true if only the kernel time (library call) is timed
 	//flush==false if memory time is also timed
 	if (flush==true)
@@ -1032,12 +1035,15 @@ void
 xGemm<cl_float2>::
 xGemm_Function(bool flush, cl_uint apiCallCount )
 {
-	clblasCgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
+  for (int i = 0; i < apiCallCount; i++)
+	{
+	  clblasCgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
                      buffer_.m_, buffer_.n_, buffer_.k_, buffer_.alpha_,
                      buffer_.buf_a_, buffer_.offA_, buffer_.lda_,
                      buffer_.buf_b_, buffer_.offB_, buffer_.ldb_,
                      buffer_.beta_, buffer_.buf_c_, buffer_.offC_,
                      buffer_.ldc_, 1, &queue_, 0, NULL, &event_);
+  }
 	//flush==true if only the kernel time (library call) is timed
 	//flush==false if memory time is also timed
 	if (flush==true)
@@ -1051,12 +1057,28 @@ void
 xGemm<cl_double2>::
 xGemm_Function(bool flush, cl_uint apiCallCount )
 {
-	clblasZgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
+  for (int i = 0; i < apiCallCount; i++)
+	{
+	  clblasZgemm(order_, buffer_.trans_a_, buffer_.trans_b_,
                      buffer_.m_, buffer_.n_, buffer_.k_, buffer_.alpha_,
                      buffer_.buf_a_, buffer_.offA_, buffer_.lda_,
                      buffer_.buf_b_, buffer_.offB_, buffer_.ldb_,
                      buffer_.beta_, buffer_.buf_c_, buffer_.offC_,
                      buffer_.ldc_, 1, &queue_, 0, NULL, &event_);
+#if 0
+    // print kernel time
+    clFinish(queue_);
+    cl_ulong start, stop;
+    double time;
+    cl_int err;
+    err = clGetEventProfilingInfo( event_, CL_PROFILING_COMMAND_START, sizeof(start), &start, NULL );
+    if (err) printf("err = %i\n", err);
+    err = clGetEventProfilingInfo( event_, CL_PROFILING_COMMAND_END,   sizeof(stop),  &stop,  NULL );
+    if (err) printf("err = %i\n", err);
+    time = (stop - start) / 1000000.0; // milliseconds
+    printf("kernel %lu -> %lu = %.f ms\n", start, stop, time );
+#endif
+  }
 	//flush==true if only the kernel time (library call) is timed
 	//flush==false if memory time is also timed
 	if (flush==true)
@@ -1070,7 +1092,7 @@ double
 xGemm<cl_float2>::
 gflops()
 {
-    return (8.0*buffer_.m_*buffer_.n_*buffer_.k_)/time_in_ns();
+    return (8.0*buffer_.m_*buffer_.n_*buffer_.k_)/(time_in_ns() / buffer_.apiCallCount);
 }
 
 template<>
@@ -1078,7 +1100,7 @@ double
 xGemm<cl_double2>::
 gflops()
 {
-    return (8.0*buffer_.m_*buffer_.n_*buffer_.k_)/time_in_ns();
+    return (8.0*buffer_.m_*buffer_.n_*buffer_.k_)/(time_in_ns() / buffer_.apiCallCount);
 }
 
 template<>

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



More information about the debian-science-commits mailing list