/* !!!! AUTOGENERATED FILE generated by test_convert_type.py !!!!!

   DO NOT CHANGE THIS FILE. MAKE YOUR CHANGES TO test_convert_type.py AND RUN:
   $ python3 test_convert_type.py > test_convert_type.cl
*/

#if __clang_major__ == 3 && __clang_minor__ < 4
typedef const char* string;     /* for backward compatibility */
#else
typedef constant char* string;
#endif

constant char char_values[6] = { 0, 1, CHAR_MIN, CHAR_MAX, CHAR_MIN / 2, CHAR_MAX / 2 };
constant uchar uchar_values[6] = { 0, 1, 0, UCHAR_MAX, 0 / 2, UCHAR_MAX / 2 };
constant short short_values[6] = { 0, 1, SHRT_MIN, SHRT_MAX, SHRT_MIN / 2, SHRT_MAX / 2 };
constant ushort ushort_values[6] = { 0, 1, 0, USHRT_MAX, 0 / 2, USHRT_MAX / 2 };
constant int int_values[6] = { 0, 1, INT_MIN, INT_MAX, INT_MIN / 2, INT_MAX / 2 };
constant uint uint_values[6] = { 0, 1, 0, UINT_MAX, 0 / 2, UINT_MAX / 2 };

constant size_t char_values_length = sizeof(char_values) / sizeof(char_values[0]);
constant size_t uchar_values_length = sizeof(uchar_values) / sizeof(uchar_values[0]);
constant size_t short_values_length = sizeof(short_values) / sizeof(short_values[0]);
constant size_t ushort_values_length = sizeof(ushort_values) / sizeof(ushort_values[0]);
constant size_t int_values_length = sizeof(int_values) / sizeof(int_values[0]);
constant size_t uint_values_length = sizeof(uint_values) / sizeof(uint_values[0]);

#ifdef cl_khr_int64
constant long long_values[6] = { 0, 1, LONG_MIN, LONG_MAX, LONG_MIN / 2, LONG_MAX / 2 };
constant ulong ulong_values[6] = { 0, 1, 0, ULONG_MAX, 0 / 2, ULONG_MAX / 2 };

constant size_t long_values_length = sizeof(long_values) / sizeof(long_values[0]);
constant size_t ulong_values_length = sizeof(ulong_values) / sizeof(ulong_values[0]);

#endif

#ifdef cl_khr_fp64
constant float float_sat_offsets[16] =
{
   0.0f, (float)CHAR_MAX, (float)CHAR_MIN, (float)UCHAR_MAX, (float)SHRT_MIN, (float)SHRT_MAX, (float)USHRT_MAX, (float)INT_MAX,
   (float)INT_MIN, (float)UINT_MAX, (float)LONG_MAX, (float)LONG_MIN, (float)ULONG_MAX, 0.0f, 1.0e15f, -1.0e15f
};
#else
constant float float_sat_offsets[13] =
{
   0.0f, (float)CHAR_MAX, (float)CHAR_MIN, (float)UCHAR_MAX, (float)SHRT_MIN, (float)SHRT_MAX, (float)USHRT_MAX, (float)INT_MAX,
   (float)INT_MIN, (float)UINT_MAX, 0.0f, 1.0e15f, -1.0e15f
};
#endif

constant float float_values            [17] = { -2.0f, -1.75f, -1.5f, -1.25f, -1.0f, -0.75f, -0.5f, -0.25f, 0.0f, 0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f };
constant int float_rounded_values    [17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };
constant int float_rounded_values_rtz[17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };
constant int float_rounded_values_rte[17] = { -2     , -2      , -2     , -1      , -1     , -1      ,  0     ,  0      , 0     , 0      , 0     , 1      , 1     , 1      , 2     , 2      , 2      };
constant int float_rounded_values_rtp[17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 1      , 1     , 1      , 1     , 2      , 2     , 2      , 2      };
constant int float_rounded_values_rtn[17] = { -2     , -2      , -2     , -2      , -1     , -1      , -1     , -1      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };

constant size_t float_values_length = sizeof(float_values) / sizeof(float_values[0]);


#ifdef cl_khr_fp64

#ifdef cl_khr_fp64
constant double double_sat_offsets[16] =
{
   0.0, (double)CHAR_MAX, (double)CHAR_MIN, (double)UCHAR_MAX, (double)SHRT_MIN, (double)SHRT_MAX, (double)USHRT_MAX, (double)INT_MAX,
   (double)INT_MIN, (double)UINT_MAX, (double)LONG_MAX, (double)LONG_MIN, (double)ULONG_MAX, 0.0, 1.0e15, -1.0e15
};
#else
constant double double_sat_offsets[13] =
{
   0.0, (double)CHAR_MAX, (double)CHAR_MIN, (double)UCHAR_MAX, (double)SHRT_MIN, (double)SHRT_MAX, (double)USHRT_MAX, (double)INT_MAX,
   (double)INT_MIN, (double)UINT_MAX, 0.0, 1.0e15, -1.0e15
};
#endif

constant double double_values            [17] = { -2.0, -1.75, -1.5, -1.25, -1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0 };
constant long double_rounded_values    [17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };
constant long double_rounded_values_rtz[17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };
constant long double_rounded_values_rte[17] = { -2     , -2      , -2     , -1      , -1     , -1      ,  0     ,  0      , 0     , 0      , 0     , 1      , 1     , 1      , 2     , 2      , 2      };
constant long double_rounded_values_rtp[17] = { -2     , -1      , -1     , -1      , -1     ,  0      ,  0     ,  0      , 0     , 1      , 1     , 1      , 1     , 2      , 2     , 2      , 2      };
constant long double_rounded_values_rtn[17] = { -2     , -2      , -2     , -2      , -1     , -1      , -1     , -1      , 0     , 0      , 0     , 0      , 1     , 1      , 1     , 1      , 2      };

constant size_t double_values_length = sizeof(double_values) / sizeof(double_values[0]);


#endif

_CL_NOINLINE
void compare_char_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_char_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_char_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_char_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_char_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_char_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_char_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_char_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_char_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_char_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const char* expected, const char* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_uchar_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uchar_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uchar_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uchar_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uchar_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uchar_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_uchar_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_uchar_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_uchar_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_uchar_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const uchar* expected, const uchar* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.2hhx actual: %#.2hhx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_short_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_short_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_short_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_short_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_short_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_short_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_short_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_short_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_short_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_short_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const short* expected, const short* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_ushort_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_ushort_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_ushort_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_ushort_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_ushort_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_ushort_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ushort_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ushort_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_ushort_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_ushort_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const ushort* expected, const ushort* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.4hx actual: %#.4hx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_int_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_int_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_int_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_int_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_int_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_int_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_int_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_int_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_int_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_int_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const int* expected, const int* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_uint_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uint_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uint_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uint_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uint_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_uint_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_uint_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_uint_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_uint_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_uint_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const uint* expected, const uint* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.8x actual: %#.8x\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_long_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const long* expected, const long* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_ulong_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const ulong* expected, const ulong* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %#.16llx actual: %#.16llx\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#endif

_CL_NOINLINE
void compare_float_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_float_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_float_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_float_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_float_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

_CL_NOINLINE
void compare_float_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_float_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_float_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

_CL_NOINLINE
void compare_float_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_float_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const float* expected, const float* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %.8g actual: %.8g\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_char(string name, size_t sample, constant char* original_scalar, const char* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (char)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_uchar(string name, size_t sample, constant uchar* original_scalar, const uchar* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.2hhx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (uchar)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_short(string name, size_t sample, constant short* original_scalar, const short* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (short)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_ushort(string name, size_t sample, constant ushort* original_scalar, const ushort* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.4hx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (ushort)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_int(string name, size_t sample, constant int* original_scalar, const int* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (int)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_uint(string name, size_t sample, constant uint* original_scalar, const uint* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.8x expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (uint)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_double_elements_long(string name, size_t sample, constant long* original_scalar, const long* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (long)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#endif

#ifdef cl_khr_fp64

#ifdef cl_khr_int64

_CL_NOINLINE
void compare_double_elements_ulong(string name, size_t sample, constant ulong* original_scalar, const ulong* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %#.16llx expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (ulong)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_float(string name, size_t sample, constant float* original_scalar, const float* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.8g expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (float)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

#ifdef cl_khr_fp64

_CL_NOINLINE
void compare_double_elements_double(string name, size_t sample, constant double* original_scalar, const double* original_array, const double* expected, const double* actual, size_t n)
{
  for (size_t i = 0; i < n; ++i) {
    if (expected[i] != actual[i]) {
      printf("FAIL: %s - sample#: %u element#: %u original: %.17g expected: %.17g actual: %.17g\n",
        name, (uint)sample, (uint)i, (double)(original_scalar ? *original_scalar : original_array[i]), expected[i], actual[i]);
    }
  }
}

#endif

kernel void test_convert_type_4()
{
  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(CHAR_MIN > CHAR_MIN) ? (char)CHAR_MIN : CHAR_MIN;
    const char max_expected = (char)(CHAR_MAX < CHAR_MAX) ? (char)CHAR_MAX : CHAR_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)char_values[i]));
    actual.value = convert_char4((char4)char_values[i]);
    compare_char_elements_char("convert_char4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((char4)char_values[i]);
    compare_char_elements_char("convert_char4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(0 > CHAR_MIN) ? (char)0 : CHAR_MIN;
    const char max_expected = (char)(UCHAR_MAX < CHAR_MAX) ? (char)UCHAR_MAX : CHAR_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)char_values[i]));
    actual.value = convert_uchar4((char4)char_values[i]);
    compare_uchar_elements_char("convert_uchar4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((char4)char_values[i]);
    compare_uchar_elements_char("convert_uchar4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(SHRT_MIN > CHAR_MIN) ? (char)SHRT_MIN : CHAR_MIN;
    const char max_expected = (char)(SHRT_MAX < CHAR_MAX) ? (char)SHRT_MAX : CHAR_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)char_values[i]));
    actual.value = convert_short4((char4)char_values[i]);
    compare_short_elements_char("convert_short4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((char4)char_values[i]);
    compare_short_elements_char("convert_short4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(0 > CHAR_MIN) ? (char)0 : CHAR_MIN;
    const char max_expected = (char)(USHRT_MAX < CHAR_MAX) ? (char)USHRT_MAX : CHAR_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)char_values[i]));
    actual.value = convert_ushort4((char4)char_values[i]);
    compare_ushort_elements_char("convert_ushort4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((char4)char_values[i]);
    compare_ushort_elements_char("convert_ushort4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(INT_MIN > CHAR_MIN) ? (char)INT_MIN : CHAR_MIN;
    const char max_expected = (char)(INT_MAX < CHAR_MAX) ? (char)INT_MAX : CHAR_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)char_values[i]));
    actual.value = convert_int4((char4)char_values[i]);
    compare_int_elements_char("convert_int4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((char4)char_values[i]);
    compare_int_elements_char("convert_int4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(0 > CHAR_MIN) ? (char)0 : CHAR_MIN;
    const char max_expected = (char)(UINT_MAX < CHAR_MAX) ? (char)UINT_MAX : CHAR_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)char_values[i]));
    actual.value = convert_uint4((char4)char_values[i]);
    compare_uint_elements_char("convert_uint4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((char4)char_values[i]);
    compare_uint_elements_char("convert_uint4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(LONG_MIN > CHAR_MIN) ? (char)LONG_MIN : CHAR_MIN;
    const char max_expected = (char)(LONG_MAX < CHAR_MAX) ? (char)LONG_MAX : CHAR_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)char_values[i]));
    actual.value = convert_long4((char4)char_values[i]);
    compare_long_elements_char("convert_long4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((char4)char_values[i]);
    compare_long_elements_char("convert_long4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < char_values_length; ++i) {
    const char min_expected = (char)(0 > CHAR_MIN) ? (char)0 : CHAR_MIN;
    const char max_expected = (char)(ULONG_MAX < CHAR_MAX) ? (char)ULONG_MAX : CHAR_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)char_values[i]));
    actual.value = convert_ulong4((char4)char_values[i]);
    compare_ulong_elements_char("convert_ulong4(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
    if (char_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (char_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((char4)char_values[i]);
    compare_ulong_elements_char("convert_ulong4_sat(char4)", i, &char_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(CHAR_MIN > 0) ? (uchar)CHAR_MIN : 0;
    const uchar max_expected = (uchar)(CHAR_MAX < UCHAR_MAX) ? (uchar)CHAR_MAX : UCHAR_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)uchar_values[i]));
    actual.value = convert_char4((uchar4)uchar_values[i]);
    compare_char_elements_uchar("convert_char4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((uchar4)uchar_values[i]);
    compare_char_elements_uchar("convert_char4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(0 > 0) ? (uchar)0 : 0;
    const uchar max_expected = (uchar)(UCHAR_MAX < UCHAR_MAX) ? (uchar)UCHAR_MAX : UCHAR_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)uchar_values[i]));
    actual.value = convert_uchar4((uchar4)uchar_values[i]);
    compare_uchar_elements_uchar("convert_uchar4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((uchar4)uchar_values[i]);
    compare_uchar_elements_uchar("convert_uchar4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(SHRT_MIN > 0) ? (uchar)SHRT_MIN : 0;
    const uchar max_expected = (uchar)(SHRT_MAX < UCHAR_MAX) ? (uchar)SHRT_MAX : UCHAR_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)uchar_values[i]));
    actual.value = convert_short4((uchar4)uchar_values[i]);
    compare_short_elements_uchar("convert_short4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((uchar4)uchar_values[i]);
    compare_short_elements_uchar("convert_short4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(0 > 0) ? (uchar)0 : 0;
    const uchar max_expected = (uchar)(USHRT_MAX < UCHAR_MAX) ? (uchar)USHRT_MAX : UCHAR_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)uchar_values[i]));
    actual.value = convert_ushort4((uchar4)uchar_values[i]);
    compare_ushort_elements_uchar("convert_ushort4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((uchar4)uchar_values[i]);
    compare_ushort_elements_uchar("convert_ushort4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(INT_MIN > 0) ? (uchar)INT_MIN : 0;
    const uchar max_expected = (uchar)(INT_MAX < UCHAR_MAX) ? (uchar)INT_MAX : UCHAR_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)uchar_values[i]));
    actual.value = convert_int4((uchar4)uchar_values[i]);
    compare_int_elements_uchar("convert_int4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((uchar4)uchar_values[i]);
    compare_int_elements_uchar("convert_int4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(0 > 0) ? (uchar)0 : 0;
    const uchar max_expected = (uchar)(UINT_MAX < UCHAR_MAX) ? (uchar)UINT_MAX : UCHAR_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)uchar_values[i]));
    actual.value = convert_uint4((uchar4)uchar_values[i]);
    compare_uint_elements_uchar("convert_uint4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((uchar4)uchar_values[i]);
    compare_uint_elements_uchar("convert_uint4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(LONG_MIN > 0) ? (uchar)LONG_MIN : 0;
    const uchar max_expected = (uchar)(LONG_MAX < UCHAR_MAX) ? (uchar)LONG_MAX : UCHAR_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)uchar_values[i]));
    actual.value = convert_long4((uchar4)uchar_values[i]);
    compare_long_elements_uchar("convert_long4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((uchar4)uchar_values[i]);
    compare_long_elements_uchar("convert_long4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < uchar_values_length; ++i) {
    const uchar min_expected = (uchar)(0 > 0) ? (uchar)0 : 0;
    const uchar max_expected = (uchar)(ULONG_MAX < UCHAR_MAX) ? (uchar)ULONG_MAX : UCHAR_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)uchar_values[i]));
    actual.value = convert_ulong4((uchar4)uchar_values[i]);
    compare_ulong_elements_uchar("convert_ulong4(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
    if (uchar_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (uchar_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((uchar4)uchar_values[i]);
    compare_ulong_elements_uchar("convert_ulong4_sat(uchar4)", i, &uchar_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(CHAR_MIN > SHRT_MIN) ? (short)CHAR_MIN : SHRT_MIN;
    const short max_expected = (short)(CHAR_MAX < SHRT_MAX) ? (short)CHAR_MAX : SHRT_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)short_values[i]));
    actual.value = convert_char4((short4)short_values[i]);
    compare_char_elements_short("convert_char4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((short4)short_values[i]);
    compare_char_elements_short("convert_char4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(0 > SHRT_MIN) ? (short)0 : SHRT_MIN;
    const short max_expected = (short)(UCHAR_MAX < SHRT_MAX) ? (short)UCHAR_MAX : SHRT_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)short_values[i]));
    actual.value = convert_uchar4((short4)short_values[i]);
    compare_uchar_elements_short("convert_uchar4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((short4)short_values[i]);
    compare_uchar_elements_short("convert_uchar4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(SHRT_MIN > SHRT_MIN) ? (short)SHRT_MIN : SHRT_MIN;
    const short max_expected = (short)(SHRT_MAX < SHRT_MAX) ? (short)SHRT_MAX : SHRT_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)short_values[i]));
    actual.value = convert_short4((short4)short_values[i]);
    compare_short_elements_short("convert_short4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((short4)short_values[i]);
    compare_short_elements_short("convert_short4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(0 > SHRT_MIN) ? (short)0 : SHRT_MIN;
    const short max_expected = (short)(USHRT_MAX < SHRT_MAX) ? (short)USHRT_MAX : SHRT_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)short_values[i]));
    actual.value = convert_ushort4((short4)short_values[i]);
    compare_ushort_elements_short("convert_ushort4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((short4)short_values[i]);
    compare_ushort_elements_short("convert_ushort4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(INT_MIN > SHRT_MIN) ? (short)INT_MIN : SHRT_MIN;
    const short max_expected = (short)(INT_MAX < SHRT_MAX) ? (short)INT_MAX : SHRT_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)short_values[i]));
    actual.value = convert_int4((short4)short_values[i]);
    compare_int_elements_short("convert_int4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((short4)short_values[i]);
    compare_int_elements_short("convert_int4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(0 > SHRT_MIN) ? (short)0 : SHRT_MIN;
    const short max_expected = (short)(UINT_MAX < SHRT_MAX) ? (short)UINT_MAX : SHRT_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)short_values[i]));
    actual.value = convert_uint4((short4)short_values[i]);
    compare_uint_elements_short("convert_uint4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((short4)short_values[i]);
    compare_uint_elements_short("convert_uint4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(LONG_MIN > SHRT_MIN) ? (short)LONG_MIN : SHRT_MIN;
    const short max_expected = (short)(LONG_MAX < SHRT_MAX) ? (short)LONG_MAX : SHRT_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)short_values[i]));
    actual.value = convert_long4((short4)short_values[i]);
    compare_long_elements_short("convert_long4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((short4)short_values[i]);
    compare_long_elements_short("convert_long4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < short_values_length; ++i) {
    const short min_expected = (short)(0 > SHRT_MIN) ? (short)0 : SHRT_MIN;
    const short max_expected = (short)(ULONG_MAX < SHRT_MAX) ? (short)ULONG_MAX : SHRT_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)short_values[i]));
    actual.value = convert_ulong4((short4)short_values[i]);
    compare_ulong_elements_short("convert_ulong4(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
    if (short_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (short_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((short4)short_values[i]);
    compare_ulong_elements_short("convert_ulong4_sat(short4)", i, &short_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(CHAR_MIN > 0) ? (ushort)CHAR_MIN : 0;
    const ushort max_expected = (ushort)(CHAR_MAX < USHRT_MAX) ? (ushort)CHAR_MAX : USHRT_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)ushort_values[i]));
    actual.value = convert_char4((ushort4)ushort_values[i]);
    compare_char_elements_ushort("convert_char4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((ushort4)ushort_values[i]);
    compare_char_elements_ushort("convert_char4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(0 > 0) ? (ushort)0 : 0;
    const ushort max_expected = (ushort)(UCHAR_MAX < USHRT_MAX) ? (ushort)UCHAR_MAX : USHRT_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)ushort_values[i]));
    actual.value = convert_uchar4((ushort4)ushort_values[i]);
    compare_uchar_elements_ushort("convert_uchar4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((ushort4)ushort_values[i]);
    compare_uchar_elements_ushort("convert_uchar4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(SHRT_MIN > 0) ? (ushort)SHRT_MIN : 0;
    const ushort max_expected = (ushort)(SHRT_MAX < USHRT_MAX) ? (ushort)SHRT_MAX : USHRT_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)ushort_values[i]));
    actual.value = convert_short4((ushort4)ushort_values[i]);
    compare_short_elements_ushort("convert_short4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((ushort4)ushort_values[i]);
    compare_short_elements_ushort("convert_short4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(0 > 0) ? (ushort)0 : 0;
    const ushort max_expected = (ushort)(USHRT_MAX < USHRT_MAX) ? (ushort)USHRT_MAX : USHRT_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)ushort_values[i]));
    actual.value = convert_ushort4((ushort4)ushort_values[i]);
    compare_ushort_elements_ushort("convert_ushort4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((ushort4)ushort_values[i]);
    compare_ushort_elements_ushort("convert_ushort4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(INT_MIN > 0) ? (ushort)INT_MIN : 0;
    const ushort max_expected = (ushort)(INT_MAX < USHRT_MAX) ? (ushort)INT_MAX : USHRT_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)ushort_values[i]));
    actual.value = convert_int4((ushort4)ushort_values[i]);
    compare_int_elements_ushort("convert_int4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((ushort4)ushort_values[i]);
    compare_int_elements_ushort("convert_int4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(0 > 0) ? (ushort)0 : 0;
    const ushort max_expected = (ushort)(UINT_MAX < USHRT_MAX) ? (ushort)UINT_MAX : USHRT_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)ushort_values[i]));
    actual.value = convert_uint4((ushort4)ushort_values[i]);
    compare_uint_elements_ushort("convert_uint4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((ushort4)ushort_values[i]);
    compare_uint_elements_ushort("convert_uint4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(LONG_MIN > 0) ? (ushort)LONG_MIN : 0;
    const ushort max_expected = (ushort)(LONG_MAX < USHRT_MAX) ? (ushort)LONG_MAX : USHRT_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)ushort_values[i]));
    actual.value = convert_long4((ushort4)ushort_values[i]);
    compare_long_elements_ushort("convert_long4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((ushort4)ushort_values[i]);
    compare_long_elements_ushort("convert_long4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ushort_values_length; ++i) {
    const ushort min_expected = (ushort)(0 > 0) ? (ushort)0 : 0;
    const ushort max_expected = (ushort)(ULONG_MAX < USHRT_MAX) ? (ushort)ULONG_MAX : USHRT_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)ushort_values[i]));
    actual.value = convert_ulong4((ushort4)ushort_values[i]);
    compare_ulong_elements_ushort("convert_ulong4(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
    if (ushort_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (ushort_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((ushort4)ushort_values[i]);
    compare_ulong_elements_ushort("convert_ulong4_sat(ushort4)", i, &ushort_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(CHAR_MIN > INT_MIN) ? (int)CHAR_MIN : INT_MIN;
    const int max_expected = (int)(CHAR_MAX < INT_MAX) ? (int)CHAR_MAX : INT_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)int_values[i]));
    actual.value = convert_char4((int4)int_values[i]);
    compare_char_elements_int("convert_char4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((int4)int_values[i]);
    compare_char_elements_int("convert_char4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(0 > INT_MIN) ? (int)0 : INT_MIN;
    const int max_expected = (int)(UCHAR_MAX < INT_MAX) ? (int)UCHAR_MAX : INT_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)int_values[i]));
    actual.value = convert_uchar4((int4)int_values[i]);
    compare_uchar_elements_int("convert_uchar4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((int4)int_values[i]);
    compare_uchar_elements_int("convert_uchar4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(SHRT_MIN > INT_MIN) ? (int)SHRT_MIN : INT_MIN;
    const int max_expected = (int)(SHRT_MAX < INT_MAX) ? (int)SHRT_MAX : INT_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)int_values[i]));
    actual.value = convert_short4((int4)int_values[i]);
    compare_short_elements_int("convert_short4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((int4)int_values[i]);
    compare_short_elements_int("convert_short4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(0 > INT_MIN) ? (int)0 : INT_MIN;
    const int max_expected = (int)(USHRT_MAX < INT_MAX) ? (int)USHRT_MAX : INT_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)int_values[i]));
    actual.value = convert_ushort4((int4)int_values[i]);
    compare_ushort_elements_int("convert_ushort4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((int4)int_values[i]);
    compare_ushort_elements_int("convert_ushort4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(INT_MIN > INT_MIN) ? (int)INT_MIN : INT_MIN;
    const int max_expected = (int)(INT_MAX < INT_MAX) ? (int)INT_MAX : INT_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)int_values[i]));
    actual.value = convert_int4((int4)int_values[i]);
    compare_int_elements_int("convert_int4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((int4)int_values[i]);
    compare_int_elements_int("convert_int4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(0 > INT_MIN) ? (int)0 : INT_MIN;
    const int max_expected = (int)(UINT_MAX < INT_MAX) ? (int)UINT_MAX : INT_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)int_values[i]));
    actual.value = convert_uint4((int4)int_values[i]);
    compare_uint_elements_int("convert_uint4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((int4)int_values[i]);
    compare_uint_elements_int("convert_uint4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(LONG_MIN > INT_MIN) ? (int)LONG_MIN : INT_MIN;
    const int max_expected = (int)(LONG_MAX < INT_MAX) ? (int)LONG_MAX : INT_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)int_values[i]));
    actual.value = convert_long4((int4)int_values[i]);
    compare_long_elements_int("convert_long4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((int4)int_values[i]);
    compare_long_elements_int("convert_long4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < int_values_length; ++i) {
    const int min_expected = (int)(0 > INT_MIN) ? (int)0 : INT_MIN;
    const int max_expected = (int)(ULONG_MAX < INT_MAX) ? (int)ULONG_MAX : INT_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)int_values[i]));
    actual.value = convert_ulong4((int4)int_values[i]);
    compare_ulong_elements_int("convert_ulong4(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
    if (int_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (int_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((int4)int_values[i]);
    compare_ulong_elements_int("convert_ulong4_sat(int4)", i, &int_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(CHAR_MIN > 0) ? (uint)CHAR_MIN : 0;
    const uint max_expected = (uint)(CHAR_MAX < UINT_MAX) ? (uint)CHAR_MAX : UINT_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)uint_values[i]));
    actual.value = convert_char4((uint4)uint_values[i]);
    compare_char_elements_uint("convert_char4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((uint4)uint_values[i]);
    compare_char_elements_uint("convert_char4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(0 > 0) ? (uint)0 : 0;
    const uint max_expected = (uint)(UCHAR_MAX < UINT_MAX) ? (uint)UCHAR_MAX : UINT_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)uint_values[i]));
    actual.value = convert_uchar4((uint4)uint_values[i]);
    compare_uchar_elements_uint("convert_uchar4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((uint4)uint_values[i]);
    compare_uchar_elements_uint("convert_uchar4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(SHRT_MIN > 0) ? (uint)SHRT_MIN : 0;
    const uint max_expected = (uint)(SHRT_MAX < UINT_MAX) ? (uint)SHRT_MAX : UINT_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)uint_values[i]));
    actual.value = convert_short4((uint4)uint_values[i]);
    compare_short_elements_uint("convert_short4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((uint4)uint_values[i]);
    compare_short_elements_uint("convert_short4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(0 > 0) ? (uint)0 : 0;
    const uint max_expected = (uint)(USHRT_MAX < UINT_MAX) ? (uint)USHRT_MAX : UINT_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)uint_values[i]));
    actual.value = convert_ushort4((uint4)uint_values[i]);
    compare_ushort_elements_uint("convert_ushort4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((uint4)uint_values[i]);
    compare_ushort_elements_uint("convert_ushort4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(INT_MIN > 0) ? (uint)INT_MIN : 0;
    const uint max_expected = (uint)(INT_MAX < UINT_MAX) ? (uint)INT_MAX : UINT_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)uint_values[i]));
    actual.value = convert_int4((uint4)uint_values[i]);
    compare_int_elements_uint("convert_int4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((uint4)uint_values[i]);
    compare_int_elements_uint("convert_int4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(0 > 0) ? (uint)0 : 0;
    const uint max_expected = (uint)(UINT_MAX < UINT_MAX) ? (uint)UINT_MAX : UINT_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)uint_values[i]));
    actual.value = convert_uint4((uint4)uint_values[i]);
    compare_uint_elements_uint("convert_uint4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((uint4)uint_values[i]);
    compare_uint_elements_uint("convert_uint4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(LONG_MIN > 0) ? (uint)LONG_MIN : 0;
    const uint max_expected = (uint)(LONG_MAX < UINT_MAX) ? (uint)LONG_MAX : UINT_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)uint_values[i]));
    actual.value = convert_long4((uint4)uint_values[i]);
    compare_long_elements_uint("convert_long4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((uint4)uint_values[i]);
    compare_long_elements_uint("convert_long4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < uint_values_length; ++i) {
    const uint min_expected = (uint)(0 > 0) ? (uint)0 : 0;
    const uint max_expected = (uint)(ULONG_MAX < UINT_MAX) ? (uint)ULONG_MAX : UINT_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)uint_values[i]));
    actual.value = convert_ulong4((uint4)uint_values[i]);
    compare_ulong_elements_uint("convert_ulong4(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
    if (uint_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (uint_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((uint4)uint_values[i]);
    compare_ulong_elements_uint("convert_ulong4_sat(uint4)", i, &uint_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(CHAR_MIN > LONG_MIN) ? (long)CHAR_MIN : LONG_MIN;
    const long max_expected = (long)(CHAR_MAX < LONG_MAX) ? (long)CHAR_MAX : LONG_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)long_values[i]));
    actual.value = convert_char4((long4)long_values[i]);
    compare_char_elements_long("convert_char4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((long4)long_values[i]);
    compare_char_elements_long("convert_char4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(0 > LONG_MIN) ? (long)0 : LONG_MIN;
    const long max_expected = (long)(UCHAR_MAX < LONG_MAX) ? (long)UCHAR_MAX : LONG_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)long_values[i]));
    actual.value = convert_uchar4((long4)long_values[i]);
    compare_uchar_elements_long("convert_uchar4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((long4)long_values[i]);
    compare_uchar_elements_long("convert_uchar4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(SHRT_MIN > LONG_MIN) ? (long)SHRT_MIN : LONG_MIN;
    const long max_expected = (long)(SHRT_MAX < LONG_MAX) ? (long)SHRT_MAX : LONG_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)long_values[i]));
    actual.value = convert_short4((long4)long_values[i]);
    compare_short_elements_long("convert_short4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((long4)long_values[i]);
    compare_short_elements_long("convert_short4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(0 > LONG_MIN) ? (long)0 : LONG_MIN;
    const long max_expected = (long)(USHRT_MAX < LONG_MAX) ? (long)USHRT_MAX : LONG_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)long_values[i]));
    actual.value = convert_ushort4((long4)long_values[i]);
    compare_ushort_elements_long("convert_ushort4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((long4)long_values[i]);
    compare_ushort_elements_long("convert_ushort4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(INT_MIN > LONG_MIN) ? (long)INT_MIN : LONG_MIN;
    const long max_expected = (long)(INT_MAX < LONG_MAX) ? (long)INT_MAX : LONG_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)long_values[i]));
    actual.value = convert_int4((long4)long_values[i]);
    compare_int_elements_long("convert_int4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((long4)long_values[i]);
    compare_int_elements_long("convert_int4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(0 > LONG_MIN) ? (long)0 : LONG_MIN;
    const long max_expected = (long)(UINT_MAX < LONG_MAX) ? (long)UINT_MAX : LONG_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)long_values[i]));
    actual.value = convert_uint4((long4)long_values[i]);
    compare_uint_elements_long("convert_uint4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((long4)long_values[i]);
    compare_uint_elements_long("convert_uint4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(LONG_MIN > LONG_MIN) ? (long)LONG_MIN : LONG_MIN;
    const long max_expected = (long)(LONG_MAX < LONG_MAX) ? (long)LONG_MAX : LONG_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)long_values[i]));
    actual.value = convert_long4((long4)long_values[i]);
    compare_long_elements_long("convert_long4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((long4)long_values[i]);
    compare_long_elements_long("convert_long4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < long_values_length; ++i) {
    const long min_expected = (long)(0 > LONG_MIN) ? (long)0 : LONG_MIN;
    const long max_expected = (long)(ULONG_MAX < LONG_MAX) ? (long)ULONG_MAX : LONG_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)long_values[i]));
    actual.value = convert_ulong4((long4)long_values[i]);
    compare_ulong_elements_long("convert_ulong4(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
    if (long_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (long_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((long4)long_values[i]);
    compare_ulong_elements_long("convert_ulong4_sat(long4)", i, &long_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(CHAR_MIN > 0) ? (ulong)CHAR_MIN : 0;
    const ulong max_expected = (ulong)(CHAR_MAX < ULONG_MAX) ? (ulong)CHAR_MAX : ULONG_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)ulong_values[i]));
    actual.value = convert_char4((ulong4)ulong_values[i]);
    compare_char_elements_ulong("convert_char4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((ulong4)ulong_values[i]);
    compare_char_elements_ulong("convert_char4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(0 > 0) ? (ulong)0 : 0;
    const ulong max_expected = (ulong)(UCHAR_MAX < ULONG_MAX) ? (ulong)UCHAR_MAX : ULONG_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)ulong_values[i]));
    actual.value = convert_uchar4((ulong4)ulong_values[i]);
    compare_uchar_elements_ulong("convert_uchar4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((ulong4)ulong_values[i]);
    compare_uchar_elements_ulong("convert_uchar4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(SHRT_MIN > 0) ? (ulong)SHRT_MIN : 0;
    const ulong max_expected = (ulong)(SHRT_MAX < ULONG_MAX) ? (ulong)SHRT_MAX : ULONG_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)ulong_values[i]));
    actual.value = convert_short4((ulong4)ulong_values[i]);
    compare_short_elements_ulong("convert_short4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((ulong4)ulong_values[i]);
    compare_short_elements_ulong("convert_short4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(0 > 0) ? (ulong)0 : 0;
    const ulong max_expected = (ulong)(USHRT_MAX < ULONG_MAX) ? (ulong)USHRT_MAX : ULONG_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)ulong_values[i]));
    actual.value = convert_ushort4((ulong4)ulong_values[i]);
    compare_ushort_elements_ulong("convert_ushort4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((ulong4)ulong_values[i]);
    compare_ushort_elements_ulong("convert_ushort4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(INT_MIN > 0) ? (ulong)INT_MIN : 0;
    const ulong max_expected = (ulong)(INT_MAX < ULONG_MAX) ? (ulong)INT_MAX : ULONG_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)ulong_values[i]));
    actual.value = convert_int4((ulong4)ulong_values[i]);
    compare_int_elements_ulong("convert_int4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((ulong4)ulong_values[i]);
    compare_int_elements_ulong("convert_int4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(0 > 0) ? (ulong)0 : 0;
    const ulong max_expected = (ulong)(UINT_MAX < ULONG_MAX) ? (ulong)UINT_MAX : ULONG_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)ulong_values[i]));
    actual.value = convert_uint4((ulong4)ulong_values[i]);
    compare_uint_elements_ulong("convert_uint4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((ulong4)ulong_values[i]);
    compare_uint_elements_ulong("convert_uint4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(LONG_MIN > 0) ? (ulong)LONG_MIN : 0;
    const ulong max_expected = (ulong)(LONG_MAX < ULONG_MAX) ? (ulong)LONG_MAX : ULONG_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)ulong_values[i]));
    actual.value = convert_long4((ulong4)ulong_values[i]);
    compare_long_elements_ulong("convert_long4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((ulong4)ulong_values[i]);
    compare_long_elements_ulong("convert_long4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < ulong_values_length; ++i) {
    const ulong min_expected = (ulong)(0 > 0) ? (ulong)0 : 0;
    const ulong max_expected = (ulong)(ULONG_MAX < ULONG_MAX) ? (ulong)ULONG_MAX : ULONG_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)ulong_values[i]));
    actual.value = convert_ulong4((ulong4)ulong_values[i]);
    compare_ulong_elements_ulong("convert_ulong4(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
    if (ulong_values[i] < min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (ulong_values[i] > max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((ulong4)ulong_values[i]);
    compare_ulong_elements_ulong("convert_ulong4_sat(ulong4)", i, &ulong_values[i], 0, expected.raw, actual.raw, 4);
  }

#endif

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const char min_expected = (char)(CHAR_MIN > -FLT_MAX) ? CHAR_MIN : (char)-FLT_MAX;
    const char max_expected = (char)(CHAR_MAX < FLT_MAX) ? CHAR_MAX : (char)FLT_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)float_rounded_values[i]));
    actual.value = convert_char4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_float("convert_char4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((float4)sat_input);
    compare_char_elements_float("convert_char4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)float_rounded_values_rte[i]));
    actual.value = convert_char4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_float("convert_char4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rte((float4)sat_input);
    compare_char_elements_float("convert_char4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)float_rounded_values_rtz[i]));
    actual.value = convert_char4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_float("convert_char4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtz((float4)sat_input);
    compare_char_elements_float("convert_char4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)float_rounded_values_rtp[i]));
    actual.value = convert_char4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_float("convert_char4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtp((float4)sat_input);
    compare_char_elements_float("convert_char4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)float_rounded_values_rtn[i]));
    actual.value = convert_char4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_float("convert_char4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtn((float4)sat_input);
    compare_char_elements_float("convert_char4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const uchar min_expected = (uchar)(0 > -FLT_MAX) ? 0 : (uchar)-FLT_MAX;
    const uchar max_expected = (uchar)(UCHAR_MAX < FLT_MAX) ? UCHAR_MAX : (uchar)FLT_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)float_rounded_values[i]));
    actual.value = convert_uchar4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_float("convert_uchar4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((float4)sat_input);
    compare_uchar_elements_float("convert_uchar4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)float_rounded_values_rte[i]));
    actual.value = convert_uchar4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_float("convert_uchar4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rte((float4)sat_input);
    compare_uchar_elements_float("convert_uchar4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)float_rounded_values_rtz[i]));
    actual.value = convert_uchar4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_float("convert_uchar4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtz((float4)sat_input);
    compare_uchar_elements_float("convert_uchar4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)float_rounded_values_rtp[i]));
    actual.value = convert_uchar4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_float("convert_uchar4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtp((float4)sat_input);
    compare_uchar_elements_float("convert_uchar4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)float_rounded_values_rtn[i]));
    actual.value = convert_uchar4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_float("convert_uchar4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtn((float4)sat_input);
    compare_uchar_elements_float("convert_uchar4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const short min_expected = (short)(SHRT_MIN > -FLT_MAX) ? SHRT_MIN : (short)-FLT_MAX;
    const short max_expected = (short)(SHRT_MAX < FLT_MAX) ? SHRT_MAX : (short)FLT_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)float_rounded_values[i]));
    actual.value = convert_short4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_float("convert_short4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((float4)sat_input);
    compare_short_elements_float("convert_short4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)float_rounded_values_rte[i]));
    actual.value = convert_short4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_float("convert_short4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rte((float4)sat_input);
    compare_short_elements_float("convert_short4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)float_rounded_values_rtz[i]));
    actual.value = convert_short4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_float("convert_short4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtz((float4)sat_input);
    compare_short_elements_float("convert_short4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)float_rounded_values_rtp[i]));
    actual.value = convert_short4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_float("convert_short4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtp((float4)sat_input);
    compare_short_elements_float("convert_short4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)float_rounded_values_rtn[i]));
    actual.value = convert_short4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_float("convert_short4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtn((float4)sat_input);
    compare_short_elements_float("convert_short4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const ushort min_expected = (ushort)(0 > -FLT_MAX) ? 0 : (ushort)-FLT_MAX;
    const ushort max_expected = (ushort)(USHRT_MAX < FLT_MAX) ? USHRT_MAX : (ushort)FLT_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)float_rounded_values[i]));
    actual.value = convert_ushort4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_float("convert_ushort4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((float4)sat_input);
    compare_ushort_elements_float("convert_ushort4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)float_rounded_values_rte[i]));
    actual.value = convert_ushort4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_float("convert_ushort4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rte((float4)sat_input);
    compare_ushort_elements_float("convert_ushort4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)float_rounded_values_rtz[i]));
    actual.value = convert_ushort4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_float("convert_ushort4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtz((float4)sat_input);
    compare_ushort_elements_float("convert_ushort4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)float_rounded_values_rtp[i]));
    actual.value = convert_ushort4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_float("convert_ushort4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtp((float4)sat_input);
    compare_ushort_elements_float("convert_ushort4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)float_rounded_values_rtn[i]));
    actual.value = convert_ushort4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_float("convert_ushort4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtn((float4)sat_input);
    compare_ushort_elements_float("convert_ushort4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const int min_expected = (int)(INT_MIN > -FLT_MAX) ? INT_MIN : (int)-FLT_MAX;
    const int max_expected = (int)(INT_MAX < FLT_MAX) ? INT_MAX : (int)FLT_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)float_rounded_values[i]));
    actual.value = convert_int4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_float("convert_int4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((float4)sat_input);
    compare_int_elements_float("convert_int4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)float_rounded_values_rte[i]));
    actual.value = convert_int4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_float("convert_int4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rte((float4)sat_input);
    compare_int_elements_float("convert_int4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)float_rounded_values_rtz[i]));
    actual.value = convert_int4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_float("convert_int4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtz((float4)sat_input);
    compare_int_elements_float("convert_int4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)float_rounded_values_rtp[i]));
    actual.value = convert_int4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_float("convert_int4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtp((float4)sat_input);
    compare_int_elements_float("convert_int4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)float_rounded_values_rtn[i]));
    actual.value = convert_int4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_float("convert_int4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtn((float4)sat_input);
    compare_int_elements_float("convert_int4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const uint min_expected = (uint)(0 > -FLT_MAX) ? 0 : (uint)-FLT_MAX;
    const uint max_expected = (uint)(UINT_MAX < FLT_MAX) ? UINT_MAX : (uint)FLT_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)float_rounded_values[i]));
    actual.value = convert_uint4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_float("convert_uint4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((float4)sat_input);
    compare_uint_elements_float("convert_uint4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)float_rounded_values_rte[i]));
    actual.value = convert_uint4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_float("convert_uint4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rte((float4)sat_input);
    compare_uint_elements_float("convert_uint4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)float_rounded_values_rtz[i]));
    actual.value = convert_uint4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_float("convert_uint4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtz((float4)sat_input);
    compare_uint_elements_float("convert_uint4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)float_rounded_values_rtp[i]));
    actual.value = convert_uint4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_float("convert_uint4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtp((float4)sat_input);
    compare_uint_elements_float("convert_uint4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)float_rounded_values_rtn[i]));
    actual.value = convert_uint4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_float("convert_uint4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtn((float4)sat_input);
    compare_uint_elements_float("convert_uint4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#ifdef cl_khr_int64

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const long min_expected = (long)(LONG_MIN > -FLT_MAX) ? LONG_MIN : (long)-FLT_MAX;
    const long max_expected = (long)(LONG_MAX < FLT_MAX) ? LONG_MAX : (long)FLT_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)float_rounded_values[i]));
    actual.value = convert_long4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_float("convert_long4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((float4)sat_input);
    compare_long_elements_float("convert_long4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)float_rounded_values_rte[i]));
    actual.value = convert_long4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_float("convert_long4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rte((float4)sat_input);
    compare_long_elements_float("convert_long4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)float_rounded_values_rtz[i]));
    actual.value = convert_long4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_float("convert_long4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtz((float4)sat_input);
    compare_long_elements_float("convert_long4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)float_rounded_values_rtp[i]));
    actual.value = convert_long4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_float("convert_long4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtp((float4)sat_input);
    compare_long_elements_float("convert_long4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)float_rounded_values_rtn[i]));
    actual.value = convert_long4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_float("convert_long4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtn((float4)sat_input);
    compare_long_elements_float("convert_long4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

  for (size_t i = 0; i < float_values_length; ++i) {
    const float sat_input = (float_values[i] + float_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const ulong min_expected = (ulong)(0 > -FLT_MAX) ? 0 : (ulong)-FLT_MAX;
    const ulong max_expected = (ulong)(ULONG_MAX < FLT_MAX) ? ULONG_MAX : (ulong)FLT_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)float_rounded_values[i]));
    actual.value = convert_ulong4((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = float_rounded_values[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_float("convert_ulong4(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((float4)sat_input);
    compare_ulong_elements_float("convert_ulong4_sat(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)float_rounded_values_rte[i]));
    actual.value = convert_ulong4_rte((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = float_rounded_values_rte[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_float("convert_ulong4_rte(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rte(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rte((float4)sat_input);
    compare_ulong_elements_float("convert_ulong4_sat_rte(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)float_rounded_values_rtz[i]));
    actual.value = convert_ulong4_rtz((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = float_rounded_values_rtz[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_float("convert_ulong4_rtz(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtz(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtz((float4)sat_input);
    compare_ulong_elements_float("convert_ulong4_sat_rtz(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)float_rounded_values_rtp[i]));
    actual.value = convert_ulong4_rtp((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = float_rounded_values_rtp[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_float("convert_ulong4_rtp(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtp(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtp((float4)sat_input);
    compare_ulong_elements_float("convert_ulong4_sat_rtp(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)float_rounded_values_rtn[i]));
    actual.value = convert_ulong4_rtn((float4)float_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = float_rounded_values_rtn[i] < (float)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_float("convert_ulong4_rtn(float4)", i, &float_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtn(sat_input);
    if (sat_input <= (float)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (float)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtn((float4)sat_input);
    compare_ulong_elements_float("convert_ulong4_sat_rtn(float4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const char min_expected = (char)(CHAR_MIN > -DBL_MAX) ? CHAR_MIN : (char)-DBL_MAX;
    const char max_expected = (char)(CHAR_MAX < DBL_MAX) ? CHAR_MAX : (char)DBL_MAX;
    union { char4 value; char raw[4]; } expected, actual;
    expected.value = ((char4)((char)double_rounded_values[i]));
    actual.value = convert_char4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_double("convert_char4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat((double4)sat_input);
    compare_char_elements_double("convert_char4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)double_rounded_values_rte[i]));
    actual.value = convert_char4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_double("convert_char4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rte((double4)sat_input);
    compare_char_elements_double("convert_char4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)double_rounded_values_rtz[i]));
    actual.value = convert_char4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_double("convert_char4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtz((double4)sat_input);
    compare_char_elements_double("convert_char4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)double_rounded_values_rtp[i]));
    actual.value = convert_char4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_double("convert_char4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtp((double4)sat_input);
    compare_char_elements_double("convert_char4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((char4)((char)double_rounded_values_rtn[i]));
    actual.value = convert_char4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (char)((char)0 - (char)1) >= (char)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (char)0;
        actual.raw[n] = (char)0;
      }
    }
    compare_char_elements_double("convert_char4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (char4)convert_char_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (char4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (char4)max_expected;
    }
    actual.value = convert_char4_sat_rtn((double4)sat_input);
    compare_char_elements_double("convert_char4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const uchar min_expected = (uchar)(0 > -DBL_MAX) ? 0 : (uchar)-DBL_MAX;
    const uchar max_expected = (uchar)(UCHAR_MAX < DBL_MAX) ? UCHAR_MAX : (uchar)DBL_MAX;
    union { uchar4 value; uchar raw[4]; } expected, actual;
    expected.value = ((uchar4)((uchar)double_rounded_values[i]));
    actual.value = convert_uchar4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_double("convert_uchar4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat((double4)sat_input);
    compare_uchar_elements_double("convert_uchar4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)double_rounded_values_rte[i]));
    actual.value = convert_uchar4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_double("convert_uchar4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rte((double4)sat_input);
    compare_uchar_elements_double("convert_uchar4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)double_rounded_values_rtz[i]));
    actual.value = convert_uchar4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_double("convert_uchar4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtz((double4)sat_input);
    compare_uchar_elements_double("convert_uchar4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)double_rounded_values_rtp[i]));
    actual.value = convert_uchar4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_double("convert_uchar4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtp((double4)sat_input);
    compare_uchar_elements_double("convert_uchar4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uchar4)((uchar)double_rounded_values_rtn[i]));
    actual.value = convert_uchar4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uchar)((uchar)0 - (uchar)1) >= (uchar)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uchar)0;
        actual.raw[n] = (uchar)0;
      }
    }
    compare_uchar_elements_double("convert_uchar4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uchar4)convert_uchar_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uchar4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uchar4)max_expected;
    }
    actual.value = convert_uchar4_sat_rtn((double4)sat_input);
    compare_uchar_elements_double("convert_uchar4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const short min_expected = (short)(SHRT_MIN > -DBL_MAX) ? SHRT_MIN : (short)-DBL_MAX;
    const short max_expected = (short)(SHRT_MAX < DBL_MAX) ? SHRT_MAX : (short)DBL_MAX;
    union { short4 value; short raw[4]; } expected, actual;
    expected.value = ((short4)((short)double_rounded_values[i]));
    actual.value = convert_short4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_double("convert_short4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat((double4)sat_input);
    compare_short_elements_double("convert_short4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)double_rounded_values_rte[i]));
    actual.value = convert_short4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_double("convert_short4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rte((double4)sat_input);
    compare_short_elements_double("convert_short4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)double_rounded_values_rtz[i]));
    actual.value = convert_short4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_double("convert_short4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtz((double4)sat_input);
    compare_short_elements_double("convert_short4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)double_rounded_values_rtp[i]));
    actual.value = convert_short4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_double("convert_short4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtp((double4)sat_input);
    compare_short_elements_double("convert_short4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((short4)((short)double_rounded_values_rtn[i]));
    actual.value = convert_short4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (short)((short)0 - (short)1) >= (short)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (short)0;
        actual.raw[n] = (short)0;
      }
    }
    compare_short_elements_double("convert_short4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (short4)convert_short_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (short4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (short4)max_expected;
    }
    actual.value = convert_short4_sat_rtn((double4)sat_input);
    compare_short_elements_double("convert_short4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const ushort min_expected = (ushort)(0 > -DBL_MAX) ? 0 : (ushort)-DBL_MAX;
    const ushort max_expected = (ushort)(USHRT_MAX < DBL_MAX) ? USHRT_MAX : (ushort)DBL_MAX;
    union { ushort4 value; ushort raw[4]; } expected, actual;
    expected.value = ((ushort4)((ushort)double_rounded_values[i]));
    actual.value = convert_ushort4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_double("convert_ushort4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat((double4)sat_input);
    compare_ushort_elements_double("convert_ushort4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)double_rounded_values_rte[i]));
    actual.value = convert_ushort4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_double("convert_ushort4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rte((double4)sat_input);
    compare_ushort_elements_double("convert_ushort4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)double_rounded_values_rtz[i]));
    actual.value = convert_ushort4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_double("convert_ushort4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtz((double4)sat_input);
    compare_ushort_elements_double("convert_ushort4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)double_rounded_values_rtp[i]));
    actual.value = convert_ushort4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_double("convert_ushort4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtp((double4)sat_input);
    compare_ushort_elements_double("convert_ushort4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ushort4)((ushort)double_rounded_values_rtn[i]));
    actual.value = convert_ushort4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ushort)((ushort)0 - (ushort)1) >= (ushort)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ushort)0;
        actual.raw[n] = (ushort)0;
      }
    }
    compare_ushort_elements_double("convert_ushort4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ushort4)convert_ushort_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ushort4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ushort4)max_expected;
    }
    actual.value = convert_ushort4_sat_rtn((double4)sat_input);
    compare_ushort_elements_double("convert_ushort4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const int min_expected = (int)(INT_MIN > -DBL_MAX) ? INT_MIN : (int)-DBL_MAX;
    const int max_expected = (int)(INT_MAX < DBL_MAX) ? INT_MAX : (int)DBL_MAX;
    union { int4 value; int raw[4]; } expected, actual;
    expected.value = ((int4)((int)double_rounded_values[i]));
    actual.value = convert_int4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_double("convert_int4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat((double4)sat_input);
    compare_int_elements_double("convert_int4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)double_rounded_values_rte[i]));
    actual.value = convert_int4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_double("convert_int4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rte((double4)sat_input);
    compare_int_elements_double("convert_int4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)double_rounded_values_rtz[i]));
    actual.value = convert_int4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_double("convert_int4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtz((double4)sat_input);
    compare_int_elements_double("convert_int4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)double_rounded_values_rtp[i]));
    actual.value = convert_int4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_double("convert_int4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtp((double4)sat_input);
    compare_int_elements_double("convert_int4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((int4)((int)double_rounded_values_rtn[i]));
    actual.value = convert_int4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (int)((int)0 - (int)1) >= (int)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (int)0;
        actual.raw[n] = (int)0;
      }
    }
    compare_int_elements_double("convert_int4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (int4)convert_int_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (int4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (int4)max_expected;
    }
    actual.value = convert_int4_sat_rtn((double4)sat_input);
    compare_int_elements_double("convert_int4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const uint min_expected = (uint)(0 > -DBL_MAX) ? 0 : (uint)-DBL_MAX;
    const uint max_expected = (uint)(UINT_MAX < DBL_MAX) ? UINT_MAX : (uint)DBL_MAX;
    union { uint4 value; uint raw[4]; } expected, actual;
    expected.value = ((uint4)((uint)double_rounded_values[i]));
    actual.value = convert_uint4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_double("convert_uint4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat((double4)sat_input);
    compare_uint_elements_double("convert_uint4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)double_rounded_values_rte[i]));
    actual.value = convert_uint4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_double("convert_uint4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rte((double4)sat_input);
    compare_uint_elements_double("convert_uint4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)double_rounded_values_rtz[i]));
    actual.value = convert_uint4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_double("convert_uint4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtz((double4)sat_input);
    compare_uint_elements_double("convert_uint4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)double_rounded_values_rtp[i]));
    actual.value = convert_uint4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_double("convert_uint4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtp((double4)sat_input);
    compare_uint_elements_double("convert_uint4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((uint4)((uint)double_rounded_values_rtn[i]));
    actual.value = convert_uint4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (uint)((uint)0 - (uint)1) >= (uint)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (uint)0;
        actual.raw[n] = (uint)0;
      }
    }
    compare_uint_elements_double("convert_uint4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (uint4)convert_uint_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (uint4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (uint4)max_expected;
    }
    actual.value = convert_uint4_sat_rtn((double4)sat_input);
    compare_uint_elements_double("convert_uint4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#ifdef cl_khr_int64

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const long min_expected = (long)(LONG_MIN > -DBL_MAX) ? LONG_MIN : (long)-DBL_MAX;
    const long max_expected = (long)(LONG_MAX < DBL_MAX) ? LONG_MAX : (long)DBL_MAX;
    union { long4 value; long raw[4]; } expected, actual;
    expected.value = ((long4)((long)double_rounded_values[i]));
    actual.value = convert_long4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_double("convert_long4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat((double4)sat_input);
    compare_long_elements_double("convert_long4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)double_rounded_values_rte[i]));
    actual.value = convert_long4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_double("convert_long4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rte((double4)sat_input);
    compare_long_elements_double("convert_long4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)double_rounded_values_rtz[i]));
    actual.value = convert_long4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_double("convert_long4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtz((double4)sat_input);
    compare_long_elements_double("convert_long4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)double_rounded_values_rtp[i]));
    actual.value = convert_long4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_double("convert_long4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtp((double4)sat_input);
    compare_long_elements_double("convert_long4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((long4)((long)double_rounded_values_rtn[i]));
    actual.value = convert_long4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (long)((long)0 - (long)1) >= (long)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (long)0;
        actual.raw[n] = (long)0;
      }
    }
    compare_long_elements_double("convert_long4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (long4)convert_long_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (long4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (long4)max_expected;
    }
    actual.value = convert_long4_sat_rtn((double4)sat_input);
    compare_long_elements_double("convert_long4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#endif

#ifdef cl_khr_int64

#ifdef cl_khr_fp64

  for (size_t i = 0; i < double_values_length; ++i) {
    const double sat_input = (double_values[i] + double_sat_offsets[i]);
    // use the destination (integer) type always to avoid rounding errors when
    // comparing floats to int
    const ulong min_expected = (ulong)(0 > -DBL_MAX) ? 0 : (ulong)-DBL_MAX;
    const ulong max_expected = (ulong)(ULONG_MAX < DBL_MAX) ? ULONG_MAX : (ulong)DBL_MAX;
    union { ulong4 value; ulong raw[4]; } expected, actual;
    expected.value = ((ulong4)((ulong)double_rounded_values[i]));
    actual.value = convert_ulong4((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = double_rounded_values[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_double("convert_ulong4(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat((double4)sat_input);
    compare_ulong_elements_double("convert_ulong4_sat(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)double_rounded_values_rte[i]));
    actual.value = convert_ulong4_rte((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = double_rounded_values_rte[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_double("convert_ulong4_rte(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rte(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rte((double4)sat_input);
    compare_ulong_elements_double("convert_ulong4_sat_rte(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)double_rounded_values_rtz[i]));
    actual.value = convert_ulong4_rtz((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = double_rounded_values_rtz[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_double("convert_ulong4_rtz(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtz(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtz((double4)sat_input);
    compare_ulong_elements_double("convert_ulong4_sat_rtz(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)double_rounded_values_rtp[i]));
    actual.value = convert_ulong4_rtp((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = double_rounded_values_rtp[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_double("convert_ulong4_rtp(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtp(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtp((double4)sat_input);
    compare_ulong_elements_double("convert_ulong4_sat_rtp(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
    expected.value = ((ulong4)((ulong)double_rounded_values_rtn[i]));
    actual.value = convert_ulong4_rtn((double4)double_values[i]);
    for (size_t n=0; n<4; ++n) {
      bool type_is_unsigned = (ulong)((ulong)0 - (ulong)1) >= (ulong)0;
      bool result_is_negative = double_rounded_values_rtn[i] < (double)0;
      if (type_is_unsigned && result_is_negative) {
        // Ignore this result
        expected.raw[n] = (ulong)0;
        actual.raw[n] = (ulong)0;
      }
    }
    compare_ulong_elements_double("convert_ulong4_rtn(double4)", i, &double_values[i], 0, expected.raw, actual.raw, 4);
    expected.value = (ulong4)convert_ulong_rtn(sat_input);
    if (sat_input <= (double)min_expected) {
       expected.value = (ulong4)min_expected;
    }
    else if (sat_input >= (double)max_expected) {
       expected.value = (ulong4)max_expected;
    }
    actual.value = convert_ulong4_sat_rtn((double4)sat_input);
    compare_ulong_elements_double("convert_ulong4_sat_rtn(double4)", i, 0, &sat_input, expected.raw, actual.raw, 4);
  }

#endif

#endif

union { int8 value; int raw[8]; } qe, qa;
union { float8 value; float raw[8]; } qo;

qo.value = (float8)(-23.67f, -23.50f, -23.35f, -23.0f, 23.0f, 23.35f, 23.50f, 23.67f);
qa.value = convert_int8_rtz(qo.value);
qe.value = (int8)(-23, -23, -23, -23, 23, 23, 23, 23);
compare_int_elements_float("convert_int8_rtz(float8)", 0, 0, qo.raw, qe.raw, qa.raw, 8);

qo.value = (float8)(-23.67f, -23.50f, -23.35f, -23.0f, 23.0f, 23.35f, 23.50f, 23.67f);
qa.value = convert_int8_rtp(qo.value);
qe.value = (int8)(-23, -23, -23, -23, 23, 24, 24, 24);
compare_int_elements_float("convert_int8_rtp(float8)", 0, 0, qo.raw, qe.raw, qa.raw, 8);

qo.value = (float8)(-23.67f, -23.50f, -23.35f, -23.0f, 23.0f, 23.35f, 23.50f, 23.67f);
qa.value = convert_int8_rtn(qo.value);
qe.value = (int8)(-24, -24, -24, -23, 23, 23, 23, 23);
compare_int_elements_float("convert_int8_rtn(float8)", 0, 0, qo.raw, qe.raw, qa.raw, 8);

qo.value = (float8)(-23.67f, -23.50f, -23.35f, -23.0f, 23.0f, 23.35f, 23.50f, 23.67f);
qa.value = convert_int8_rte(qo.value);
qe.value = (int8)(-24, -24, -23, -23, 23, 23, 24, 24);
compare_int_elements_float("convert_int8_rte(float8)", 0, 0, qo.raw, qe.raw, qa.raw, 8);

qo.value = (float8)(-23.67f, -23.50f, -23.35f, -23.0f, 23.0f, 23.35f, 23.50f, 23.67f);
qa.value = convert_int8(qo.value);
qe.value = (int8)(-23, -23, -23, -23, 23, 23, 23, 23);
compare_int_elements_float("convert_int8(float8)", 0, 0, qo.raw, qe.raw, qa.raw, 8);

}
