Re: [Mesa-dev] [PATCH] gallivm: print out time for jitting functions with GALLIVM_DEBUG=perf

2016-10-14 Thread Roland Scheidegger
Am 14.10.2016 um 18:05 schrieb Jose Fonseca:
> On 14/10/16 15:36, Brian Paul wrote:
>> On 10/13/2016 09:38 PM, srol...@vmware.com wrote:
>>> From: Roland Scheidegger 
>>>
>>> Compilation to actual machine code can easily take as much time as the
>>> optimization passes on the IR if not more, so print this out too.
>>> ---
>>>   src/gallium/auxiliary/gallivm/lp_bld_init.c | 11 +++
>>>   1 file changed, 11 insertions(+)
>>>
>>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c
>>> b/src/gallium/auxiliary/gallivm/lp_bld_init.c
>>> index 7114cde..d1b2369 100644
>>> --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
>>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
>>> @@ -659,13 +659,24 @@ gallivm_jit_function(struct gallivm_state
>>> *gallivm,
>>>   {
>>>  void *code;
>>>  func_pointer jit_func;
>>> +   int64_t time_begin = 0;
>>
>> I think we might want to put MAYBE_UNUSED on that decl so there's not an
>> unused var warning in a non-debug build.
> 
> I think it might be OK because Roland's using `if` isntead of `#if`.
> That said, some compilers are too smart for their own good.
I think it would be really surprising if compilers would warn about that
indeed. That it can be optimized out might be obvious here, nevertheless
the variable is used as far as the c code is concerned (you also get
compile errors if the syntax is wrong somewhere in a "if (0)" clause).
At least I've never seen a warning, though I'm usually not using
bleeding edge compilers... (the code here is a near exact copy of the
one in gallivm_compile_module() in any case).

Roland

> 
>>
>>>
>>>  assert(gallivm->compiled);
>>>  assert(gallivm->engine);
>>>
>>> +   if (gallivm_debug & GALLIVM_DEBUG_PERF)
>>> +  time_begin = os_time_get();
>>> +
>>>  code = LLVMGetPointerToGlobal(gallivm->engine, func);
>>>  assert(code);
>>>  jit_func = pointer_to_func(code);
>>>
>>> +   if (gallivm_debug & GALLIVM_DEBUG_PERF) {
>>> +  int64_t time_end = os_time_get();
>>> +  int time_msec = (int)(time_end - time_begin) / 1000;
>>> +  debug_printf("   jitting func %s took %d msec\n",
>>> +   LLVMGetValueName(func), time_msec);
>>> +   }
>>> +
>>>  return jit_func;
>>>   }
>>>
>>
>> Looks OK otherwise.
>>
>> Reviewed-by: Brian Paul 
> 
> Reviewed-by: Jose Fonseca 
> 
> Jose
> 

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


Re: [Mesa-dev] [PATCH] gallivm: print out time for jitting functions with GALLIVM_DEBUG=perf

2016-10-14 Thread Jose Fonseca

On 14/10/16 15:36, Brian Paul wrote:

On 10/13/2016 09:38 PM, srol...@vmware.com wrote:

From: Roland Scheidegger 

Compilation to actual machine code can easily take as much time as the
optimization passes on the IR if not more, so print this out too.
---
  src/gallium/auxiliary/gallivm/lp_bld_init.c | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 7114cde..d1b2369 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -659,13 +659,24 @@ gallivm_jit_function(struct gallivm_state *gallivm,
  {
 void *code;
 func_pointer jit_func;
+   int64_t time_begin = 0;


I think we might want to put MAYBE_UNUSED on that decl so there's not an
unused var warning in a non-debug build.


I think it might be OK because Roland's using `if` isntead of `#if`. 
That said, some compilers are too smart for their own good.






 assert(gallivm->compiled);
 assert(gallivm->engine);

+   if (gallivm_debug & GALLIVM_DEBUG_PERF)
+  time_begin = os_time_get();
+
 code = LLVMGetPointerToGlobal(gallivm->engine, func);
 assert(code);
 jit_func = pointer_to_func(code);

+   if (gallivm_debug & GALLIVM_DEBUG_PERF) {
+  int64_t time_end = os_time_get();
+  int time_msec = (int)(time_end - time_begin) / 1000;
+  debug_printf("   jitting func %s took %d msec\n",
+   LLVMGetValueName(func), time_msec);
+   }
+
 return jit_func;
  }



Looks OK otherwise.

Reviewed-by: Brian Paul 


Reviewed-by: Jose Fonseca 

Jose

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


Re: [Mesa-dev] [PATCH] gallivm: print out time for jitting functions with GALLIVM_DEBUG=perf

2016-10-14 Thread Brian Paul

On 10/13/2016 09:38 PM, srol...@vmware.com wrote:

From: Roland Scheidegger 

Compilation to actual machine code can easily take as much time as the
optimization passes on the IR if not more, so print this out too.
---
  src/gallium/auxiliary/gallivm/lp_bld_init.c | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c 
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 7114cde..d1b2369 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -659,13 +659,24 @@ gallivm_jit_function(struct gallivm_state *gallivm,
  {
 void *code;
 func_pointer jit_func;
+   int64_t time_begin = 0;


I think we might want to put MAYBE_UNUSED on that decl so there's not an 
unused var warning in a non-debug build.





 assert(gallivm->compiled);
 assert(gallivm->engine);

+   if (gallivm_debug & GALLIVM_DEBUG_PERF)
+  time_begin = os_time_get();
+
 code = LLVMGetPointerToGlobal(gallivm->engine, func);
 assert(code);
 jit_func = pointer_to_func(code);

+   if (gallivm_debug & GALLIVM_DEBUG_PERF) {
+  int64_t time_end = os_time_get();
+  int time_msec = (int)(time_end - time_begin) / 1000;
+  debug_printf("   jitting func %s took %d msec\n",
+   LLVMGetValueName(func), time_msec);
+   }
+
 return jit_func;
  }



Looks OK otherwise.

Reviewed-by: Brian Paul 

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


[Mesa-dev] [PATCH] gallivm: print out time for jitting functions with GALLIVM_DEBUG=perf

2016-10-13 Thread sroland
From: Roland Scheidegger 

Compilation to actual machine code can easily take as much time as the
optimization passes on the IR if not more, so print this out too.
---
 src/gallium/auxiliary/gallivm/lp_bld_init.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c 
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 7114cde..d1b2369 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -659,13 +659,24 @@ gallivm_jit_function(struct gallivm_state *gallivm,
 {
void *code;
func_pointer jit_func;
+   int64_t time_begin = 0;
 
assert(gallivm->compiled);
assert(gallivm->engine);
 
+   if (gallivm_debug & GALLIVM_DEBUG_PERF)
+  time_begin = os_time_get();
+
code = LLVMGetPointerToGlobal(gallivm->engine, func);
assert(code);
jit_func = pointer_to_func(code);
 
+   if (gallivm_debug & GALLIVM_DEBUG_PERF) {
+  int64_t time_end = os_time_get();
+  int time_msec = (int)(time_end - time_begin) / 1000;
+  debug_printf("   jitting func %s took %d msec\n",
+   LLVMGetValueName(func), time_msec);
+   }
+
return jit_func;
 }
-- 
2.7.4

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