Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Tom Stellard
On Tue, Jun 21, 2016 at 10:42:45PM +0200, Marek Olšák wrote:
> On Tue, Jun 21, 2016 at 9:27 PM, Tom Stellard  wrote:
> > On Tue, Jun 21, 2016 at 08:17:15PM +0200, Marek Olšák wrote:
> >> On Tue, Jun 21, 2016 at 7:21 PM, Tom Stellard  wrote:
> >> > On Mon, Jun 13, 2016 at 06:27:02PM +0200, Marek Olšák wrote:
> >> >> From: Marek Olšák 
> >> >>
> >> >> ---
> >> >>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
> >> >>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
> >> >>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
> >> >>  3 files changed, 18 insertions(+)
> >> >>
> >> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
> >> >> b/src/gallium/drivers/radeon/r600_pipe_common.c
> >> >> index fa9f70d..5d4a679 100644
> >> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
> >> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
> >> >> @@ -482,6 +482,7 @@ static const struct debug_named_value 
> >> >> common_debug_options[] = {
> >> >>   { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
> >> >> Scheduler." },
> >> >>   { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic 
> >> >> shaders compiled on demand" },
> >> >>   { "noce", DBG_NO_CE, "Disable the constant engine"},
> >> >> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> >> >> optimizations" },
> >> >>
> >> >>   DEBUG_NAMED_VALUE_END /* must be last */
> >> >>  };
> >> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
> >> >> b/src/gallium/drivers/radeon/r600_pipe_common.h
> >> >> index 77dfc4f..263ef5e 100644
> >> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> >> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> >> >> @@ -99,6 +99,7 @@
> >> >>  #define DBG_SI_SCHED (1llu << 46)
> >> >>  #define DBG_MONOLITHIC_SHADERS   (1llu << 47)
> >> >>  #define DBG_NO_CE(1llu << 48)
> >> >> +#define DBG_UNSAFE_MATH  (1llu << 49)
> >> >>
> >> >>  #define R600_MAP_BUFFER_ALIGNMENT 64
> >> >>  #define R600_MAX_VIEWPORTS16
> >> >> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> >> >> b/src/gallium/drivers/radeonsi/si_shader.c
> >> >> index 6dc4985..bba6a55 100644
> >> >> --- a/src/gallium/drivers/radeonsi/si_shader.c
> >> >> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> >> >> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
> >> >> si_shader_context *ctx,
> >> >>   else
> >> >>   LLVMAddAttribute(P, LLVMInRegAttribute);
> >> >>   }
> >> >> +
> >> >> + if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
> >> >> + /* These were copied from some LLVM test. */
> >> >> + 
> >> >> LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> >> +"less-precise-fpmad",
> >> >> +"true");
> >> >> + 
> >> >> LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> >> +"no-infs-fp-math",
> >> >> +"true");
> >> >> + 
> >> >> LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> >> +"no-nans-fp-math",
> >> >> +"true");
> >> >> + 
> >> >> LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> >> +"unsafe-fp-math",
> >> >> +"true");
> >> >> + }
> >> >
> >> > You may get better results by also adding the fast-math flags to the
> >> > individual floating-point instructions, but this would be a more
> >> > invasive change.
> >>
> >> Is there sample code showing how to do that?
> >>
> >
> > Something like this
> > https://cgit.freedesktop.org/~tstellar/mesa/commit/?h=fast-math=4fa18fdde3a2b51b2371064bc27729fd1038c219
> >
> > There are more flags than just the UnsafeAlgebra that is used in the
> > patch.
> 
> setUnsafeAlgebra enables all flags, not just UnsafeAlgebra.
> 
> Do the flags apply to whole expression trees or just one instruction?
> 

Just one instruction, but they should apply to expression trees if all
instructions in the tree have the same flags.

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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Marek Olšák
On Tue, Jun 21, 2016 at 9:27 PM, Tom Stellard  wrote:
> On Tue, Jun 21, 2016 at 08:17:15PM +0200, Marek Olšák wrote:
>> On Tue, Jun 21, 2016 at 7:21 PM, Tom Stellard  wrote:
>> > On Mon, Jun 13, 2016 at 06:27:02PM +0200, Marek Olšák wrote:
>> >> From: Marek Olšák 
>> >>
>> >> ---
>> >>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
>> >>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
>> >>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
>> >>  3 files changed, 18 insertions(+)
>> >>
>> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
>> >> b/src/gallium/drivers/radeon/r600_pipe_common.c
>> >> index fa9f70d..5d4a679 100644
>> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
>> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
>> >> @@ -482,6 +482,7 @@ static const struct debug_named_value 
>> >> common_debug_options[] = {
>> >>   { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
>> >> Scheduler." },
>> >>   { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
>> >> compiled on demand" },
>> >>   { "noce", DBG_NO_CE, "Disable the constant engine"},
>> >> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
>> >> optimizations" },
>> >>
>> >>   DEBUG_NAMED_VALUE_END /* must be last */
>> >>  };
>> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
>> >> b/src/gallium/drivers/radeon/r600_pipe_common.h
>> >> index 77dfc4f..263ef5e 100644
>> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
>> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
>> >> @@ -99,6 +99,7 @@
>> >>  #define DBG_SI_SCHED (1llu << 46)
>> >>  #define DBG_MONOLITHIC_SHADERS   (1llu << 47)
>> >>  #define DBG_NO_CE(1llu << 48)
>> >> +#define DBG_UNSAFE_MATH  (1llu << 49)
>> >>
>> >>  #define R600_MAP_BUFFER_ALIGNMENT 64
>> >>  #define R600_MAX_VIEWPORTS16
>> >> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
>> >> b/src/gallium/drivers/radeonsi/si_shader.c
>> >> index 6dc4985..bba6a55 100644
>> >> --- a/src/gallium/drivers/radeonsi/si_shader.c
>> >> +++ b/src/gallium/drivers/radeonsi/si_shader.c
>> >> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
>> >> si_shader_context *ctx,
>> >>   else
>> >>   LLVMAddAttribute(P, LLVMInRegAttribute);
>> >>   }
>> >> +
>> >> + if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
>> >> + /* These were copied from some LLVM test. */
>> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> >> +"less-precise-fpmad",
>> >> +"true");
>> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> >> +"no-infs-fp-math",
>> >> +"true");
>> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> >> +"no-nans-fp-math",
>> >> +"true");
>> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> >> +"unsafe-fp-math",
>> >> +"true");
>> >> + }
>> >
>> > You may get better results by also adding the fast-math flags to the
>> > individual floating-point instructions, but this would be a more
>> > invasive change.
>>
>> Is there sample code showing how to do that?
>>
>
> Something like this
> https://cgit.freedesktop.org/~tstellar/mesa/commit/?h=fast-math=4fa18fdde3a2b51b2371064bc27729fd1038c219
>
> There are more flags than just the UnsafeAlgebra that is used in the
> patch.

setUnsafeAlgebra enables all flags, not just UnsafeAlgebra.

Do the flags apply to whole expression trees or just one instruction?

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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Tom Stellard
On Tue, Jun 21, 2016 at 08:17:15PM +0200, Marek Olšák wrote:
> On Tue, Jun 21, 2016 at 7:21 PM, Tom Stellard  wrote:
> > On Mon, Jun 13, 2016 at 06:27:02PM +0200, Marek Olšák wrote:
> >> From: Marek Olšák 
> >>
> >> ---
> >>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
> >>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
> >>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
> >>  3 files changed, 18 insertions(+)
> >>
> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
> >> b/src/gallium/drivers/radeon/r600_pipe_common.c
> >> index fa9f70d..5d4a679 100644
> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
> >> @@ -482,6 +482,7 @@ static const struct debug_named_value 
> >> common_debug_options[] = {
> >>   { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
> >> Scheduler." },
> >>   { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
> >> compiled on demand" },
> >>   { "noce", DBG_NO_CE, "Disable the constant engine"},
> >> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> >> optimizations" },
> >>
> >>   DEBUG_NAMED_VALUE_END /* must be last */
> >>  };
> >> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
> >> b/src/gallium/drivers/radeon/r600_pipe_common.h
> >> index 77dfc4f..263ef5e 100644
> >> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> >> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> >> @@ -99,6 +99,7 @@
> >>  #define DBG_SI_SCHED (1llu << 46)
> >>  #define DBG_MONOLITHIC_SHADERS   (1llu << 47)
> >>  #define DBG_NO_CE(1llu << 48)
> >> +#define DBG_UNSAFE_MATH  (1llu << 49)
> >>
> >>  #define R600_MAP_BUFFER_ALIGNMENT 64
> >>  #define R600_MAX_VIEWPORTS16
> >> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> >> b/src/gallium/drivers/radeonsi/si_shader.c
> >> index 6dc4985..bba6a55 100644
> >> --- a/src/gallium/drivers/radeonsi/si_shader.c
> >> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> >> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
> >> si_shader_context *ctx,
> >>   else
> >>   LLVMAddAttribute(P, LLVMInRegAttribute);
> >>   }
> >> +
> >> + if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
> >> + /* These were copied from some LLVM test. */
> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> +"less-precise-fpmad",
> >> +"true");
> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> +"no-infs-fp-math",
> >> +"true");
> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> +"no-nans-fp-math",
> >> +"true");
> >> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> >> +"unsafe-fp-math",
> >> +"true");
> >> + }
> >
> > You may get better results by also adding the fast-math flags to the
> > individual floating-point instructions, but this would be a more
> > invasive change.
> 
> Is there sample code showing how to do that?
> 

Something like this
https://cgit.freedesktop.org/~tstellar/mesa/commit/?h=fast-math=4fa18fdde3a2b51b2371064bc27729fd1038c219

There are more flags than just the UnsafeAlgebra that is used in the
patch.

-Tom

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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Marek Olšák
On Tue, Jun 21, 2016 at 7:21 PM, Tom Stellard  wrote:
> On Mon, Jun 13, 2016 at 06:27:02PM +0200, Marek Olšák wrote:
>> From: Marek Olšák 
>>
>> ---
>>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
>>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
>>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
>>  3 files changed, 18 insertions(+)
>>
>> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
>> b/src/gallium/drivers/radeon/r600_pipe_common.c
>> index fa9f70d..5d4a679 100644
>> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
>> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
>> @@ -482,6 +482,7 @@ static const struct debug_named_value 
>> common_debug_options[] = {
>>   { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
>> Scheduler." },
>>   { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
>> compiled on demand" },
>>   { "noce", DBG_NO_CE, "Disable the constant engine"},
>> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
>> optimizations" },
>>
>>   DEBUG_NAMED_VALUE_END /* must be last */
>>  };
>> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
>> b/src/gallium/drivers/radeon/r600_pipe_common.h
>> index 77dfc4f..263ef5e 100644
>> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
>> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
>> @@ -99,6 +99,7 @@
>>  #define DBG_SI_SCHED (1llu << 46)
>>  #define DBG_MONOLITHIC_SHADERS   (1llu << 47)
>>  #define DBG_NO_CE(1llu << 48)
>> +#define DBG_UNSAFE_MATH  (1llu << 49)
>>
>>  #define R600_MAP_BUFFER_ALIGNMENT 64
>>  #define R600_MAX_VIEWPORTS16
>> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
>> b/src/gallium/drivers/radeonsi/si_shader.c
>> index 6dc4985..bba6a55 100644
>> --- a/src/gallium/drivers/radeonsi/si_shader.c
>> +++ b/src/gallium/drivers/radeonsi/si_shader.c
>> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
>> si_shader_context *ctx,
>>   else
>>   LLVMAddAttribute(P, LLVMInRegAttribute);
>>   }
>> +
>> + if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
>> + /* These were copied from some LLVM test. */
>> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> +"less-precise-fpmad",
>> +"true");
>> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> +"no-infs-fp-math",
>> +"true");
>> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> +"no-nans-fp-math",
>> +"true");
>> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
>> +"unsafe-fp-math",
>> +"true");
>> + }
>
> You may get better results by also adding the fast-math flags to the
> individual floating-point instructions, but this would be a more
> invasive change.

Is there sample code showing how to do that?

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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Tom Stellard
On Mon, Jun 13, 2016 at 06:27:02PM +0200, Marek Olšák wrote:
> From: Marek Olšák 
> 
> ---
>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
>  3 files changed, 18 insertions(+)
> 
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
> b/src/gallium/drivers/radeon/r600_pipe_common.c
> index fa9f70d..5d4a679 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
> @@ -482,6 +482,7 @@ static const struct debug_named_value 
> common_debug_options[] = {
>   { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
> Scheduler." },
>   { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
> compiled on demand" },
>   { "noce", DBG_NO_CE, "Disable the constant engine"},
> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> optimizations" },
>  
>   DEBUG_NAMED_VALUE_END /* must be last */
>  };
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
> b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 77dfc4f..263ef5e 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -99,6 +99,7 @@
>  #define DBG_SI_SCHED (1llu << 46)
>  #define DBG_MONOLITHIC_SHADERS   (1llu << 47)
>  #define DBG_NO_CE(1llu << 48)
> +#define DBG_UNSAFE_MATH  (1llu << 49)
>  
>  #define R600_MAP_BUFFER_ALIGNMENT 64
>  #define R600_MAX_VIEWPORTS16
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 6dc4985..bba6a55 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
> si_shader_context *ctx,
>   else
>   LLVMAddAttribute(P, LLVMInRegAttribute);
>   }
> +
> + if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
> + /* These were copied from some LLVM test. */
> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +"less-precise-fpmad",
> +"true");
> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +"no-infs-fp-math",
> +"true");
> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +"no-nans-fp-math",
> +"true");
> + LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +"unsafe-fp-math",
> +"true");
> + }

You may get better results by also adding the fast-math flags to the
individual floating-point instructions, but this would be a more
invasive change.

-Tom

>  }
>  
>  static void create_meta_data(struct si_shader_context *ctx)
> -- 
> 2.7.4
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-21 Thread Nicolai Hähnle

Reviewed-by: Nicolai Hähnle 

On 20.06.2016 19:07, Marek Olšák wrote:

Ping

On Mon, Jun 13, 2016 at 6:27 PM, Marek Olšák  wrote:

From: Marek Olšák 

---
  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
  src/gallium/drivers/radeonsi/si_shader.c  | 16 
  3 files changed, 18 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index fa9f70d..5d4a679 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -482,6 +482,7 @@ static const struct debug_named_value 
common_debug_options[] = {
 { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
Scheduler." },
 { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
compiled on demand" },
 { "noce", DBG_NO_CE, "Disable the constant engine"},
+   { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
optimizations" },

 DEBUG_NAMED_VALUE_END /* must be last */
  };
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 77dfc4f..263ef5e 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -99,6 +99,7 @@
  #define DBG_SI_SCHED   (1llu << 46)
  #define DBG_MONOLITHIC_SHADERS (1llu << 47)
  #define DBG_NO_CE  (1llu << 48)
+#define DBG_UNSAFE_MATH(1llu << 49)

  #define R600_MAP_BUFFER_ALIGNMENT 64
  #define R600_MAX_VIEWPORTS16
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 6dc4985..bba6a55 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5255,6 +5255,22 @@ static void si_create_function(struct si_shader_context 
*ctx,
 else
 LLVMAddAttribute(P, LLVMInRegAttribute);
 }
+
+   if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
+   /* These were copied from some LLVM test. */
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "less-precise-fpmad",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-infs-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-nans-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "unsafe-fp-math",
+  "true");
+   }
  }

  static void create_meta_data(struct si_shader_context *ctx)
--
2.7.4


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


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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-20 Thread Marek Olšák
Ping

On Mon, Jun 13, 2016 at 6:27 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> ---
>  src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
>  src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
>  src/gallium/drivers/radeonsi/si_shader.c  | 16 
>  3 files changed, 18 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
> b/src/gallium/drivers/radeon/r600_pipe_common.c
> index fa9f70d..5d4a679 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
> @@ -482,6 +482,7 @@ static const struct debug_named_value 
> common_debug_options[] = {
> { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
> Scheduler." },
> { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
> compiled on demand" },
> { "noce", DBG_NO_CE, "Disable the constant engine"},
> +   { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> optimizations" },
>
> DEBUG_NAMED_VALUE_END /* must be last */
>  };
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
> b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 77dfc4f..263ef5e 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -99,6 +99,7 @@
>  #define DBG_SI_SCHED   (1llu << 46)
>  #define DBG_MONOLITHIC_SHADERS (1llu << 47)
>  #define DBG_NO_CE  (1llu << 48)
> +#define DBG_UNSAFE_MATH(1llu << 49)
>
>  #define R600_MAP_BUFFER_ALIGNMENT 64
>  #define R600_MAX_VIEWPORTS16
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 6dc4985..bba6a55 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -5255,6 +5255,22 @@ static void si_create_function(struct 
> si_shader_context *ctx,
> else
> LLVMAddAttribute(P, LLVMInRegAttribute);
> }
> +
> +   if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
> +   /* These were copied from some LLVM test. */
> +   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +  "less-precise-fpmad",
> +  "true");
> +   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +  "no-infs-fp-math",
> +  "true");
> +   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +  "no-nans-fp-math",
> +  "true");
> +   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
> +  "unsafe-fp-math",
> +  "true");
> +   }
>  }
>
>  static void create_meta_data(struct si_shader_context *ctx)
> --
> 2.7.4
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-13 Thread Matt Arsenault

> On Jun 13, 2016, at 09:27, Marek Olšák  wrote:
> 
> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> optimizations" },

Perhaps one for each of the individual fast math options as well (no nans, no 
signed zeros etc.)?___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
 src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
 src/gallium/drivers/radeonsi/si_shader.c  | 16 
 3 files changed, 18 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index fa9f70d..5d4a679 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -482,6 +482,7 @@ static const struct debug_named_value 
common_debug_options[] = {
{ "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
Scheduler." },
{ "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
compiled on demand" },
{ "noce", DBG_NO_CE, "Disable the constant engine"},
+   { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
optimizations" },
 
DEBUG_NAMED_VALUE_END /* must be last */
 };
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 77dfc4f..263ef5e 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -99,6 +99,7 @@
 #define DBG_SI_SCHED   (1llu << 46)
 #define DBG_MONOLITHIC_SHADERS (1llu << 47)
 #define DBG_NO_CE  (1llu << 48)
+#define DBG_UNSAFE_MATH(1llu << 49)
 
 #define R600_MAP_BUFFER_ALIGNMENT 64
 #define R600_MAX_VIEWPORTS16
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 6dc4985..bba6a55 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5255,6 +5255,22 @@ static void si_create_function(struct si_shader_context 
*ctx,
else
LLVMAddAttribute(P, LLVMInRegAttribute);
}
+
+   if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
+   /* These were copied from some LLVM test. */
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "less-precise-fpmad",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-infs-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-nans-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "unsafe-fp-math",
+  "true");
+   }
 }
 
 static void create_meta_data(struct si_shader_context *ctx)
-- 
2.7.4

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