Re: [Mesa-dev] [PATCH 2/2] nv50/ir: initialize relDegree staticly

2018-12-07 Thread Ilia Mirkin
Reviewed-by: Ilia Mirkin 
On Fri, Dec 7, 2018 at 3:57 AM Karol Herbst  wrote:
>
> this race condition is pretty harmless, but also pretty trivial to fix
>
> Signed-off-by: Karol Herbst 
> ---
>  .../drivers/nouveau/codegen/nv50_ir_ra.cpp| 23 +--
>  1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
> index 23bd07af33a..5d1a96f8d71 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
> @@ -803,7 +803,21 @@ private:
> Function *func;
> Program *prog;
>
> -   static uint8_t relDegree[17][17];
> +   struct RelDegree {
> +  uint8_t data[17][17];
> +
> +  RelDegree() {
> + for (int i = 1; i <= 16; ++i)
> +for (int j = 1; j <= 16; ++j)
> +   data[i][j] = j * ((i + j - 1) / j);
> +  }
> +
> +  const uint8_t* operator[](std::size_t i) const {
> + return data[i];
> +  }
> +   };
> +
> +   static const RelDegree relDegree;
>
> RegisterSet regs;
>
> @@ -815,7 +829,7 @@ private:
> std::list mustSpill;
>  };
>
> -uint8_t GCRA::relDegree[17][17];
> +const GCRA::RelDegree GCRA::relDegree;
>
>  GCRA::RIG_Node::RIG_Node() : Node(NULL), next(this), prev(this)
>  {
> @@ -1172,11 +1186,6 @@ GCRA::GCRA(Function *fn, SpillCodeInserter& spill) :
> spill(spill)
>  {
> prog = func->getProgram();
> -
> -   // initialize relative degrees array - i takes away from j
> -   for (int i = 1; i <= 16; ++i)
> -  for (int j = 1; j <= 16; ++j)
> - relDegree[i][j] = j * ((i + j - 1) / j);
>  }
>
>  GCRA::~GCRA()
> --
> 2.19.2
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] nv50/ir: initialize relDegree staticly

2018-12-07 Thread Karol Herbst
this race condition is pretty harmless, but also pretty trivial to fix

Signed-off-by: Karol Herbst 
---
 .../drivers/nouveau/codegen/nv50_ir_ra.cpp| 23 +--
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
index 23bd07af33a..5d1a96f8d71 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
@@ -803,7 +803,21 @@ private:
Function *func;
Program *prog;
 
-   static uint8_t relDegree[17][17];
+   struct RelDegree {
+  uint8_t data[17][17];
+
+  RelDegree() {
+ for (int i = 1; i <= 16; ++i)
+for (int j = 1; j <= 16; ++j)
+   data[i][j] = j * ((i + j - 1) / j);
+  }
+
+  const uint8_t* operator[](std::size_t i) const {
+ return data[i];
+  }
+   };
+
+   static const RelDegree relDegree;
 
RegisterSet regs;
 
@@ -815,7 +829,7 @@ private:
std::list mustSpill;
 };
 
-uint8_t GCRA::relDegree[17][17];
+const GCRA::RelDegree GCRA::relDegree;
 
 GCRA::RIG_Node::RIG_Node() : Node(NULL), next(this), prev(this)
 {
@@ -1172,11 +1186,6 @@ GCRA::GCRA(Function *fn, SpillCodeInserter& spill) :
spill(spill)
 {
prog = func->getProgram();
-
-   // initialize relative degrees array - i takes away from j
-   for (int i = 1; i <= 16; ++i)
-  for (int j = 1; j <= 16; ++j)
- relDegree[i][j] = j * ((i + j - 1) / j);
 }
 
 GCRA::~GCRA()
-- 
2.19.2

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