[Beignet] [PATCH 17/19] Backend: Add ADD_ and SUB_ timestamps help functions.
Yang, Rong R
rong.r.yang at intel.com
Tue Nov 3 06:08:33 PST 2015
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> junyan.he at inbox.com
> Sent: Wednesday, September 9, 2015 8:01
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH 17/19] Backend: Add ADD_ and SUB_ timestamps
> help functions.
>
> From: Junyan He <junyan.he at linux.intel.com>
>
> The timestamps are calculated by Long type. Before BDW, there is no Long
> type support and we use i32 operations to implement them.
>
> Signed-off-by: Junyan He <junyan.he at linux.intel.com>
> ---
> backend/src/backend/gen8_context.cpp | 24 +++++++++++++++
> backend/src/backend/gen8_context.hpp | 2 ++
> backend/src/backend/gen_context.cpp | 53
> ++++++++++++++++++++++++++++++++++
> backend/src/backend/gen_context.hpp | 2 ++
> 4 files changed, 81 insertions(+)
>
> diff --git a/backend/src/backend/gen8_context.cpp
> b/backend/src/backend/gen8_context.cpp
> index b497ee5..9b2fc97 100644
> --- a/backend/src/backend/gen8_context.cpp
> +++ b/backend/src/backend/gen8_context.cpp
> @@ -943,6 +943,30 @@ namespace gbe
> p->pop();
> }
>
> + void Gen8Context::subTimestamps(GenRegister& t0, GenRegister& t1,
> + GenRegister& tmp) {
> + p->push(); {
> + p->curr.execWidth = 1;
> + p->curr.predicate = GEN_PREDICATE_NONE;
> + p->curr.noMask = 1;
> + p->ADD(GenRegister::retype(t0, GEN_TYPE_UL), GenRegister::retype(t0,
> GEN_TYPE_UL),
> + GenRegister::negate(GenRegister::retype(t1, GEN_TYPE_UL)));
> + p->MOV(GenRegister::retype(tmp, GEN_TYPE_UL),
> GenRegister::immuint64(0xffffffffffffffff));
Sub just add neg(t1), right? Need not add 0xffffffffffffffff, it just -1.
> + p->ADD(GenRegister::retype(t0, GEN_TYPE_UL), GenRegister::retype(t0,
> GEN_TYPE_UL),
> + GenRegister::retype(tmp, GEN_TYPE_UL));
> + } p->pop();
> + }
> +
> + void Gen8Context::addTimestamps(GenRegister& t0, GenRegister& t1,
> GenRegister& tmp) {
> + p->push(); {
> + p->curr.execWidth = 1;
> + p->curr.predicate = GEN_PREDICATE_NONE;
> + p->curr.noMask = 1;
> + p->ADD(GenRegister::retype(t0, GEN_TYPE_UL), GenRegister::retype(t0,
> GEN_TYPE_UL),
> + GenRegister::retype(t1, GEN_TYPE_UL));
> + } p->pop();
> + }
> +
> void ChvContext::newSelection(void) {
> this->sel = GBE_NEW(SelectionChv, *this);
> }
> diff --git a/backend/src/backend/gen8_context.hpp
> b/backend/src/backend/gen8_context.hpp
> index 84508e9..aab1fd0 100644
> --- a/backend/src/backend/gen8_context.hpp
> +++ b/backend/src/backend/gen8_context.hpp
> @@ -76,6 +76,8 @@ namespace gbe
>
> protected:
> virtual void setA0Content(uint16_t new_a0[16], uint16_t max_offset = 0,
> int sz = 0);
> + virtual void subTimestamps(GenRegister& t0, GenRegister& t1,
> GenRegister& tmp);
> + virtual void addTimestamps(GenRegister& t0, GenRegister& t1,
> + GenRegister& tmp);
> virtual GenEncoder* generateEncoder(void) {
> return GBE_NEW(Gen8Encoder, this->simdWidth, 8, deviceID);
> }
> diff --git a/backend/src/backend/gen_context.cpp
> b/backend/src/backend/gen_context.cpp
> index a12d056..7789fe7 100644
> --- a/backend/src/backend/gen_context.cpp
> +++ b/backend/src/backend/gen_context.cpp
> @@ -2242,6 +2242,59 @@ namespace gbe
> #undef CALC_GID
> }
>
> + void GenContext::subTimestamps(GenRegister& t0, GenRegister& t1,
> + GenRegister& tmp) {
> + p->push(); {
> + p->curr.execWidth = 1;
> + p->curr.predicate = GEN_PREDICATE_NONE;
> + p->curr.noMask = 1;
> + p->SUBB(GenRegister::retype(t0, GEN_TYPE_UD),
> + GenRegister::retype(t0, GEN_TYPE_UD), GenRegister::retype(t1,
> GEN_TYPE_UD));
> + /* FIXME We can not get the acc register's value correctly by set simd = 1.
> */
> + p->curr.execWidth = 8;
> + p->MOV(tmp, GenRegister::retype(GenRegister::acc(), GEN_TYPE_UD));
> + p->curr.execWidth = 1;
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::negate(GenRegister::toUniform(tmp, GEN_TYPE_UD)));
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::negate(GenRegister::retype(GenRegister::offset(t1, 0,
> sizeof(uint32_t)), GEN_TYPE_UD)));
> + // Mod 0xFFFFFFFF FFFFFFFF
> + p->ADDC(GenRegister::retype(t0, GEN_TYPE_UD),
> + GenRegister::retype(t0, GEN_TYPE_UD),
> GenRegister::immud(0xffffffff));
> + p->curr.execWidth = 8;
> + p->MOV(tmp, GenRegister::retype(GenRegister::acc(), GEN_TYPE_UD));
> + p->curr.execWidth = 1;
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::toUniform(tmp, GEN_TYPE_UD));
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::immud(0xffffffff));
> + } p->pop();
> + }
> +
> + void GenContext::addTimestamps(GenRegister& t0, GenRegister& t1,
> + GenRegister& tmp) {
> + p->push(); {
> + p->curr.execWidth = 1;
> + p->curr.predicate = GEN_PREDICATE_NONE;
> + p->curr.noMask = 1;
> + p->ADDC(GenRegister::retype(t0, GEN_TYPE_UD),
> + GenRegister::retype(t0, GEN_TYPE_UD), GenRegister::retype(t1,
> GEN_TYPE_UD));
> + p->curr.execWidth = 8;
> + p->MOV(tmp, GenRegister::retype(GenRegister::acc(), GEN_TYPE_UD));
> + p->curr.execWidth = 1;
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::offset(GenRegister::toUniform(tmp, GEN_TYPE_UD), 0,
> 6*sizeof(uint32_t)));
> + p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)),
> GEN_TYPE_UD),
> + GenRegister::retype(GenRegister::offset(t1, 0, sizeof(uint32_t)),
> GEN_TYPE_UD));
> + } p->pop();
> + }
> +
> void GenContext::profilingProlog(void) {
> // record the prolog, globalXYZ and lasttimestamp at the very beginning.
> GenRegister profilingReg2, profilingReg3, profilingReg4; diff --git
> a/backend/src/backend/gen_context.hpp
> b/backend/src/backend/gen_context.hpp
> index e36c8e6..5600dcd 100644
> --- a/backend/src/backend/gen_context.hpp
> +++ b/backend/src/backend/gen_context.hpp
> @@ -223,6 +223,8 @@ namespace gbe
>
> virtual void setA0Content(uint16_t new_a0[16], uint16_t max_offset = 0,
> int sz = 0);
> void calcGlobalXYZRange(GenRegister& reg, GenRegister& tmp, int flag,
> int subFlag);
> + virtual void subTimestamps(GenRegister& t0, GenRegister& t1,
> GenRegister& tmp);
> + virtual void addTimestamps(GenRegister& t0, GenRegister& t1,
> + GenRegister& tmp);
>
> private:
> CompileErrorCode errCode;
> --
> 1.7.9.5
>
>
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list