[Beignet] [PATCH] Add scalar version of "convert_*(*)"

Homer Hsing homer.xing at intel.com
Sun Sep 1 22:21:47 PDT 2013


Scalar version of "convert_*(*)" was missing.
This patch adds scalar version.

Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/gen_convert.sh |  17 ++-
 backend/src/ocl_convert.h  | 360 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 375 insertions(+), 2 deletions(-)

diff --git a/backend/src/gen_convert.sh b/backend/src/gen_convert.sh
index 056b529..5632e04 100755
--- a/backend/src/gen_convert.sh
+++ b/backend/src/gen_convert.sh
@@ -5,8 +5,20 @@
 # For all vector lengths and types, generate conversion functions
 for vector_length in $VECTOR_LENGTHS; do
         if test $vector_length -eq 1; then
-                continue;
-        fi
+          for ftype in $TYPES; do
+            fbasetype=`IFS=:; set -- dummy $ftype; echo $2`
+            for ttype in $TYPES; do
+              tbasetype=`IFS=:; set -- dummy $ttype; echo $2`
+              if test $fbasetype = $tbasetype; then
+                continue
+              fi
+              echo "INLINE OVERLOADABLE $tbasetype convert_$tbasetype($fbasetype v) {"
+              echo "  return ($tbasetype)v;"
+              echo "}"
+              echo
+            done
+          done
+        else
         for ftype in $TYPES; do
                 fbasetype=`IFS=:; set -- dummy $ftype; echo $2`
                 for ttype in $TYPES; do
@@ -49,4 +61,5 @@ for vector_length in $VECTOR_LENGTHS; do
                         echo
                 done
         done
+        fi
 done
diff --git a/backend/src/ocl_convert.h b/backend/src/ocl_convert.h
index 4063788..8b00577 100644
--- a/backend/src/ocl_convert.h
+++ b/backend/src/ocl_convert.h
@@ -1,5 +1,365 @@
 // This file is autogenerated by gen_convert.sh.
 // Don't modify it manually.
+INLINE OVERLOADABLE ulong convert_ulong(long v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(long v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(long v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(long v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(long v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(long v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(long v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(long v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(long v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(ulong v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE int convert_int(ulong v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(ulong v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(ulong v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(ulong v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(ulong v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(ulong v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(ulong v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(ulong v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(int v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(int v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(int v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(int v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(int v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(int v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(int v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(int v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(int v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(uint v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(uint v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(uint v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE short convert_short(uint v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(uint v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(uint v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(uint v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(uint v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(uint v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(short v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(short v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(short v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(short v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(short v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(short v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(short v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(short v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(short v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(ushort v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(ushort v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(ushort v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(ushort v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(ushort v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE char convert_char(ushort v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(ushort v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(ushort v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(ushort v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(char v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(char v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(char v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(char v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(char v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(char v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(char v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(char v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(char v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(uchar v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(uchar v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(uchar v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(uchar v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(uchar v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(uchar v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(uchar v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE double convert_double(uchar v) {
+  return (double)v;
+}
+
+INLINE OVERLOADABLE float convert_float(uchar v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(double v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(double v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(double v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(double v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(double v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(double v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(double v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(double v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE float convert_float(double v) {
+  return (float)v;
+}
+
+INLINE OVERLOADABLE long convert_long(float v) {
+  return (long)v;
+}
+
+INLINE OVERLOADABLE ulong convert_ulong(float v) {
+  return (ulong)v;
+}
+
+INLINE OVERLOADABLE int convert_int(float v) {
+  return (int)v;
+}
+
+INLINE OVERLOADABLE uint convert_uint(float v) {
+  return (uint)v;
+}
+
+INLINE OVERLOADABLE short convert_short(float v) {
+  return (short)v;
+}
+
+INLINE OVERLOADABLE ushort convert_ushort(float v) {
+  return (ushort)v;
+}
+
+INLINE OVERLOADABLE char convert_char(float v) {
+  return (char)v;
+}
+
+INLINE OVERLOADABLE uchar convert_uchar(float v) {
+  return (uchar)v;
+}
+
+INLINE OVERLOADABLE double convert_double(float v) {
+  return (double)v;
+}
+
 INLINE OVERLOADABLE ulong2 convert_ulong2(long2 v) {
   return (ulong2)((ulong)(v.s0), (ulong)(v.s1));
 }
-- 
1.8.1.2



More information about the Beignet mailing list