[Libreoffice-commits] core.git: 2 commits - sc/source

Tor Lillqvist tml at collabora.com
Wed Nov 20 11:00:29 PST 2013


 sc/source/core/opencl/opencl_device.cxx |   35 +++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 12 deletions(-)

New commits:
commit bd390560539cec344323e1bc68b7e19a0aa4fbb3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Nov 20 20:59:20 2013 +0200

    Rename timerStop() to timerCurrent() as it doesn't "stop" anything
    
    Change-Id: I99dbee00422ac9a066479231b32112551a317e75

diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx
index cc9be18..963e10a 100644
--- a/sc/source/core/opencl/opencl_device.cxx
+++ b/sc/source/core/opencl/opencl_device.cxx
@@ -144,8 +144,8 @@ void timerStart(timer* mytimer)
 #endif
 }
 
-/* Timer functions - stop timer and return difference */
-double timerStop(timer* mytimer)
+/* Timer functions - get current value */
+double timerCurrent(timer* mytimer)
 {
 #ifdef _WIN32
     LARGE_INTEGER stop, frequency;
@@ -342,7 +342,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
                 clReleaseKernel(clKernel);
 
                 device->score = (void*)new LibreOfficeDeviceScore;
-                ((LibreOfficeDeviceScore*)device->score)->fTime = timerStop(&kernelTime);
+                ((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
                 ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
             }
 
@@ -375,7 +375,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
         }
 
         device->score = (void*)new LibreOfficeDeviceScore;
-        ((LibreOfficeDeviceScore*)device->score)->fTime = timerStop(&kernelTime);
+        ((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
         ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
     }
     return DS_SUCCESS;
commit 43da86747ada05c7a019ef0e5a54dc1e6a3e32b3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Nov 20 20:45:05 2013 +0200

    Simplify "timer" code and add OS X implementation
    
    Change-Id: Id728dc3b422c76fcb6c0a1185caae6f05b9ca245

diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx
index ed0d2cc..cc9be18 100644
--- a/sc/source/core/opencl/opencl_device.cxx
+++ b/sc/source/core/opencl/opencl_device.cxx
@@ -9,6 +9,8 @@
 
 #ifdef _WIN32
 #include <windows.h>
+#elif defined __MACH__
+#include <mach/mach_time.h>
 #else
 #include <sys/time.h>
 #endif
@@ -62,9 +64,9 @@ struct LibreOfficeDeviceEvaluationIO
 struct timer
 {
 #ifdef _WIN32
-    LARGE_INTEGER start, stop, frequency;
+    LARGE_INTEGER start;
 #else
-    long long start, stop, frequency;
+    long long start;
 #endif
 };
 
@@ -133,6 +135,8 @@ void timerStart(timer* mytimer)
 {
 #ifdef _WIN32
     QueryPerformanceCounter(&mytimer->start);
+#elif defined __MACH__
+    mytimer->start = mach_absolute_time();
 #else
     struct timespec s;
     clock_gettime(CLOCK_MONOTONIC, &s);
@@ -144,15 +148,22 @@ void timerStart(timer* mytimer)
 double timerStop(timer* mytimer)
 {
 #ifdef _WIN32
-    QueryPerformanceCounter(&mytimer->stop);
-    QueryPerformanceFrequency(&mytimer->frequency);
-    double time = ((double)(mytimer->stop.QuadPart - mytimer->start.QuadPart) / mytimer->frequency.QuadPart);
+    LARGE_INTEGER stop, frequency;
+    QueryPerformanceCounter(&stop);
+    QueryPerformanceFrequency(&frequency);
+    double time = ((double)(stop.QuadPart - mytimer->start.QuadPart) / frequency.QuadPart);
+#elif defined __MACH__
+    static mach_timebase_info_data_t info = { 0, 0 };
+    if (info.numer == 0)
+        mach_timebase_info(&info);
+    long long stop = mach_absolute_time();
+    double time = ((stop - mytimer->start) * (double) info.numer / info.denom) / 1000.0;
 #else
     struct timespec s;
+    long long stop;
     clock_gettime(CLOCK_MONOTONIC, &s);
-    mytimer->stop = (long long)s.tv_sec * (long long)1.0E6 + (long long)s.tv_nsec / (long long)1.0E3;
-    mytimer->frequency = (long long)1.0E6;
-    double time = ((double)(mytimer->stop - mytimer->start) / mytimer->frequency);
+    stop = (long long)s.tv_sec * (long long)1.0E6 + (long long)s.tv_nsec / (long long)1.0E3;
+    double time = ((double)(stop - mytimer->start) / 1.0E6);
 #endif
     return time;
 }


More information about the Libreoffice-commits mailing list