[Beignet] [PATCH] enable unsigned 64bit version of "abs_diff"

Homer Hsing homer.xing at intel.com
Sun Aug 18 19:38:00 PDT 2013


tested by piglit,

piglit/framework/../bin/cl-program-tester generated_tests/cl/builtin/int/builtin-ulong-abs_diff-1.0.generated.cl

piglit test case passed.

Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/backend/gen_context.cpp | 10 ++++++++++
 backend/src/ocl_stdlib.tmpl.h       |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index fcd16ec..8d4bc7a 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -562,8 +562,11 @@ namespace gbe
         loadBottomHalf(tmp1, src1);
         p->CMP(insn.extra.function, tmp0, tmp1);
         saveFlag(f3, 0, 1);
+        p->push();
+        p->curr.execWidth = 1;
         p->AND(f2, f2, f3);
         p->OR(f1, f1, f2);
+        p->pop();
         break;
       case GEN_CONDITIONAL_EQ:
         p->CMP(GEN_CONDITIONAL_EQ, tmp0, tmp1);
@@ -573,7 +576,10 @@ namespace gbe
         loadBottomHalf(tmp1, src1);
         p->CMP(GEN_CONDITIONAL_EQ, tmp0, tmp1);
         saveFlag(f2, 0, 1);
+        p->push();
+        p->curr.execWidth = 1;
         p->AND(f1, f1, f2);
+        p->pop();
         break;
       case GEN_CONDITIONAL_NEQ:
         p->CMP(GEN_CONDITIONAL_NEQ, tmp0, tmp1);
@@ -583,12 +589,16 @@ namespace gbe
         loadBottomHalf(tmp1, src1);
         p->CMP(GEN_CONDITIONAL_NEQ, tmp0, tmp1);
         saveFlag(f2, 0, 1);
+        p->push();
+        p->curr.execWidth = 1;
         p->OR(f1, f1, f2);
+        p->pop();
         break;
       default:
         NOT_IMPLEMENTED;
     }
     saveFlag(f2, flag, subFlag);
+    p->curr.execWidth = 1;
     p->AND(f1, f1, f2);
     p->MOV(GenRegister::flag(flag, subFlag), f1);
     p->pop();
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index 8d4220c..59c0f6b 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -511,7 +511,7 @@ INLINE_OVERLOADABLE ulong abs_diff (long x, long y) {
   return 0;
 }
 INLINE_OVERLOADABLE ulong abs_diff (ulong x, ulong y) {
-  return 0;
+  return y > x ? (y - x) : (x - y);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-- 
1.8.1.2



More information about the Beignet mailing list