[Beignet] [PATCH 3/7] Add Gen75Context and Gen75Encoder class for hsw

junyan.he at inbox.com junyan.he at inbox.com
Tue Apr 15 17:55:48 PDT 2014


From: Junyan He <junyan.he at linux.intel.com>

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/CMakeLists.txt            |    9 +++++--
 backend/src/backend/gen75_context.cpp |   30 +++++++++++++++++++++++
 backend/src/backend/gen75_context.hpp |   42 +++++++++++++++++++++++++++++++++
 backend/src/backend/gen75_encoder.cpp |   33 ++++++++++++++++++++++++++
 backend/src/backend/gen75_encoder.hpp |   39 ++++++++++++++++++++++++++++++
 backend/src/backend/gen_context.cpp   |    8 ++++---
 backend/src/backend/gen_context.hpp   |    6 ++++-
 backend/src/backend/gen_program.cpp   |   11 ++++++++-
 8 files changed, 171 insertions(+), 7 deletions(-)
 create mode 100644 backend/src/backend/gen75_context.cpp
 create mode 100644 backend/src/backend/gen75_context.hpp
 create mode 100644 backend/src/backend/gen75_encoder.cpp
 create mode 100644 backend/src/backend/gen75_encoder.hpp

diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt
index 6e37d95..479885e 100644
--- a/backend/src/CMakeLists.txt
+++ b/backend/src/CMakeLists.txt
@@ -156,13 +156,18 @@ else (GBE_USE_BLOB)
     backend/gen_reg_allocation.cpp
     backend/gen_reg_allocation.hpp
     backend/gen_context.cpp
-    backend/gen_context.hpp
+    backend/gen_context.cpp
+    backend/gen75_context.hpp
+    backend/gen75_context.cpp
     backend/gen_program.cpp
     backend/gen_program.hpp
     backend/gen_program.h
     backend/gen_defs.hpp
     backend/gen_encoder.hpp
-    backend/gen_encoder.cpp)
+    backend/gen_encoder.cpp
+    backend/gen75_encoder.hpp
+    backend/gen75_encoder.cpp
+    )
 
 endif (GBE_USE_BLOB)
 
diff --git a/backend/src/backend/gen75_context.cpp b/backend/src/backend/gen75_context.cpp
new file mode 100644
index 0000000..e101815
--- /dev/null
+++ b/backend/src/backend/gen75_context.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * \file gen75_context.cpp
+ */
+
+#include "backend/gen75_context.hpp"
+#include "backend/gen75_encoder.hpp"
+
+namespace gbe
+{
+
+}
+
diff --git a/backend/src/backend/gen75_context.hpp b/backend/src/backend/gen75_context.hpp
new file mode 100644
index 0000000..1f7ec76
--- /dev/null
+++ b/backend/src/backend/gen75_context.hpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * \file gen75_context.hpp
+ */
+#ifndef __GBE_GEN75_CONTEXT_HPP__
+#define __GBE_GEN75_CONTEXT_HPP__
+
+#include "backend/gen_context.hpp"
+#include "backend/gen75_encoder.hpp"
+
+namespace gbe
+{
+  /* This class is used to implement the HSW
+     specific logic for context. */
+  class Gen75Context : public GenContext
+  {
+  public:
+    Gen75Context(const ir::Unit &unit, const std::string &name, bool limitRegisterPressure = false)
+    	: GenContext(unit, name, limitRegisterPressure, 16, false) {
+      this->p = GBE_NEW(Gen75Encoder, simdWidth, 75);
+    };
+  };
+}
+#endif /* __GBE_GEN75_CONTEXT_HPP__ */
+
diff --git a/backend/src/backend/gen75_encoder.cpp b/backend/src/backend/gen75_encoder.cpp
new file mode 100644
index 0000000..909b301
--- /dev/null
+++ b/backend/src/backend/gen75_encoder.cpp
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) Intel Corp.  2006.  All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **********************************************************************/
+
+#include "backend/gen75_encoder.hpp"
+
+namespace gbe
+{
+
+} /* End of the name space. */
diff --git a/backend/src/backend/gen75_encoder.hpp b/backend/src/backend/gen75_encoder.hpp
new file mode 100644
index 0000000..64b47de
--- /dev/null
+++ b/backend/src/backend/gen75_encoder.hpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * \file gen75_context.hpp
+ */
+#ifndef __GBE_GEN75_ENCODER_HPP__
+#define __GBE_GEN75_ENCODER_HPP__
+
+#include "backend/gen_encoder.hpp"
+
+namespace gbe
+{
+  /* This class is used to implement the HSW
+     specific logic for encoder. */
+  class Gen75Encoder : public GenEncoder
+  {
+  public:
+    Gen75Encoder(uint32_t simdWidth, uint32_t gen) : GenEncoder(simdWidth, gen) { };
+  };
+}
+#endif /* __GBE_GEN75_ENCODER_HPP__ */
+
+
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 9689ac5..3faed98 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -43,10 +43,12 @@ namespace gbe
   ///////////////////////////////////////////////////////////////////////////
   GenContext::GenContext(const ir::Unit &unit,
                          const std::string &name,
-                         bool limitRegisterPressure) :
-    Context(unit, name), limitRegisterPressure(limitRegisterPressure)
+                         bool limitRegisterPressure,
+                         int jump_width, bool generate_encoder) :
+    Context(unit, name), limitRegisterPressure(limitRegisterPressure), jump_width(jump_width)
   {
-    this->p = GBE_NEW(GenEncoder, simdWidth, 7); // XXX handle more than Gen7
+    if (generate_encoder) this->p = GBE_NEW(GenEncoder, simdWidth, 7); // XXX handle more than Gen7
+
     this->sel = GBE_NEW(Selection, *this);
     this->ra = GBE_NEW(GenRegAllocator, *this);
   }
diff --git a/backend/src/backend/gen_context.hpp b/backend/src/backend/gen_context.hpp
index 642301c..b27d5e8 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -52,7 +52,9 @@ namespace gbe
     /*! Create a new context. name is the name of the function we want to
      *  compile
      */
-    GenContext(const ir::Unit &unit, const std::string &name, bool limitRegisterPressure = false);
+    GenContext(const ir::Unit &unit, const std::string &name,
+               bool limitRegisterPressure = false, int jump_width = 2,
+               bool generate_encoder = true);
     /*! Release everything needed */
     ~GenContext(void);
     /*! Implements base class */
@@ -162,6 +164,8 @@ namespace gbe
      * regenerating the code
      */
     bool limitRegisterPressure;
+    /*! The constant for jump. */
+    const int jump_width;
   };
 
 } /* namespace gbe */
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index 21fe636..51282a6 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -26,6 +26,7 @@
 #include "backend/gen_program.h"
 #include "backend/gen_program.hpp"
 #include "backend/gen_context.hpp"
+#include "backend/gen75_context.hpp"
 #include "backend/gen_defs.hpp"
 #include "backend/gen/gen_mesa_disasm.h"
 #include "backend/gen_reg_allocation.hpp"
@@ -102,7 +103,15 @@ namespace gbe {
 
       // Force the SIMD width now and try to compile
       unit.getFunction(name)->setSimdWidth(simdWidth);
-      Context *ctx = GBE_NEW(GenContext, unit, name, limitRegisterPressure);
+      Context *ctx = NULL;
+
+      if (gen_ver == 70) {
+        ctx = GBE_NEW(GenContext, unit, name, limitRegisterPressure);
+      } else if (gen_ver == 75) {
+        ctx = GBE_NEW(Gen75Context, unit, name, limitRegisterPressure);
+      }
+      assert(ctx);
+
       kernel = ctx->compileKernel();
       if (kernel != NULL) {
         break;
-- 
1.7.9.5





More information about the Beignet mailing list