mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
remove min max macros (#1310)
* remove the MIN and MAX macros and use the std versions instead * fix formatting * fix Arm build * remove additional MIN and MAX macros from compat.h
This commit is contained in:
@@ -21,27 +21,18 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "procs.h"
|
||||
|
||||
#define UCHAR_MIN 0
|
||||
#define USHRT_MIN 0
|
||||
#define UINT_MIN 0
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( _a, _b ) ( (_a) > (_b) ? (_a) : (_b) )
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN( _a, _b ) ( (_a) < (_b) ? (_a) : (_b) )
|
||||
#endif
|
||||
|
||||
static int verify_addsat_char( const cl_char *inA, const cl_char *inB, const cl_char *outptr, int n, const char *sizeName, int vecSize )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] + (cl_int) inB[i];
|
||||
r = MAX( r, CL_CHAR_MIN );
|
||||
r = MIN( r, CL_CHAR_MAX );
|
||||
r = std::max(r, CL_CHAR_MIN);
|
||||
r = std::min(r, CL_CHAR_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for add_sat( (char%s) 0x%2.2x, (char%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
@@ -55,9 +46,9 @@ static int verify_addsat_uchar( const cl_uchar *inA, const cl_uchar *inB, const
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (int) inA[i] + (int) inB[i];
|
||||
r = MAX( r, 0 );
|
||||
r = MIN( r, CL_UCHAR_MAX );
|
||||
if( r != outptr[i] )
|
||||
r = std::max(r, 0);
|
||||
r = std::min(r, CL_UCHAR_MAX);
|
||||
if (r != outptr[i])
|
||||
{ log_info( "\n%d) Failure for add_sat( (uchar%s) 0x%2.2x, (uchar%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
}
|
||||
return 0;
|
||||
@@ -69,8 +60,8 @@ static int verify_addsat_short( const cl_short *inA, const cl_short *inB, const
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] + (cl_int) inB[i];
|
||||
r = MAX( r, CL_SHRT_MIN );
|
||||
r = MIN( r, CL_SHRT_MAX );
|
||||
r = std::max(r, CL_SHRT_MIN);
|
||||
r = std::min(r, CL_SHRT_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for add_sat( (short%s) 0x%4.4x, (short%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
@@ -84,8 +75,8 @@ static int verify_addsat_ushort( const cl_ushort *inA, const cl_ushort *inB, con
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] + (cl_int) inB[i];
|
||||
r = MAX( r, 0 );
|
||||
r = MIN( r, CL_USHRT_MAX );
|
||||
r = std::max(r, 0);
|
||||
r = std::min(r, CL_USHRT_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for add_sat( (ushort%s) 0x%4.4x, (ushort%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
|
||||
@@ -16,14 +16,9 @@
|
||||
#include "testBase.h"
|
||||
#include "harness/conversions.h"
|
||||
|
||||
#define TEST_SIZE 512
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( _a, _b ) ((_a) < (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX( _a, _b ) ((_a) > (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
#define TEST_SIZE 512
|
||||
|
||||
const char *singleParamIntegerKernelSourcePattern =
|
||||
"__kernel void sample_test(__global %s *sourceA, __global %s *destValues)\n"
|
||||
@@ -1512,19 +1507,20 @@ bool verify_integer_clamp( void *sourceA, void *sourceB, void *sourceC, void *de
|
||||
switch( vecAType )
|
||||
{
|
||||
case kULong:
|
||||
((cl_ulong*) destination)[0] = MAX(MIN(valueA, valueC), valueB);
|
||||
((cl_ulong *)destination)[0] =
|
||||
std::max(std::min(valueA, valueC), valueB);
|
||||
break;
|
||||
case kUInt:
|
||||
((cl_uint*) destination)[0] = (cl_uint)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_uint *)destination)[0] =
|
||||
(cl_uint)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
case kUShort:
|
||||
((cl_ushort*) destination)[0] = (cl_ushort)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_ushort *)destination)[0] =
|
||||
(cl_ushort)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
case kUChar:
|
||||
((cl_uchar*) destination)[0] = (cl_uchar)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_uchar *)destination)[0] =
|
||||
(cl_uchar)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
default:
|
||||
//error -- should never get here
|
||||
@@ -1576,19 +1572,20 @@ bool verify_integer_clamp( void *sourceA, void *sourceB, void *sourceC, void *de
|
||||
switch( vecAType )
|
||||
{
|
||||
case kLong:
|
||||
((cl_long*) destination)[0] = MAX(MIN(valueA, valueC), valueB);
|
||||
((cl_long *)destination)[0] =
|
||||
std::max(std::min(valueA, valueC), valueB);
|
||||
break;
|
||||
case kInt:
|
||||
((cl_int*) destination)[0] = (cl_int)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_int *)destination)[0] =
|
||||
(cl_int)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
case kShort:
|
||||
((cl_short*) destination)[0] = (cl_short)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_short *)destination)[0] =
|
||||
(cl_short)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
case kChar:
|
||||
((cl_char*) destination)[0] = (cl_char)
|
||||
(MAX(MIN(valueA, valueC), valueB));
|
||||
((cl_char *)destination)[0] =
|
||||
(cl_char)(std::max(std::min(valueA, valueC), valueB));
|
||||
break;
|
||||
default:
|
||||
//error -- should never get here
|
||||
@@ -1654,13 +1651,16 @@ bool verify_integer_mad_sat( void *sourceA, void *sourceB, void *sourceC, void *
|
||||
((cl_ulong*) destination)[0] = multLo;
|
||||
break;
|
||||
case kUInt:
|
||||
((cl_uint*) destination)[0] = (cl_uint) MIN( multLo, (cl_ulong) CL_UINT_MAX );
|
||||
((cl_uint *)destination)[0] =
|
||||
(cl_uint)std::min(multLo, (cl_ulong)CL_UINT_MAX);
|
||||
break;
|
||||
case kUShort:
|
||||
((cl_ushort*) destination)[0] = (cl_ushort) MIN( multLo, (cl_ulong) CL_USHRT_MAX );
|
||||
((cl_ushort *)destination)[0] =
|
||||
(cl_ushort)std::min(multLo, (cl_ulong)CL_USHRT_MAX);
|
||||
break;
|
||||
case kUChar:
|
||||
((cl_uchar*) destination)[0] = (cl_uchar) MIN( multLo, (cl_ulong) CL_UCHAR_MAX );
|
||||
((cl_uchar *)destination)[0] =
|
||||
(cl_uchar)std::min(multLo, (cl_ulong)CL_UCHAR_MAX);
|
||||
break;
|
||||
default:
|
||||
//error -- should never get here
|
||||
@@ -1744,18 +1744,18 @@ bool verify_integer_mad_sat( void *sourceA, void *sourceB, void *sourceC, void *
|
||||
((cl_long*) destination)[0] = result;
|
||||
break;
|
||||
case kInt:
|
||||
result = MIN( result, (cl_long) CL_INT_MAX );
|
||||
result = MAX( result, (cl_long) CL_INT_MIN );
|
||||
result = std::min(result, (cl_long)CL_INT_MAX);
|
||||
result = std::max(result, (cl_long)CL_INT_MIN);
|
||||
((cl_int*) destination)[0] = (cl_int) result;
|
||||
break;
|
||||
case kShort:
|
||||
result = MIN( result, (cl_long) CL_SHRT_MAX );
|
||||
result = MAX( result, (cl_long) CL_SHRT_MIN );
|
||||
result = std::min(result, (cl_long)CL_SHRT_MAX);
|
||||
result = std::max(result, (cl_long)CL_SHRT_MIN);
|
||||
((cl_short*) destination)[0] = (cl_short) result;
|
||||
break;
|
||||
case kChar:
|
||||
result = MIN( result, (cl_long) CL_CHAR_MAX );
|
||||
result = MAX( result, (cl_long) CL_CHAR_MIN );
|
||||
result = std::min(result, (cl_long)CL_CHAR_MAX);
|
||||
result = std::max(result, (cl_long)CL_CHAR_MIN);
|
||||
((cl_char*) destination)[0] = (cl_char) result;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -21,28 +21,18 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "procs.h"
|
||||
|
||||
#define UCHAR_MIN 0
|
||||
#define USHRT_MIN 0
|
||||
#define UINT_MIN 0
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( _a, _b ) ( (_a) > (_b) ? (_a) : (_b) )
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN( _a, _b ) ( (_a) < (_b) ? (_a) : (_b) )
|
||||
#endif
|
||||
|
||||
|
||||
static int verify_subsat_char( const cl_char *inA, const cl_char *inB, const cl_char *outptr, int n, const char *sizeName, int vecSize )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] - (cl_int) inB[i];
|
||||
r = MAX( r, CL_CHAR_MIN );
|
||||
r = MIN( r, CL_CHAR_MAX );
|
||||
r = std::max(r, CL_CHAR_MIN);
|
||||
r = std::min(r, CL_CHAR_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for sub_sat( (char%s) 0x%2.2x, (char%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
@@ -56,9 +46,9 @@ static int verify_subsat_uchar( const cl_uchar *inA, const cl_uchar *inB, const
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] - (cl_int) inB[i];
|
||||
r = MAX( r, 0 );
|
||||
r = MIN( r, CL_UCHAR_MAX );
|
||||
if( r != outptr[i] )
|
||||
r = std::max(r, 0);
|
||||
r = std::min(r, CL_UCHAR_MAX);
|
||||
if (r != outptr[i])
|
||||
{ log_info( "\n%d) Failure for sub_sat( (uchar%s) 0x%2.2x, (uchar%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
}
|
||||
return 0;
|
||||
@@ -70,8 +60,8 @@ static int verify_subsat_short( const cl_short *inA, const cl_short *inB, const
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] - (cl_int) inB[i];
|
||||
r = MAX( r, CL_SHRT_MIN );
|
||||
r = MIN( r, CL_SHRT_MAX );
|
||||
r = std::max(r, CL_SHRT_MIN);
|
||||
r = std::min(r, CL_SHRT_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for sub_sat( (short%s) 0x%4.4x, (short%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
@@ -85,8 +75,8 @@ static int verify_subsat_ushort( const cl_ushort *inA, const cl_ushort *inB, con
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
cl_int r = (cl_int) inA[i] - (cl_int) inB[i];
|
||||
r = MAX( r, 0 );
|
||||
r = MIN( r, CL_USHRT_MAX );
|
||||
r = std::max(r, 0);
|
||||
r = std::min(r, CL_USHRT_MAX);
|
||||
|
||||
if( r != outptr[i] )
|
||||
{ log_info( "\n%d) Failure for sub_sat( (ushort%s) 0x%4.4x, (ushort%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; }
|
||||
|
||||
@@ -107,7 +107,7 @@ int test_unary_op( cl_command_queue queue, cl_context context, OpKonstants which
|
||||
// For sub ops, the min control value is 2. Otherwise, it's 0
|
||||
controlData[ i ] |= 0x02;
|
||||
else if( whichOp == kIncrement )
|
||||
// For addition ops, the MAX control value is 1. Otherwise, it's 3
|
||||
// For addition ops, the max control value is 1. Otherwise, it's 3
|
||||
controlData[ i ] &= ~0x02;
|
||||
}
|
||||
streams[1] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR,
|
||||
|
||||
Reference in New Issue
Block a user