Replace cl_ushort with cl_half (#885) (#1000)

* test_common: Replace cl_ushort with cl_half (#885)

Change-Id: I507eca2084629c3b6f3e7331f062f006edbce434
Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* buffers, pipes, profiling: Replace cl_ushort with cl_half (#885)

Change-Id: Id9799322b636af6aa0eec3d4e846d7af8c7f9602
Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* images/kernel_read_write: Replace cl_ushort with cl_half (#885)

Change-Id: I922ddb593b6e5631d0f4ea1522c7f75f8770be40
Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* half: Replace cl_ushort with cl_half (#885)

Change-Id: I484a5bb2b33a7e87805fc6079953c66e5f8d9239
Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>
This commit is contained in:
Chetan Mistry
2020-10-02 16:29:05 +01:00
committed by GitHub
parent 615ab64db5
commit 7a735b74e3
15 changed files with 156 additions and 90 deletions

View File

@@ -1277,9 +1277,7 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
case kUInt: case kUInt:
*((unsigned int*)p) = val*0xffffffff; *((unsigned int*)p) = val*0xffffffff;
break; break;
case kHalf: case kHalf: *((cl_half *)p) = convert_float_to_half(val); break;
*((cl_ushort*)p) = convert_float_to_half(val);
break;
default: default:
log_error("Test error: unexpected type enum 0x%x\n",type); log_error("Test error: unexpected type enum 0x%x\n",type);
} }
@@ -1541,9 +1539,7 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
case kUInt: case kUInt:
*((unsigned int*)p) = val*0xffffffff; *((unsigned int*)p) = val*0xffffffff;
break; break;
case kHalf: case kHalf: *((cl_half *)p) = convert_float_to_half(val); break;
*((cl_ushort*)p) = convert_float_to_half(val);
break;
default: default:
log_error("Test error: unexpected type enum 0x%x\n",type); log_error("Test error: unexpected type enum 0x%x\n",type);
} }

View File

@@ -880,7 +880,7 @@ void generate_random_data( ExplicitType type, size_t count, MTdata d, void *outD
cl_ulong *ulongPtr; cl_ulong *ulongPtr;
cl_float *floatPtr; cl_float *floatPtr;
cl_double *doublePtr; cl_double *doublePtr;
cl_ushort *halfPtr; cl_half *halfPtr;
size_t i; size_t i;
cl_uint bits = genrand_int32(d); cl_uint bits = genrand_int32(d);
cl_uint bitsLeft = 32; cl_uint bitsLeft = 32;

View File

@@ -354,7 +354,7 @@ static float Ulp_Error_Half_Float( float test, double reference )
return (float) scalbn( testVal - reference, ulp_exp ); return (float) scalbn( testVal - reference, ulp_exp );
} }
float Ulp_Error_Half( cl_ushort test, float reference ) float Ulp_Error_Half(cl_half test, float reference)
{ {
return Ulp_Error_Half_Float(cl_half_to_float(test), reference); return Ulp_Error_Half_Float(cl_half_to_float(test), reference);
} }

View File

@@ -122,9 +122,9 @@ static int vlog_win32(const char *format, ...);
extern const char *IGetErrorString( int clErrorCode ); extern const char *IGetErrorString( int clErrorCode );
extern float Ulp_Error_Half( cl_ushort test, float reference ); extern float Ulp_Error_Half(cl_half test, float reference);
extern float Ulp_Error( float test, double reference ); extern float Ulp_Error(float test, double reference);
extern float Ulp_Error_Double( double test, long double reference ); extern float Ulp_Error_Double(double test, long double reference);
extern const char *GetChannelTypeName( cl_channel_type type ); extern const char *GetChannelTypeName( cl_channel_type type );
extern int IsChannelTypeSupported( cl_channel_type type ); extern int IsChannelTypeSupported( cl_channel_type type );

View File

@@ -925,7 +925,7 @@ int get_format_min_int( cl_image_format *format )
} }
} }
cl_ushort convert_float_to_half( float f ) cl_half convert_float_to_half(float f)
{ {
switch( gFloatToHalfRoundingMode ) switch( gFloatToHalfRoundingMode )
{ {
@@ -1281,10 +1281,9 @@ void read_image_pixel_float( void *imageData, image_descriptor *imageInfo,
break; break;
} }
case CL_HALF_FLOAT: case CL_HALF_FLOAT: {
{ cl_half *dPtr = (cl_half *)ptr;
cl_ushort *dPtr = (cl_ushort *)ptr; for (i = 0; i < channelCount; i++)
for( i = 0; i < channelCount; i++ )
tempData[i] = cl_half_to_float(dPtr[i]); tempData[i] = cl_half_to_float(dPtr[i]);
break; break;
} }
@@ -2397,9 +2396,8 @@ void pack_image_pixel( float *srcVector, const cl_image_format *imageFormat, voi
size_t channelCount = get_format_channel_count( imageFormat ); size_t channelCount = get_format_channel_count( imageFormat );
switch( imageFormat->image_channel_data_type ) switch( imageFormat->image_channel_data_type )
{ {
case CL_HALF_FLOAT: case CL_HALF_FLOAT: {
{ cl_half *ptr = (cl_half *)outData;
cl_ushort *ptr = (cl_ushort *)outData;
switch( gFloatToHalfRoundingMode ) switch( gFloatToHalfRoundingMode )
{ {
@@ -2569,9 +2567,8 @@ void pack_image_pixel_error( const float *srcVector, const cl_image_format *imag
size_t channelCount = get_format_channel_count( imageFormat ); size_t channelCount = get_format_channel_count( imageFormat );
switch( imageFormat->image_channel_data_type ) switch( imageFormat->image_channel_data_type )
{ {
case CL_HALF_FLOAT: case CL_HALF_FLOAT: {
{ const cl_half *ptr = (const cl_half *)results;
const cl_ushort *ptr = (const cl_ushort *)results;
for( unsigned int i = 0; i < channelCount; i++ ) for( unsigned int i = 0; i < channelCount; i++ )
errors[i] = Ulp_Error_Half( ptr[i], srcVector[i] ); errors[i] = Ulp_Error_Half( ptr[i], srcVector[i] );
@@ -2838,25 +2835,28 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS
return err; return err;
} }
// read the results // read the results
cl_ushort outBuf[count*4]; cl_half outBuf[count * 4];
memset( outBuf, -1, sizeof( outBuf ) ); memset(outBuf, -1, sizeof(outBuf));
size_t origin[3] = {0,0,0}; size_t origin[3] = { 0, 0, 0 };
size_t region[3] = {count,1,1}; size_t region[3] = { count, 1, 1 };
err = clEnqueueReadImage( q, outImage, CL_TRUE, origin, region, 0, 0, outBuf, 0, NULL, NULL ); err = clEnqueueReadImage(q, outImage, CL_TRUE, origin, region, 0, 0,
if( err ) outBuf, 0, NULL, NULL);
if (err)
{ {
log_error( "Error: could not read output image in DetectFloatToHalfRoundingMode (%d)", err ); log_error("Error: could not read output image in "
clReleaseMemObject( inBuf ); "DetectFloatToHalfRoundingMode (%d)",
clReleaseMemObject( outImage ); err);
clReleaseKernel( k ); clReleaseMemObject(inBuf);
clReleaseMemObject(outImage);
clReleaseKernel(k);
return err; return err;
} }
// Generate our list of reference results // Generate our list of reference results
cl_ushort rte_ref[count*4]; cl_half rte_ref[count * 4];
cl_ushort rtz_ref[count*4]; cl_half rtz_ref[count * 4];
for( size_t i = 0; i < 4 * count; i++ ) for (size_t i = 0; i < 4 * count; i++)
{ {
rte_ref[i] = cl_half_from_float(inp[i], CL_HALF_RTE); rte_ref[i] = cl_half_from_float(inp[i], CL_HALF_RTE);
rtz_ref[i] = cl_half_from_float(inp[i], CL_HALF_RTZ); rtz_ref[i] = cl_half_from_float(inp[i], CL_HALF_RTZ);

View File

@@ -275,10 +275,9 @@ template <class T> void read_image_pixel( void *imageData, image_descriptor *ima
break; break;
} }
case CL_HALF_FLOAT: case CL_HALF_FLOAT: {
{ cl_half *dPtr = (cl_half *)ptr;
cl_ushort *dPtr = (cl_ushort *)ptr; for (i = 0; i < get_format_channel_count(format); i++)
for( i = 0; i < get_format_channel_count( format ); i++ )
tempData[i] = (T)cl_half_to_float(dPtr[i]); tempData[i] = (T)cl_half_to_float(dPtr[i]);
break; break;
} }
@@ -639,17 +638,18 @@ protected:
size_t mVecSize; size_t mVecSize;
}; };
extern cl_ushort convert_float_to_half(float f); extern cl_half convert_float_to_half(float f);
extern int DetectFloatToHalfRoundingMode( cl_command_queue ); // Returns CL_SUCCESS on success extern int DetectFloatToHalfRoundingMode(
cl_command_queue); // Returns CL_SUCCESS on success
// sign bit: don't care, exponent: maximum value, significand: non-zero // sign bit: don't care, exponent: maximum value, significand: non-zero
static int inline is_half_nan( cl_ushort half ){ return ( half & 0x7fff ) > 0x7c00; } static int inline is_half_nan(cl_half half) { return (half & 0x7fff) > 0x7c00; }
// sign bit: don't care, exponent: zero, significand: non-zero // sign bit: don't care, exponent: zero, significand: non-zero
static int inline is_half_denorm( cl_ushort half ){ return IsHalfSubnormal( half ); } static int inline is_half_denorm(cl_half half) { return IsHalfSubnormal(half); }
// sign bit: don't care, exponent: zero, significand: zero // sign bit: don't care, exponent: zero, significand: zero
static int inline is_half_zero( cl_ushort half ){ return ( half & 0x7fff ) == 0; } static int inline is_half_zero(cl_half half) { return (half & 0x7fff) == 0; }
extern double sRGBmap(float fc); extern double sRGBmap(float fc);

View File

@@ -554,8 +554,8 @@ static int verify_write_float( void *ptr1, void *ptr2, int n )
static int verify_write_half( void *ptr1, void *ptr2, int n ) static int verify_write_half( void *ptr1, void *ptr2, int n )
{ {
int i; int i;
cl_ushort *inptr = (cl_ushort *)ptr1; cl_half *inptr = (cl_half *)ptr1;
cl_ushort *outptr = (cl_ushort *)ptr2; cl_half *outptr = (cl_half *)ptr2;
for ( i = 0; i < n; i++ ){ for ( i = 0; i < n; i++ ){
if ( outptr[i] != inptr[i] ) if ( outptr[i] != inptr[i] )

View File

@@ -210,42 +210,42 @@ CheckD(cl_uint jid, cl_uint tid, void *userInfo)
return ret; return ret;
} }
static cl_ushort float2half_rte(float f) static cl_half float2half_rte(float f)
{ {
return cl_half_from_float(f, CL_HALF_RTE); return cl_half_from_float(f, CL_HALF_RTE);
} }
static cl_ushort float2half_rtz(float f) static cl_half float2half_rtz(float f)
{ {
return cl_half_from_float(f, CL_HALF_RTZ); return cl_half_from_float(f, CL_HALF_RTZ);
} }
static cl_ushort float2half_rtp(float f) static cl_half float2half_rtp(float f)
{ {
return cl_half_from_float(f, CL_HALF_RTP); return cl_half_from_float(f, CL_HALF_RTP);
} }
static cl_ushort float2half_rtn(float f) static cl_half float2half_rtn(float f)
{ {
return cl_half_from_float(f, CL_HALF_RTN); return cl_half_from_float(f, CL_HALF_RTN);
} }
static cl_ushort double2half_rte(double f) static cl_half double2half_rte(double f)
{ {
return cl_half_from_double(f, CL_HALF_RTE); return cl_half_from_double(f, CL_HALF_RTE);
} }
static cl_ushort double2half_rtz(double f) static cl_half double2half_rtz(double f)
{ {
return cl_half_from_double(f, CL_HALF_RTZ); return cl_half_from_double(f, CL_HALF_RTZ);
} }
static cl_ushort double2half_rtp(double f) static cl_half double2half_rtp(double f)
{ {
return cl_half_from_double(f, CL_HALF_RTP); return cl_half_from_double(f, CL_HALF_RTP);
} }
static cl_ushort double2half_rtn(double f) static cl_half double2half_rtn(double f)
{ {
return cl_half_from_double(f, CL_HALF_RTN); return cl_half_from_double(f, CL_HALF_RTN);
} }
@@ -696,30 +696,30 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
ComputeReferenceInfoF fref; ComputeReferenceInfoF fref;
fref.x = (float *)gIn_single; fref.x = (float *)gIn_single;
fref.r = (cl_ushort *)gOut_half_reference; fref.r = (cl_half *)gOut_half_reference;
fref.f = referenceFunc; fref.f = referenceFunc;
fref.lim = blockCount; fref.lim = blockCount;
fref.count = (blockCount + threadCount - 1) / threadCount; fref.count = (blockCount + threadCount - 1) / threadCount;
CheckResultInfoF fchk; CheckResultInfoF fchk;
fchk.x = (const float *)gIn_single; fchk.x = (const float *)gIn_single;
fchk.r = (const cl_ushort *)gOut_half_reference; fchk.r = (const cl_half *)gOut_half_reference;
fchk.s = (const cl_ushort *)gOut_half; fchk.s = (const cl_half *)gOut_half;
fchk.f = referenceFunc; fchk.f = referenceFunc;
fchk.lim = blockCount; fchk.lim = blockCount;
fchk.count = (blockCount + threadCount - 1) / threadCount; fchk.count = (blockCount + threadCount - 1) / threadCount;
ComputeReferenceInfoD dref; ComputeReferenceInfoD dref;
dref.x = (double *)gIn_double; dref.x = (double *)gIn_double;
dref.r = (cl_ushort *)gOut_half_reference_double; dref.r = (cl_half *)gOut_half_reference_double;
dref.f = doubleReferenceFunc; dref.f = doubleReferenceFunc;
dref.lim = blockCount; dref.lim = blockCount;
dref.count = (blockCount + threadCount - 1) / threadCount; dref.count = (blockCount + threadCount - 1) / threadCount;
CheckResultInfoD dchk; CheckResultInfoD dchk;
dchk.x = (const double *)gIn_double; dchk.x = (const double *)gIn_double;
dchk.r = (const cl_ushort *)gOut_half_reference_double; dchk.r = (const cl_half *)gOut_half_reference_double;
dchk.s = (const cl_ushort *)gOut_half; dchk.s = (const cl_half *)gOut_half;
dchk.f = doubleReferenceFunc; dchk.f = doubleReferenceFunc;
dchk.lim = blockCount; dchk.lim = blockCount;
dchk.count = (blockCount + threadCount - 1) / threadCount; dchk.count = (blockCount + threadCount - 1) / threadCount;
@@ -764,7 +764,9 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
cl_uint pattern = 0xdeaddead; cl_uint pattern = 0xdeaddead;
memset_pattern4( gOut_half, &pattern, BUFFER_SIZE/2); memset_pattern4( gOut_half, &pattern, BUFFER_SIZE/2);
error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE,
0, count * sizeof(cl_half),
gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clWriteArray\n" ); vlog_error( "Failure in clWriteArray\n" );
gFailCount++; gFailCount++;
@@ -779,7 +781,9 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
goto exit; goto exit;
} }
error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0,
count * sizeof(cl_half), gOut_half,
0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clReadArray\n" ); vlog_error( "Failure in clReadArray\n" );
gFailCount++; gFailCount++;
@@ -795,7 +799,9 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
if (gTestDouble) { if (gTestDouble) {
memset_pattern4( gOut_half, &pattern, BUFFER_SIZE/2); memset_pattern4( gOut_half, &pattern, BUFFER_SIZE/2);
error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueWriteBuffer(
gQueue, gOutBuffer_half, CL_FALSE, 0,
count * sizeof(cl_half), gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clWriteArray\n" ); vlog_error( "Failure in clWriteArray\n" );
gFailCount++; gFailCount++;
@@ -810,7 +816,9 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
goto exit; goto exit;
} }
error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueReadBuffer(
gQueue, gOutBuffer_half, CL_TRUE, 0,
count * sizeof(cl_half), gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clReadArray\n" ); vlog_error( "Failure in clReadArray\n" );
gFailCount++; gFailCount++;
@@ -1285,30 +1293,30 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
ComputeReferenceInfoF fref; ComputeReferenceInfoF fref;
fref.x = (float *)gIn_single; fref.x = (float *)gIn_single;
fref.r = (cl_ushort *)gOut_half_reference; fref.r = (cl_half *)gOut_half_reference;
fref.f = referenceFunc; fref.f = referenceFunc;
fref.lim = blockCount; fref.lim = blockCount;
fref.count = (blockCount + threadCount - 1) / threadCount; fref.count = (blockCount + threadCount - 1) / threadCount;
CheckResultInfoF fchk; CheckResultInfoF fchk;
fchk.x = (const float *)gIn_single; fchk.x = (const float *)gIn_single;
fchk.r = (const cl_ushort *)gOut_half_reference; fchk.r = (const cl_half *)gOut_half_reference;
fchk.s = (const cl_ushort *)gOut_half; fchk.s = (const cl_half *)gOut_half;
fchk.f = referenceFunc; fchk.f = referenceFunc;
fchk.lim = blockCount; fchk.lim = blockCount;
fchk.count = (blockCount + threadCount - 1) / threadCount; fchk.count = (blockCount + threadCount - 1) / threadCount;
ComputeReferenceInfoD dref; ComputeReferenceInfoD dref;
dref.x = (double *)gIn_double; dref.x = (double *)gIn_double;
dref.r = (cl_ushort *)gOut_half_reference_double; dref.r = (cl_half *)gOut_half_reference_double;
dref.f = doubleReferenceFunc; dref.f = doubleReferenceFunc;
dref.lim = blockCount; dref.lim = blockCount;
dref.count = (blockCount + threadCount - 1) / threadCount; dref.count = (blockCount + threadCount - 1) / threadCount;
CheckResultInfoD dchk; CheckResultInfoD dchk;
dchk.x = (const double *)gIn_double; dchk.x = (const double *)gIn_double;
dchk.r = (const cl_ushort *)gOut_half_reference_double; dchk.r = (const cl_half *)gOut_half_reference_double;
dchk.s = (const cl_ushort *)gOut_half; dchk.s = (const cl_half *)gOut_half;
dchk.f = doubleReferenceFunc; dchk.f = doubleReferenceFunc;
dchk.lim = blockCount; dchk.lim = blockCount;
dchk.count = (blockCount + threadCount - 1) / threadCount; dchk.count = (blockCount + threadCount - 1) / threadCount;
@@ -1353,7 +1361,9 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
cl_uint pattern = 0xdeaddead; cl_uint pattern = 0xdeaddead;
memset_pattern4(gOut_half, &pattern, BUFFER_SIZE/2); memset_pattern4(gOut_half, &pattern, BUFFER_SIZE/2);
error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE,
0, count * sizeof(cl_half),
gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clWriteArray\n" ); vlog_error( "Failure in clWriteArray\n" );
gFailCount++; gFailCount++;
@@ -1368,7 +1378,9 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
goto exit; goto exit;
} }
error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0,
count * sizeof(cl_half), gOut_half,
0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clReadArray\n" ); vlog_error( "Failure in clReadArray\n" );
gFailCount++; gFailCount++;
@@ -1384,7 +1396,9 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
if (gTestDouble) { if (gTestDouble) {
memset_pattern4(gOut_half, &pattern, BUFFER_SIZE/2); memset_pattern4(gOut_half, &pattern, BUFFER_SIZE/2);
error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_FALSE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueWriteBuffer(
gQueue, gOutBuffer_half, CL_FALSE, 0,
count * sizeof(cl_half), gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clWriteArray\n" ); vlog_error( "Failure in clWriteArray\n" );
gFailCount++; gFailCount++;
@@ -1399,7 +1413,9 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
goto exit; goto exit;
} }
error = clEnqueueReadBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_ushort), gOut_half, 0, NULL, NULL); error = clEnqueueReadBuffer(
gQueue, gOutBuffer_half, CL_TRUE, 0,
count * sizeof(cl_half), gOut_half, 0, NULL, NULL);
if (error) { if (error) {
vlog_error( "Failure in clReadArray\n" ); vlog_error( "Failure in clReadArray\n" );
gFailCount++; gFailCount++;

View File

@@ -472,8 +472,18 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que
log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_HALF_FLOAT: case CL_HALF_FLOAT:
log_error( " Expected: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultBuffer)[0], ((cl_ushort*)resultBuffer)[1], ((cl_ushort*)resultBuffer)[2], ((cl_ushort*)resultBuffer)[3] ); log_error(" Expected: 0x%4.4x "
log_error( " Actual: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultPtr)[0], ((cl_ushort*)resultPtr)[1], ((cl_ushort*)resultPtr)[2], ((cl_ushort*)resultPtr)[3] ); "0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultBuffer)[0],
((cl_half *)resultBuffer)[1],
((cl_half *)resultBuffer)[2],
((cl_half *)resultBuffer)[3]);
log_error(" Actual: 0x%4.4x "
"0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultPtr)[0],
((cl_half *)resultPtr)[1],
((cl_half *)resultPtr)[2],
((cl_half *)resultPtr)[3]);
log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_UNSIGNED_INT32: case CL_UNSIGNED_INT32:

View File

@@ -491,8 +491,18 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma
log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_HALF_FLOAT: case CL_HALF_FLOAT:
log_error( " Expected: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultBuffer)[0], ((cl_ushort*)resultBuffer)[1], ((cl_ushort*)resultBuffer)[2], ((cl_ushort*)resultBuffer)[3] ); log_error(" Expected: 0x%4.4x "
log_error( " Actual: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultPtr)[0], ((cl_ushort*)resultPtr)[1], ((cl_ushort*)resultPtr)[2], ((cl_ushort*)resultPtr)[3] ); "0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultBuffer)[0],
((cl_half *)resultBuffer)[1],
((cl_half *)resultBuffer)[2],
((cl_half *)resultBuffer)[3]);
log_error(" Actual: 0x%4.4x "
"0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultPtr)[0],
((cl_half *)resultPtr)[1],
((cl_half *)resultPtr)[2],
((cl_half *)resultPtr)[3]);
log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_UNSIGNED_INT32: case CL_UNSIGNED_INT32:

View File

@@ -514,8 +514,20 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma
log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_HALF_FLOAT: case CL_HALF_FLOAT:
log_error( " Expected: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultBuffer)[0], ((cl_ushort*)resultBuffer)[1], ((cl_ushort*)resultBuffer)[2], ((cl_ushort*)resultBuffer)[3] ); log_error(
log_error( " Actual: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultPtr)[0], ((cl_ushort*)resultPtr)[1], ((cl_ushort*)resultPtr)[2], ((cl_ushort*)resultPtr)[3] ); " Expected: 0x%4.4x 0x%4.4x "
"0x%4.4x 0x%4.4x\n",
((cl_half *)resultBuffer)[0],
((cl_half *)resultBuffer)[1],
((cl_half *)resultBuffer)[2],
((cl_half *)resultBuffer)[3]);
log_error(
" Actual: 0x%4.4x 0x%4.4x "
"0x%4.4x 0x%4.4x\n",
((cl_half *)resultPtr)[0],
((cl_half *)resultPtr)[1],
((cl_half *)resultPtr)[2],
((cl_half *)resultPtr)[3]);
log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_UNSIGNED_INT32: case CL_UNSIGNED_INT32:

View File

@@ -521,8 +521,20 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que
log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_HALF_FLOAT: case CL_HALF_FLOAT:
log_error( " Expected: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultBuffer)[0], ((cl_ushort*)resultBuffer)[1], ((cl_ushort*)resultBuffer)[2], ((cl_ushort*)resultBuffer)[3] ); log_error(
log_error( " Actual: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultPtr)[0], ((cl_ushort*)resultPtr)[1], ((cl_ushort*)resultPtr)[2], ((cl_ushort*)resultPtr)[3] ); " Expected: 0x%4.4x 0x%4.4x "
"0x%4.4x 0x%4.4x\n",
((cl_half *)resultBuffer)[0],
((cl_half *)resultBuffer)[1],
((cl_half *)resultBuffer)[2],
((cl_half *)resultBuffer)[3]);
log_error(
" Actual: 0x%4.4x 0x%4.4x "
"0x%4.4x 0x%4.4x\n",
((cl_half *)resultPtr)[0],
((cl_half *)resultPtr)[1],
((cl_half *)resultPtr)[2],
((cl_half *)resultPtr)[3]);
log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_UNSIGNED_INT32: case CL_UNSIGNED_INT32:

View File

@@ -538,8 +538,18 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue
log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Error: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_HALF_FLOAT: case CL_HALF_FLOAT:
log_error( " Expected: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultBuffer)[0], ((cl_ushort*)resultBuffer)[1], ((cl_ushort*)resultBuffer)[2], ((cl_ushort*)resultBuffer)[3] ); log_error(" Expected: 0x%4.4x "
log_error( " Actual: 0x%4.4x 0x%4.4x 0x%4.4x 0x%4.4x\n", ((cl_ushort*)resultPtr)[0], ((cl_ushort*)resultPtr)[1], ((cl_ushort*)resultPtr)[2], ((cl_ushort*)resultPtr)[3] ); "0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultBuffer)[0],
((cl_half *)resultBuffer)[1],
((cl_half *)resultBuffer)[2],
((cl_half *)resultBuffer)[3]);
log_error(" Actual: 0x%4.4x "
"0x%4.4x 0x%4.4x 0x%4.4x\n",
((cl_half *)resultPtr)[0],
((cl_half *)resultPtr)[1],
((cl_half *)resultPtr)[2],
((cl_half *)resultPtr)[3]);
log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] ); log_error( " Ulps: %f %f %f %f\n", errors[0], errors[1], errors[2], errors[3] );
break; break;
case CL_UNSIGNED_INT32: case CL_UNSIGNED_INT32:

View File

@@ -361,8 +361,8 @@ static int verify_readwrite_half(void *ptr1, void *ptr2, int n)
{ {
int i; int i;
int sum_input = 0, sum_output = 0; int sum_input = 0, sum_output = 0;
cl_ushort *inptr = (cl_ushort *)ptr1; cl_half *inptr = (cl_half *)ptr1;
cl_ushort *outptr = (cl_ushort *)ptr2; cl_half *outptr = (cl_half *)ptr2;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {

View File

@@ -551,8 +551,8 @@ static int verify_write_float( void *ptr1, void *ptr2, int n )
static int verify_write_half( void *ptr1, void *ptr2, int n ) static int verify_write_half( void *ptr1, void *ptr2, int n )
{ {
int i; int i;
cl_ushort *inptr = (cl_ushort *)ptr1; cl_half *inptr = (cl_half *)ptr1;
cl_ushort *outptr = (cl_ushort *)ptr2; cl_half *outptr = (cl_half *)ptr2;
for( i = 0; i < n; i++ ){ for( i = 0; i < n; i++ ){
if( outptr[i] != inptr[i] ) if( outptr[i] != inptr[i] )