[Mesa-dev] [PATCH v2 1/5] i965/eu: add support for 1-OWord Block Read/Write messages

2017-07-19 Thread Samuel Iglesias Gonsálvez
v2:
- Use nibctrl and the number of written/read owords to detect
each case of a 1-OWord Block Read/Write (Curro)

Signed-off-by: Samuel Iglesias Gonsálvez 
---
 src/intel/compiler/brw_eu.h | 14 +-
 src/intel/compiler/brw_eu_emit.c| 46 +
 src/intel/compiler/brw_fs_generator.cpp |  4 +--
 3 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index a3a9c63239..de8470b4b5 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -342,15 +342,15 @@ void brw_oword_block_read(struct brw_codegen *p,
 unsigned brw_scratch_surface_idx(const struct brw_codegen *p);
 
 void brw_oword_block_read_scratch(struct brw_codegen *p,
- struct brw_reg dest,
- struct brw_reg mrf,
- int num_regs,
- unsigned offset);
+  struct brw_reg dest,
+  struct brw_reg mrf,
+  int num_owords,
+  unsigned offset);
 
 void brw_oword_block_write_scratch(struct brw_codegen *p,
-  struct brw_reg mrf,
-  int num_regs,
-  unsigned offset);
+   struct brw_reg mrf,
+   int num_owords,
+   unsigned offset);
 
 void gen7_block_read_scratch(struct brw_codegen *p,
  struct brw_reg dest,
diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c
index 0b0d67a5c5..956ef263a2 100644
--- a/src/intel/compiler/brw_eu_emit.c
+++ b/src/intel/compiler/brw_eu_emit.c
@@ -2133,9 +2133,9 @@ brw_scratch_surface_idx(const struct brw_codegen *p)
  * register spilling.
  */
 void brw_oword_block_write_scratch(struct brw_codegen *p,
-  struct brw_reg mrf,
-  int num_regs,
-  unsigned offset)
+   struct brw_reg mrf,
+   int num_owords,
+   unsigned offset)
 {
const struct gen_device_info *devinfo = p->devinfo;
const unsigned target_cache =
@@ -2149,7 +2149,7 @@ void brw_oword_block_write_scratch(struct brw_codegen *p,
 
mrf = retype(mrf, BRW_REGISTER_TYPE_UD);
 
-   const unsigned mlen = 1 + num_regs;
+   const unsigned mlen = 1 + MAX2(1, num_owords / 2);
 
/* Set up the message header.  This is g0, with g0.2 filled with
 * the offset.  We don't want to leave our offset around in g0 or
@@ -2180,6 +2180,18 @@ void brw_oword_block_write_scratch(struct brw_codegen *p,
   int send_commit_msg;
   struct brw_reg src_header = retype(brw_vec8_grf(0, 0),
 BRW_REGISTER_TYPE_UW);
+  int msg_control = BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_owords * 4);
+
+  /* By default for 1-oword, msg_control = 
BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW,
+   * fix it when we are writing the high part.
+   */
+  if (num_owords == 1 && brw_inst_nib_control(devinfo, insn) != 0) {
+ msg_control = BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH;
+ /* The messages only work with group == 0, we use the group to know 
which
+  * message emit (1-OWORD LOW or 1-OWORD HIGH), so reset it to zero.
+  */
+ brw_inst_set_group(devinfo, insn, 0);
+  }
 
   brw_inst_set_compression(devinfo, insn, false);
 
@@ -2223,7 +2235,7 @@ void brw_oword_block_write_scratch(struct brw_codegen *p,
   brw_set_dp_write_message(p,
   insn,
brw_scratch_surface_idx(p),
-  BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_regs * 8),
+  msg_control,
   msg_type,
target_cache,
   mlen,
@@ -2245,10 +2257,10 @@ void brw_oword_block_write_scratch(struct brw_codegen 
*p,
  */
 void
 brw_oword_block_read_scratch(struct brw_codegen *p,
-struct brw_reg dest,
-struct brw_reg mrf,
-int num_regs,
-unsigned offset)
+ struct brw_reg dest,
+ struct brw_reg mrf,
+ int num_owords,
+ unsigned offset)
 {
const struct gen_device_info *devinfo = p->devinfo;
 
@@ -2269,7 +2281,7 @@ brw_oword_block_read_scratch(struct brw_codegen *p,
}
dest = retype(dest, BRW_REGISTER_TYPE_UW);
 
-   const unsigned rlen = num_regs;
+   const unsigned rlen = MAX2(1, num_owords / 2);
const unsigned target_cache =

Re: [Mesa-dev] [PATCH v2 1/5] i965/eu: add support for 1-OWord Block Read/Write messages

2017-08-11 Thread Mark Janes
This series resolves
https://bugs.freedesktop.org/show_bug.cgi?id=101985, currently blocking
17.2 release.

Tested-by: Mark Janes 

Samuel Iglesias Gonsálvez  writes:

> v2:
> - Use nibctrl and the number of written/read owords to detect
> each case of a 1-OWord Block Read/Write (Curro)
>
> Signed-off-by: Samuel Iglesias Gonsálvez 
> ---
>  src/intel/compiler/brw_eu.h | 14 +-
>  src/intel/compiler/brw_eu_emit.c| 46 
> +
>  src/intel/compiler/brw_fs_generator.cpp |  4 +--
>  3 files changed, 44 insertions(+), 20 deletions(-)
>
> diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
> index a3a9c63239..de8470b4b5 100644
> --- a/src/intel/compiler/brw_eu.h
> +++ b/src/intel/compiler/brw_eu.h
> @@ -342,15 +342,15 @@ void brw_oword_block_read(struct brw_codegen *p,
>  unsigned brw_scratch_surface_idx(const struct brw_codegen *p);
>  
>  void brw_oword_block_read_scratch(struct brw_codegen *p,
> -   struct brw_reg dest,
> -   struct brw_reg mrf,
> -   int num_regs,
> -   unsigned offset);
> +  struct brw_reg dest,
> +  struct brw_reg mrf,
> +  int num_owords,
> +  unsigned offset);
>  
>  void brw_oword_block_write_scratch(struct brw_codegen *p,
> -struct brw_reg mrf,
> -int num_regs,
> -unsigned offset);
> +   struct brw_reg mrf,
> +   int num_owords,
> +   unsigned offset);
>  
>  void gen7_block_read_scratch(struct brw_codegen *p,
>   struct brw_reg dest,
> diff --git a/src/intel/compiler/brw_eu_emit.c 
> b/src/intel/compiler/brw_eu_emit.c
> index 0b0d67a5c5..956ef263a2 100644
> --- a/src/intel/compiler/brw_eu_emit.c
> +++ b/src/intel/compiler/brw_eu_emit.c
> @@ -2133,9 +2133,9 @@ brw_scratch_surface_idx(const struct brw_codegen *p)
>   * register spilling.
>   */
>  void brw_oword_block_write_scratch(struct brw_codegen *p,
> -struct brw_reg mrf,
> -int num_regs,
> -unsigned offset)
> +   struct brw_reg mrf,
> +   int num_owords,
> +   unsigned offset)
>  {
> const struct gen_device_info *devinfo = p->devinfo;
> const unsigned target_cache =
> @@ -2149,7 +2149,7 @@ void brw_oword_block_write_scratch(struct brw_codegen 
> *p,
>  
> mrf = retype(mrf, BRW_REGISTER_TYPE_UD);
>  
> -   const unsigned mlen = 1 + num_regs;
> +   const unsigned mlen = 1 + MAX2(1, num_owords / 2);
>  
> /* Set up the message header.  This is g0, with g0.2 filled with
>  * the offset.  We don't want to leave our offset around in g0 or
> @@ -2180,6 +2180,18 @@ void brw_oword_block_write_scratch(struct brw_codegen 
> *p,
>int send_commit_msg;
>struct brw_reg src_header = retype(brw_vec8_grf(0, 0),
>BRW_REGISTER_TYPE_UW);
> +  int msg_control = BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_owords * 4);
> +
> +  /* By default for 1-oword, msg_control = 
> BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW,
> +   * fix it when we are writing the high part.
> +   */
> +  if (num_owords == 1 && brw_inst_nib_control(devinfo, insn) != 0) {
> + msg_control = BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH;
> + /* The messages only work with group == 0, we use the group to know 
> which
> +  * message emit (1-OWORD LOW or 1-OWORD HIGH), so reset it to zero.
> +  */
> + brw_inst_set_group(devinfo, insn, 0);
> +  }
>  
>brw_inst_set_compression(devinfo, insn, false);
>  
> @@ -2223,7 +2235,7 @@ void brw_oword_block_write_scratch(struct brw_codegen 
> *p,
>brw_set_dp_write_message(p,
>  insn,
> brw_scratch_surface_idx(p),
> -BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_regs * 8),
> +msg_control,
>  msg_type,
> target_cache,
>  mlen,
> @@ -2245,10 +2257,10 @@ void brw_oword_block_write_scratch(struct brw_codegen 
> *p,
>   */
>  void
>  brw_oword_block_read_scratch(struct brw_codegen *p,
> -  struct brw_reg dest,
> -  struct brw_reg mrf,
> -  int num_regs,
> -  unsigned offset)
> + struct brw_reg dest,
> + struct brw_reg mrf,
> + int num_owords,
> + 

Re: [Mesa-dev] [PATCH v2 1/5] i965/eu: add support for 1-OWord Block Read/Write messages

2017-08-15 Thread Francisco Jerez
Mark Janes  writes:

> This series resolves
> https://bugs.freedesktop.org/show_bug.cgi?id=101985, currently blocking
> 17.2 release.
>

I have doubts this series is ready for production, though I don't think
it makes a ton of sense for Gen7 fp64 vec4 spilling to be considered a
blocking issue for the 17.2 release?

> Tested-by: Mark Janes 
>
> Samuel Iglesias Gonsálvez  writes:
>
>> v2:
>> - Use nibctrl and the number of written/read owords to detect
>> each case of a 1-OWord Block Read/Write (Curro)
>>
>> Signed-off-by: Samuel Iglesias Gonsálvez 
>> ---
>>  src/intel/compiler/brw_eu.h | 14 +-
>>  src/intel/compiler/brw_eu_emit.c| 46 
>> +
>>  src/intel/compiler/brw_fs_generator.cpp |  4 +--
>>  3 files changed, 44 insertions(+), 20 deletions(-)
>>
>> diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
>> index a3a9c63239..de8470b4b5 100644
>> --- a/src/intel/compiler/brw_eu.h
>> +++ b/src/intel/compiler/brw_eu.h
>> @@ -342,15 +342,15 @@ void brw_oword_block_read(struct brw_codegen *p,
>>  unsigned brw_scratch_surface_idx(const struct brw_codegen *p);
>>  
>>  void brw_oword_block_read_scratch(struct brw_codegen *p,
>> -  struct brw_reg dest,
>> -  struct brw_reg mrf,
>> -  int num_regs,
>> -  unsigned offset);
>> +  struct brw_reg dest,
>> +  struct brw_reg mrf,
>> +  int num_owords,
>> +  unsigned offset);
>>  
>>  void brw_oword_block_write_scratch(struct brw_codegen *p,
>> -   struct brw_reg mrf,
>> -   int num_regs,
>> -   unsigned offset);
>> +   struct brw_reg mrf,
>> +   int num_owords,
>> +   unsigned offset);
>>  
>>  void gen7_block_read_scratch(struct brw_codegen *p,
>>   struct brw_reg dest,
>> diff --git a/src/intel/compiler/brw_eu_emit.c 
>> b/src/intel/compiler/brw_eu_emit.c
>> index 0b0d67a5c5..956ef263a2 100644
>> --- a/src/intel/compiler/brw_eu_emit.c
>> +++ b/src/intel/compiler/brw_eu_emit.c
>> @@ -2133,9 +2133,9 @@ brw_scratch_surface_idx(const struct brw_codegen *p)
>>   * register spilling.
>>   */
>>  void brw_oword_block_write_scratch(struct brw_codegen *p,
>> -   struct brw_reg mrf,
>> -   int num_regs,
>> -   unsigned offset)
>> +   struct brw_reg mrf,
>> +   int num_owords,
>> +   unsigned offset)
>>  {
>> const struct gen_device_info *devinfo = p->devinfo;
>> const unsigned target_cache =
>> @@ -2149,7 +2149,7 @@ void brw_oword_block_write_scratch(struct brw_codegen 
>> *p,
>>  
>> mrf = retype(mrf, BRW_REGISTER_TYPE_UD);
>>  
>> -   const unsigned mlen = 1 + num_regs;
>> +   const unsigned mlen = 1 + MAX2(1, num_owords / 2);
>>  
>> /* Set up the message header.  This is g0, with g0.2 filled with
>>  * the offset.  We don't want to leave our offset around in g0 or
>> @@ -2180,6 +2180,18 @@ void brw_oword_block_write_scratch(struct brw_codegen 
>> *p,
>>int send_commit_msg;
>>struct brw_reg src_header = retype(brw_vec8_grf(0, 0),
>>   BRW_REGISTER_TYPE_UW);
>> +  int msg_control = BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_owords * 4);
>> +
>> +  /* By default for 1-oword, msg_control = 
>> BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW,
>> +   * fix it when we are writing the high part.
>> +   */
>> +  if (num_owords == 1 && brw_inst_nib_control(devinfo, insn) != 0) {
>> + msg_control = BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH;
>> + /* The messages only work with group == 0, we use the group to 
>> know which
>> +  * message emit (1-OWORD LOW or 1-OWORD HIGH), so reset it to zero.
>> +  */
>> + brw_inst_set_group(devinfo, insn, 0);
>> +  }
>>  
>>brw_inst_set_compression(devinfo, insn, false);
>>  
>> @@ -2223,7 +2235,7 @@ void brw_oword_block_write_scratch(struct brw_codegen 
>> *p,
>>brw_set_dp_write_message(p,
>> insn,
>> brw_scratch_surface_idx(p),
>> -   BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_regs * 8),
>> +   msg_control,
>> msg_type,
>> target_cache,
>> mlen,
>> @@ -2245,10 +2257,10 @@ void brw_oword_block_write_scratch(struct 
>> brw_codegen *p,
>>   */
>>  void
>>  brw_oword_block_read_scratch(struct brw_codegen *p,
>> - struct brw_r