Re: [Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

2017-08-18 Thread Jose Fonseca

On 18/08/17 08:23, Frank Richter wrote:

Hi,
On 17.08.2017 02:34, Brian Paul wrote:

BTW, I wonder if we would win by using lldiv().  Because this is often
use for performance measurements, so these extra division might add some
impact.


Frank, do you want to look into that?  In the mean time, I'll push the 
patches as-is.


AFAICS, the lldiv implementation in the MSVC runtime (also used by 
MinGW) simply does “a = num / denom; b = num % denom;” as well, so it 
seems unlikely that lldiv() would give a benefit here.


I see.  I thought they would try do something smarter to leverage the 
ISA ability to compute both at the same time, but I suppose that's left 
to the compiler to figure out.  Thanks for checking.


Jose
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

2017-08-18 Thread Frank Richter

Hi,
On 17.08.2017 02:34, Brian Paul wrote:

BTW, I wonder if we would win by using lldiv().  Because this is often
use for performance measurements, so these extra division might add some
impact.


Frank, do you want to look into that?  In the mean time, I'll push the 
patches as-is.


AFAICS, the lldiv implementation in the MSVC runtime (also used by 
MinGW) simply does “a = num / denom; b = num % denom;” as well, so it 
seems unlikely that lldiv() would give a benefit here.


-f.r.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

2017-08-16 Thread Brian Paul

On 08/16/2017 04:42 PM, Jose Fonseca wrote:

On 16/08/17 23:37, Jose Fonseca wrote:

On 16/08/17 14:22, Brian Paul wrote:

From: Frank Richter 

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Brian Paul 
---
  src/gallium/auxiliary/os/os_time.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/os/os_time.c
b/src/gallium/auxiliary/os/os_time.c
index e169139..e4a1cae 100644
--- a/src/gallium/auxiliary/os/os_time.c
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -69,10 +69,17 @@ os_time_get_nano(void)
 static LARGE_INTEGER frequency;
 LARGE_INTEGER counter;
+   int64_t secs, nanosecs;
 if(!frequency.QuadPart)
QueryPerformanceFrequency();
 QueryPerformanceCounter();
-   return counter.QuadPart*INT64_C(10)/frequency.QuadPart;
+   /* Compute seconds and nanoseconds parts separately to
+* reduce severity of precision loss.
+*/
+   secs = counter.QuadPart / frequency.QuadPart;
+   nanosecs = (counter.QuadPart % frequency.QuadPart) *
INT64_C(10)
+  / frequency.QuadPart;
+   return secs*INT64_C(10) + nanosecs;
  #else



Series looks great.

Thanks!

Reviewed-by: Jose Fonseca 


BTW, I wonder if we would win by using lldiv().  Because this is often
use for performance measurements, so these extra division might add some
impact.


Frank, do you want to look into that?  In the mean time, I'll push the 
patches as-is.


-Brian


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

2017-08-16 Thread Jose Fonseca

On 16/08/17 14:22, Brian Paul wrote:

From: Frank Richter 

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Brian Paul 
---
  src/gallium/auxiliary/os/os_time.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/os/os_time.c 
b/src/gallium/auxiliary/os/os_time.c
index e169139..e4a1cae 100644
--- a/src/gallium/auxiliary/os/os_time.c
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -69,10 +69,17 @@ os_time_get_nano(void)
  
 static LARGE_INTEGER frequency;

 LARGE_INTEGER counter;
+   int64_t secs, nanosecs;
 if(!frequency.QuadPart)
QueryPerformanceFrequency();
 QueryPerformanceCounter();
-   return counter.QuadPart*INT64_C(10)/frequency.QuadPart;
+   /* Compute seconds and nanoseconds parts separately to
+* reduce severity of precision loss.
+*/
+   secs = counter.QuadPart / frequency.QuadPart;
+   nanosecs = (counter.QuadPart % frequency.QuadPart) * INT64_C(10)
+  / frequency.QuadPart;
+   return secs*INT64_C(10) + nanosecs;
  
  #else
  



Series looks great.

Thanks!

Reviewed-by: Jose Fonseca 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium/os: fix os_time_get_nano() to roll over less

2017-08-16 Thread Jose Fonseca

On 16/08/17 23:37, Jose Fonseca wrote:

On 16/08/17 14:22, Brian Paul wrote:

From: Frank Richter 

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Brian Paul 
---
  src/gallium/auxiliary/os/os_time.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/os/os_time.c 
b/src/gallium/auxiliary/os/os_time.c

index e169139..e4a1cae 100644
--- a/src/gallium/auxiliary/os/os_time.c
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -69,10 +69,17 @@ os_time_get_nano(void)
 static LARGE_INTEGER frequency;
 LARGE_INTEGER counter;
+   int64_t secs, nanosecs;
 if(!frequency.QuadPart)
QueryPerformanceFrequency();
 QueryPerformanceCounter();
-   return counter.QuadPart*INT64_C(10)/frequency.QuadPart;
+   /* Compute seconds and nanoseconds parts separately to
+* reduce severity of precision loss.
+*/
+   secs = counter.QuadPart / frequency.QuadPart;
+   nanosecs = (counter.QuadPart % frequency.QuadPart) * 
INT64_C(10)

+  / frequency.QuadPart;
+   return secs*INT64_C(10) + nanosecs;
  #else



Series looks great.

Thanks!

Reviewed-by: Jose Fonseca 


BTW, I wonder if we would win by using lldiv().  Because this is often 
use for performance measurements, so these extra division might add some 
impact.


Jose
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev