mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 15:39:03 +00:00
Synchronise with Khronos-private Gitlab branch
The maintenance of the conformance tests is moving to Github. This commit contains all the changes that have been done in Gitlab since the first public release of the conformance tests. Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_cl_fill_images
|
||||
: main.cpp
|
||||
test_fill_2D_3D.cpp
|
||||
test_fill_2D.cpp
|
||||
test_fill_3D.cpp
|
||||
test_loops.cpp
|
||||
/images//image_helpers
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_cl_fill_images
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/images/clFillImage
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/images/clFillImage
|
||||
;
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_cl_fill_images
|
||||
: main.cpp
|
||||
test_fill_2D_3D.cpp
|
||||
test_fill_2D.cpp
|
||||
test_fill_3D.cpp
|
||||
test_loops.cpp
|
||||
/images//image_helpers
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_cl_fill_images
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/images/clFillImage
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/images/clFillImage
|
||||
;
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
test_fill_generic.cpp \
|
||||
test_fill_1D.cpp \
|
||||
test_fill_2D.cpp \
|
||||
test_fill_3D.cpp \
|
||||
test_fill_1D_array.cpp \
|
||||
test_fill_2D_array.cpp \
|
||||
test_loops.cpp \
|
||||
../image_helpers.cpp \
|
||||
../../../test_common/harness/errorHelpers.c \
|
||||
../../../test_common/harness/threadTesting.c \
|
||||
../../../test_common/harness/kernelHelpers.c \
|
||||
../../../test_common/harness/imageHelpers.cpp \
|
||||
../../../test_common/harness/conversions.c \
|
||||
../../../test_common/harness/testHarness.cpp \
|
||||
../../../test_common/harness/typeWrappers.cpp \
|
||||
../../../test_common/harness/mt19937.c
|
||||
|
||||
|
||||
DEFINES = DONT_TEST_GARBAGE_POINTERS
|
||||
|
||||
SOURCES = $(abspath $(SRCS))
|
||||
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
|
||||
LIBPATH += -L.
|
||||
FRAMEWORK =
|
||||
HEADERS =
|
||||
TARGET = test_cl_fill_images
|
||||
INCLUDE =
|
||||
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32 -Os
|
||||
CC = c++
|
||||
CXX = c++
|
||||
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
|
||||
|
||||
OBJECTS := ${SOURCES:.c=.o}
|
||||
OBJECTS := ${OBJECTS:.cpp=.o}
|
||||
|
||||
TARGETOBJECT =
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.DEFAULT:
|
||||
@echo The target \"$@\" does not exist in Makefile.
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
test_fill_generic.cpp \
|
||||
test_fill_1D.cpp \
|
||||
test_fill_2D.cpp \
|
||||
test_fill_3D.cpp \
|
||||
test_fill_1D_array.cpp \
|
||||
test_fill_2D_array.cpp \
|
||||
test_loops.cpp \
|
||||
../image_helpers.cpp \
|
||||
../../../test_common/harness/errorHelpers.c \
|
||||
../../../test_common/harness/threadTesting.c \
|
||||
../../../test_common/harness/kernelHelpers.c \
|
||||
../../../test_common/harness/imageHelpers.cpp \
|
||||
../../../test_common/harness/conversions.c \
|
||||
../../../test_common/harness/testHarness.cpp \
|
||||
../../../test_common/harness/typeWrappers.cpp \
|
||||
../../../test_common/harness/mt19937.c
|
||||
|
||||
|
||||
DEFINES = DONT_TEST_GARBAGE_POINTERS
|
||||
|
||||
SOURCES = $(abspath $(SRCS))
|
||||
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
|
||||
LIBPATH += -L.
|
||||
FRAMEWORK =
|
||||
HEADERS =
|
||||
TARGET = test_cl_fill_images
|
||||
INCLUDE =
|
||||
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32 -Os
|
||||
CC = c++
|
||||
CXX = c++
|
||||
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
|
||||
|
||||
OBJECTS := ${SOURCES:.c=.o}
|
||||
OBJECTS := ${OBJECTS:.cpp=.o}
|
||||
|
||||
TARGETOBJECT =
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.DEFAULT:
|
||||
@echo The target \"$@\" does not exist in Makefile.
|
||||
|
||||
@@ -1,256 +1,256 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "../testBase.h"
|
||||
|
||||
bool gDebugTrace = false, gTestSmallImages = false, gTestMaxImages = false, gTestRounding = false, gEnablePitch = false;
|
||||
int gTypesToTest = 0;
|
||||
cl_channel_type gChannelTypeToUse = (cl_channel_type)-1;
|
||||
cl_channel_order gChannelOrderToUse = (cl_channel_order)-1;
|
||||
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
cl_context context;
|
||||
cl_command_queue queue;
|
||||
|
||||
extern int test_image_set( cl_device_id device, MethodsToTest testMethod );
|
||||
|
||||
#define MAX_ALLOWED_STD_DEVIATION_IN_MB 8.0
|
||||
|
||||
void printUsage( const char *execName )
|
||||
{
|
||||
const char *p = strrchr( execName, '/' );
|
||||
if ( p != NULL )
|
||||
execName = p + 1;
|
||||
|
||||
log_info( "Usage: %s [debug_trace] [small_images]\n", execName );
|
||||
log_info( "Where:\n" );
|
||||
log_info( "\t1D - Only test 1D images\n" );
|
||||
log_info( "\t2D - Only test 2D images\n" );
|
||||
log_info( "\t3D - Only test 3D images\n" );
|
||||
log_info( "\t1Darray - Only test 1D image arrays\n" );
|
||||
log_info( "\t2Darray - Only test 2D image arrays\n" );
|
||||
log_info( "\n" );
|
||||
log_info( "\tThe following flags specify the types to test. They can be combined; if none are specified, all are tested:\n" );
|
||||
log_info( "\t\tint - Test integer fill\n" );
|
||||
log_info( "\t\tuint - Test unsigned integer fill\n" );
|
||||
log_info( "\t\tfloat - Test float fill\n" );
|
||||
log_info( "\n" );
|
||||
log_info( "\tdebug_trace - Enables additional debug info logging\n" );
|
||||
log_info( "\tsmall_images - Runs every format through a loop of widths 1-13 and heights 1-9, instead of random sizes\n" );
|
||||
log_info( "\tmax_images - Runs every format through a set of size combinations with the max values, max values - 1, and max values / 128\n" );
|
||||
log_info( "\tuse_pitches - Enables row and slice pitches\n" );
|
||||
log_info( "You may also use appropriate CL_ channel type and ordering constants.\n" );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
cl_platform_id platform;
|
||||
cl_device_id device;
|
||||
cl_channel_type chanType;
|
||||
cl_channel_order chanOrder;
|
||||
char str[ 128 ];
|
||||
int testMethods = 0;
|
||||
bool randomize = false;
|
||||
|
||||
test_start();
|
||||
|
||||
checkDeviceTypeOverride( &gDeviceType );
|
||||
|
||||
// Parse arguments
|
||||
for ( int i = 1; i < argc; i++ )
|
||||
{
|
||||
strncpy( str, argv[ i ], sizeof( str ) - 1 );
|
||||
|
||||
if ( strcmp( str, "cpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_CPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_CPU;
|
||||
else if ( strcmp( str, "gpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_GPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
else if ( strcmp( str, "accelerator" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_ACCELERATOR" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_ACCELERATOR;
|
||||
else if ( strcmp( str, "CL_DEVICE_TYPE_DEFAULT" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
|
||||
else if ( strcmp( str, "debug_trace" ) == 0 )
|
||||
gDebugTrace = true;
|
||||
|
||||
else if ( strcmp( str, "small_images" ) == 0 )
|
||||
gTestSmallImages = true;
|
||||
else if ( strcmp( str, "max_images" ) == 0 )
|
||||
gTestMaxImages = true;
|
||||
|
||||
else if ( strcmp( str, "use_pitches" ) == 0 )
|
||||
gEnablePitch = true;
|
||||
|
||||
else if ( strcmp( str, "randomize" ) == 0 )
|
||||
randomize = true;
|
||||
|
||||
else if ( strcmp( str, "1D" ) == 0 )
|
||||
testMethods |= k1D;
|
||||
else if ( strcmp( str, "2D" ) == 0 )
|
||||
testMethods |= k2D;
|
||||
else if ( strcmp( str, "3D" ) == 0 )
|
||||
testMethods |= k3D;
|
||||
else if( strcmp( str, "1Darray" ) == 0 )
|
||||
testMethods |= k1DArray;
|
||||
else if( strcmp( str, "2Darray" ) == 0 )
|
||||
testMethods |= k2DArray;
|
||||
|
||||
else if( strcmp( str, "int" ) == 0 )
|
||||
gTypesToTest |= kTestInt;
|
||||
else if( strcmp( str, "uint" ) == 0 )
|
||||
gTypesToTest |= kTestUInt;
|
||||
else if( strcmp( str, "float" ) == 0 )
|
||||
gTypesToTest |= kTestFloat;
|
||||
|
||||
else if ( strcmp( str, "help" ) == 0 || strcmp( str, "?" ) == 0 )
|
||||
{
|
||||
printUsage( argv[ 0 ] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
else if ( ( chanType = get_channel_type_from_name( str ) ) != (cl_channel_type)-1 )
|
||||
gChannelTypeToUse = chanType;
|
||||
|
||||
else if ( ( chanOrder = get_channel_order_from_name( str ) ) != (cl_channel_order)-1 )
|
||||
gChannelOrderToUse = chanOrder;
|
||||
else
|
||||
{
|
||||
log_error( "ERROR: Unknown argument %d: %s. Exiting....\n", i, str );
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (testMethods == 0)
|
||||
testMethods = k1D | k2D | k3D | k1DArray | k2DArray;
|
||||
if ( gTypesToTest == 0 )
|
||||
gTypesToTest = kTestAllTypes;
|
||||
|
||||
// Seed the random # generators
|
||||
if ( randomize )
|
||||
{
|
||||
gRandomSeed = (cl_uint) clock();
|
||||
gReSeed = 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
// Get our platform
|
||||
error = clGetPlatformIDs(1, &platform, NULL);
|
||||
if ( error )
|
||||
{
|
||||
print_error( error, "Unable to get platform" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get our device
|
||||
error = clGetDeviceIDs(platform, gDeviceType, 1, &device, NULL );
|
||||
if ( error )
|
||||
{
|
||||
print_error( error, "Unable to get specified device" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
char deviceName[ 128 ], deviceVendor[ 128 ], deviceVersion[ 128 ];
|
||||
error = clGetDeviceInfo( device, CL_DEVICE_NAME, sizeof( deviceName ), deviceName, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VENDOR, sizeof( deviceVendor ), deviceVendor, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VERSION, sizeof( deviceVersion ), deviceVersion, NULL );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to get device information" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
log_info("Using compute device: Name = %s, Vendor = %s, Version = %s\n", deviceName, deviceVendor, deviceVersion );
|
||||
|
||||
// Check for image support
|
||||
if (checkForImageSupport( device ) == CL_IMAGE_FORMAT_NOT_SUPPORTED) {
|
||||
log_info("Device does not support images. Skipping test.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a context to test with
|
||||
context = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing context" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create a queue against the context
|
||||
queue = clCreateCommandQueue( context, device, 0, &error );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing command queue" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
log_info( "Note: Using small test images\n" );
|
||||
|
||||
// Run the test now
|
||||
int ret = 0;
|
||||
for ( int test = k1D; test <= k3D; test <<= 1 )
|
||||
{
|
||||
if ( testMethods & test )
|
||||
ret += test_image_set( device, (MethodsToTest)test );
|
||||
}
|
||||
|
||||
error = clFinish(queue);
|
||||
if (error)
|
||||
print_error(error, "clFinish failed.");
|
||||
|
||||
if (gTestFailure == 0) {
|
||||
if (gTestCount > 1)
|
||||
log_info("PASSED %d of %d tests.\n", gTestCount, gTestCount);
|
||||
else
|
||||
log_info("PASSED test.\n");
|
||||
}
|
||||
else if (gTestFailure > 0) {
|
||||
if (gTestCount > 1)
|
||||
log_error("FAILED %d of %d tests.\n", gTestFailure, gTestCount);
|
||||
else
|
||||
log_error("FAILED test.\n");
|
||||
}
|
||||
|
||||
// Clean up
|
||||
clReleaseCommandQueue(queue);
|
||||
clReleaseContext(context);
|
||||
test_finish();
|
||||
|
||||
if (gTestFailure > 0)
|
||||
return gTestFailure;
|
||||
|
||||
return ret;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "../testBase.h"
|
||||
|
||||
bool gDebugTrace = false, gTestSmallImages = false, gTestMaxImages = false, gTestRounding = false, gEnablePitch = false;
|
||||
int gTypesToTest = 0;
|
||||
cl_channel_type gChannelTypeToUse = (cl_channel_type)-1;
|
||||
cl_channel_order gChannelOrderToUse = (cl_channel_order)-1;
|
||||
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
cl_context context;
|
||||
cl_command_queue queue;
|
||||
|
||||
extern int test_image_set( cl_device_id device, MethodsToTest testMethod );
|
||||
|
||||
#define MAX_ALLOWED_STD_DEVIATION_IN_MB 8.0
|
||||
|
||||
void printUsage( const char *execName )
|
||||
{
|
||||
const char *p = strrchr( execName, '/' );
|
||||
if ( p != NULL )
|
||||
execName = p + 1;
|
||||
|
||||
log_info( "Usage: %s [debug_trace] [small_images]\n", execName );
|
||||
log_info( "Where:\n" );
|
||||
log_info( "\t1D - Only test 1D images\n" );
|
||||
log_info( "\t2D - Only test 2D images\n" );
|
||||
log_info( "\t3D - Only test 3D images\n" );
|
||||
log_info( "\t1Darray - Only test 1D image arrays\n" );
|
||||
log_info( "\t2Darray - Only test 2D image arrays\n" );
|
||||
log_info( "\n" );
|
||||
log_info( "\tThe following flags specify the types to test. They can be combined; if none are specified, all are tested:\n" );
|
||||
log_info( "\t\tint - Test integer fill\n" );
|
||||
log_info( "\t\tuint - Test unsigned integer fill\n" );
|
||||
log_info( "\t\tfloat - Test float fill\n" );
|
||||
log_info( "\n" );
|
||||
log_info( "\tdebug_trace - Enables additional debug info logging\n" );
|
||||
log_info( "\tsmall_images - Runs every format through a loop of widths 1-13 and heights 1-9, instead of random sizes\n" );
|
||||
log_info( "\tmax_images - Runs every format through a set of size combinations with the max values, max values - 1, and max values / 128\n" );
|
||||
log_info( "\tuse_pitches - Enables row and slice pitches\n" );
|
||||
log_info( "You may also use appropriate CL_ channel type and ordering constants.\n" );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
cl_platform_id platform;
|
||||
cl_device_id device;
|
||||
cl_channel_type chanType;
|
||||
cl_channel_order chanOrder;
|
||||
char str[ 128 ];
|
||||
int testMethods = 0;
|
||||
bool randomize = false;
|
||||
|
||||
test_start();
|
||||
|
||||
checkDeviceTypeOverride( &gDeviceType );
|
||||
|
||||
// Parse arguments
|
||||
for ( int i = 1; i < argc; i++ )
|
||||
{
|
||||
strncpy( str, argv[ i ], sizeof( str ) - 1 );
|
||||
|
||||
if ( strcmp( str, "cpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_CPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_CPU;
|
||||
else if ( strcmp( str, "gpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_GPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
else if ( strcmp( str, "accelerator" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_ACCELERATOR" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_ACCELERATOR;
|
||||
else if ( strcmp( str, "CL_DEVICE_TYPE_DEFAULT" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
|
||||
else if ( strcmp( str, "debug_trace" ) == 0 )
|
||||
gDebugTrace = true;
|
||||
|
||||
else if ( strcmp( str, "small_images" ) == 0 )
|
||||
gTestSmallImages = true;
|
||||
else if ( strcmp( str, "max_images" ) == 0 )
|
||||
gTestMaxImages = true;
|
||||
|
||||
else if ( strcmp( str, "use_pitches" ) == 0 )
|
||||
gEnablePitch = true;
|
||||
|
||||
else if ( strcmp( str, "randomize" ) == 0 )
|
||||
randomize = true;
|
||||
|
||||
else if ( strcmp( str, "1D" ) == 0 )
|
||||
testMethods |= k1D;
|
||||
else if ( strcmp( str, "2D" ) == 0 )
|
||||
testMethods |= k2D;
|
||||
else if ( strcmp( str, "3D" ) == 0 )
|
||||
testMethods |= k3D;
|
||||
else if( strcmp( str, "1Darray" ) == 0 )
|
||||
testMethods |= k1DArray;
|
||||
else if( strcmp( str, "2Darray" ) == 0 )
|
||||
testMethods |= k2DArray;
|
||||
|
||||
else if( strcmp( str, "int" ) == 0 )
|
||||
gTypesToTest |= kTestInt;
|
||||
else if( strcmp( str, "uint" ) == 0 )
|
||||
gTypesToTest |= kTestUInt;
|
||||
else if( strcmp( str, "float" ) == 0 )
|
||||
gTypesToTest |= kTestFloat;
|
||||
|
||||
else if ( strcmp( str, "help" ) == 0 || strcmp( str, "?" ) == 0 )
|
||||
{
|
||||
printUsage( argv[ 0 ] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
else if ( ( chanType = get_channel_type_from_name( str ) ) != (cl_channel_type)-1 )
|
||||
gChannelTypeToUse = chanType;
|
||||
|
||||
else if ( ( chanOrder = get_channel_order_from_name( str ) ) != (cl_channel_order)-1 )
|
||||
gChannelOrderToUse = chanOrder;
|
||||
else
|
||||
{
|
||||
log_error( "ERROR: Unknown argument %d: %s. Exiting....\n", i, str );
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (testMethods == 0)
|
||||
testMethods = k1D | k2D | k3D | k1DArray | k2DArray;
|
||||
if ( gTypesToTest == 0 )
|
||||
gTypesToTest = kTestAllTypes;
|
||||
|
||||
// Seed the random # generators
|
||||
if ( randomize )
|
||||
{
|
||||
gRandomSeed = (cl_uint) clock();
|
||||
gReSeed = 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
// Get our platform
|
||||
error = clGetPlatformIDs(1, &platform, NULL);
|
||||
if ( error )
|
||||
{
|
||||
print_error( error, "Unable to get platform" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get our device
|
||||
error = clGetDeviceIDs(platform, gDeviceType, 1, &device, NULL );
|
||||
if ( error )
|
||||
{
|
||||
print_error( error, "Unable to get specified device" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
char deviceName[ 128 ], deviceVendor[ 128 ], deviceVersion[ 128 ];
|
||||
error = clGetDeviceInfo( device, CL_DEVICE_NAME, sizeof( deviceName ), deviceName, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VENDOR, sizeof( deviceVendor ), deviceVendor, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VERSION, sizeof( deviceVersion ), deviceVersion, NULL );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to get device information" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
log_info("Using compute device: Name = %s, Vendor = %s, Version = %s\n", deviceName, deviceVendor, deviceVersion );
|
||||
|
||||
// Check for image support
|
||||
if (checkForImageSupport( device ) == CL_IMAGE_FORMAT_NOT_SUPPORTED) {
|
||||
log_info("Device does not support images. Skipping test.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a context to test with
|
||||
context = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing context" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create a queue against the context
|
||||
queue = clCreateCommandQueue( context, device, 0, &error );
|
||||
if ( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing command queue" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
log_info( "Note: Using small test images\n" );
|
||||
|
||||
// Run the test now
|
||||
int ret = 0;
|
||||
for ( int test = k1D; test <= k3D; test <<= 1 )
|
||||
{
|
||||
if ( testMethods & test )
|
||||
ret += test_image_set( device, (MethodsToTest)test );
|
||||
}
|
||||
|
||||
error = clFinish(queue);
|
||||
if (error)
|
||||
print_error(error, "clFinish failed.");
|
||||
|
||||
if (gTestFailure == 0) {
|
||||
if (gTestCount > 1)
|
||||
log_info("PASSED %d of %d tests.\n", gTestCount, gTestCount);
|
||||
else
|
||||
log_info("PASSED test.\n");
|
||||
}
|
||||
else if (gTestFailure > 0) {
|
||||
if (gTestCount > 1)
|
||||
log_error("FAILED %d of %d tests.\n", gTestFailure, gTestCount);
|
||||
else
|
||||
log_error("FAILED test.\n");
|
||||
}
|
||||
|
||||
// Clean up
|
||||
clReleaseCommandQueue(queue);
|
||||
clReleaseContext(context);
|
||||
test_finish();
|
||||
|
||||
if (gTestFailure > 0)
|
||||
return gTestFailure;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,173 +1,181 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_1D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = 1;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_1D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D size from device" );
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.height );
|
||||
|
||||
int ret = test_fill_image_size_1D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
log_info( "Testing %d\n", (int)sizes[ idx ][ 0 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d\n", (int)sizes[ idx ][ 0 ] );
|
||||
if ( test_fill_image_size_1D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d (row pitch %d) out of %d\n", (int)imageInfo.width, (int)imageInfo.rowPitch, (int)maxWidth );
|
||||
int ret = test_fill_image_size_1D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_1D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = 1;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_1D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = {0};
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding_default = 48;
|
||||
size_t rowPadding = gEnablePitch ? rowPadding_default : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.height );
|
||||
|
||||
int ret = test_fill_image_size_1D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
log_info( "Testing %d\n", (int)sizes[ idx ][ 0 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d\n", (int)sizes[ idx ][ 0 ] );
|
||||
if ( test_fill_image_size_1D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d (row pitch %d) out of %d\n", (int)imageInfo.width, (int)imageInfo.rowPitch, (int)maxWidth );
|
||||
int ret = test_fill_image_size_1D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,185 +1,193 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_1D_array( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->arraySize;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->arraySize > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - region[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_1D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 1D array size from device" );
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
for ( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize );
|
||||
|
||||
int ret = test_fill_image_size_1D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_ARRAY, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.arraySize = sizes[ idx ][ 2 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_size_1D_array( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.arraySize * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxArraySize );
|
||||
int ret = test_fill_image_size_1D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_1D_array( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->arraySize;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->arraySize > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - region[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_1D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = {0};
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding_default = 48;
|
||||
size_t rowPadding = gEnablePitch ? rowPadding_default : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 1D array size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
for ( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize );
|
||||
|
||||
int ret = test_fill_image_size_1D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_ARRAY, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.arraySize = sizes[ idx ][ 2 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_size_1D_array( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.arraySize * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxArraySize );
|
||||
int ret = test_fill_image_size_1D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,181 +1,189 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_2D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_2D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D size from device" );
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.height );
|
||||
|
||||
int ret = test_fill_image_size_2D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] );
|
||||
if ( test_fill_image_size_2D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.height * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxHeight );
|
||||
int ret = test_fill_image_size_2D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_size_2D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region fill
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = 1;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_2D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = {0};
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding_default = 48;
|
||||
size_t rowPadding = gEnablePitch ? rowPadding_default : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.height );
|
||||
|
||||
int ret = test_fill_image_size_2D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] );
|
||||
if ( test_fill_image_size_2D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.height * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxHeight );
|
||||
int ret = test_fill_image_size_2D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,192 +1,200 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
static int test_fill_image_2D_array( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = imageInfo->arraySize;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
region[ 2 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
origin[ 2 ] = ( imageInfo->arraySize > region[ 2 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - region[ 2 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_2D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo;
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D array size from device" );
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
for ( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize );
|
||||
int ret = test_fill_image_2D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D_ARRAY, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.arraySize = sizes[ idx ][ 2 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_2D_array( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 64, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 64, seed );
|
||||
imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32,seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.arraySize * 4 * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxArraySize );
|
||||
int ret = test_fill_image_2D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
static int test_fill_image_2D_array( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = imageInfo->arraySize;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
region[ 2 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
origin[ 2 ] = ( imageInfo->arraySize > region[ 2 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - region[ 2 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_2D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = {0};
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding_default = 80;
|
||||
size_t rowPadding = gEnablePitch ? rowPadding_default : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 2D array size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
for ( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize );
|
||||
int ret = test_fill_image_2D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D_ARRAY, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.arraySize = sizes[ idx ][ 2 ];
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_2D_array( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 64, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 64, seed );
|
||||
imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32,seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.arraySize * 4 * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxArraySize );
|
||||
int ret = test_fill_image_2D_array( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,192 +1,200 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_3D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = imageInfo->depth;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
region[ 2 ] = ( imageInfo->depth > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->depth - 1, d ) : imageInfo->depth;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
origin[ 2 ] = ( imageInfo->depth > region[ 2 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->depth - region[ 2 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_3D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo;
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE3D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 3D size from device" );
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
for ( imageInfo.depth = 2; imageInfo.depth < 9; imageInfo.depth++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth );
|
||||
int ret = test_fill_image_3D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, maxDepth, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE3D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.depth = sizes[ idx ][ 2 ];
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_3D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
imageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.depth * 4 * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxDepth );
|
||||
int ret = test_fill_image_3D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_fill_2D_3D.cpp
|
||||
extern int test_fill_image_generic( cl_device_id device, image_descriptor *imageInfo,
|
||||
const size_t origin[], const size_t region[], ExplicitType outputType, MTdata d );
|
||||
|
||||
|
||||
int test_fill_image_3D( cl_device_id device, image_descriptor *imageInfo, ExplicitType outputType, MTdata d )
|
||||
{
|
||||
size_t origin[ 3 ], region[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
origin[ 0 ] = origin[ 1 ] = origin[ 2 ] = 0;
|
||||
region[ 0 ] = imageInfo->width;
|
||||
region[ 1 ] = imageInfo->height;
|
||||
region[ 2 ] = imageInfo->depth;
|
||||
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
// Pick a random size
|
||||
region[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
region[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
region[ 2 ] = ( imageInfo->depth > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->depth - 1, d ) : imageInfo->depth;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
origin[ 0 ] = ( imageInfo->width > region[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - region[ 0 ] - 1 ), d ) : 0;
|
||||
origin[ 1 ] = ( imageInfo->height > region[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - region[ 1 ] - 1 ), d ) : 0;
|
||||
origin[ 2 ] = ( imageInfo->depth > region[ 2 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->depth - region[ 2 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_fill_image_generic( device, imageInfo, origin, region, outputType, d );
|
||||
if ( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_fill_image_set_3D( cl_device_id device, cl_image_format *format, ExplicitType outputType )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = {0};
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding_default = 80;
|
||||
size_t rowPadding = gEnablePitch ? rowPadding_default : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
memset(&imageInfo, 0x0, sizeof(image_descriptor));
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE3D;
|
||||
imageInfo.format = format;
|
||||
pixelSize = get_pixel_size( imageInfo.format );
|
||||
|
||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
||||
test_error( error, "Unable to get max image 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if ( gTestSmallImages )
|
||||
{
|
||||
for ( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for ( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
for ( imageInfo.depth = 2; imageInfo.depth < 9; imageInfo.depth++ )
|
||||
{
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth );
|
||||
int ret = test_fill_image_3D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, maxDepth, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE3D, imageInfo.format);
|
||||
|
||||
for ( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
imageInfo.width = sizes[ idx ][ 0 ];
|
||||
imageInfo.height = sizes[ idx ][ 1 ];
|
||||
imageInfo.depth = sizes[ idx ][ 2 ];
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( gDebugTrace )
|
||||
log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] );
|
||||
if ( test_fill_image_3D( device, &imageInfo, outputType, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
// Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
|
||||
// image, the result array, plus offset arrays, will fit in the global ram space
|
||||
do
|
||||
{
|
||||
imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
imageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32, seed );
|
||||
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
rowPadding = rowPadding_default;
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.depth * 4 * 4;
|
||||
} while ( size > maxAllocSize || ( size * 3 ) > memSize );
|
||||
|
||||
if ( gDebugTrace )
|
||||
log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxDepth );
|
||||
int ret = test_fill_image_3D( device, &imageInfo, outputType, seed );
|
||||
if ( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,327 +1,327 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
extern bool gDebugTrace;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern int gTypesToTest;
|
||||
extern int gNormalizedModeToUse;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_channel_order gChannelOrderToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
|
||||
extern int test_fill_image_set_1D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_2D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_3D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_1D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_2D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
|
||||
|
||||
int filter_formats( cl_image_format *formatList, bool *filterFlags, unsigned int formatCount, cl_channel_type *channelDataTypesToFilter )
|
||||
{
|
||||
int numSupported = 0;
|
||||
for ( unsigned int j = 0; j < formatCount; j++ )
|
||||
{
|
||||
// If this format has been previously filtered, remove the filter
|
||||
if ( filterFlags[ j ] )
|
||||
filterFlags[ j ] = false;
|
||||
|
||||
// Have we already discarded this via the command line?
|
||||
if ( gChannelTypeToUse != (cl_channel_type)-1 && gChannelTypeToUse != formatList[ j ].image_channel_data_type )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have we already discarded the channel order via the command line?
|
||||
if ( gChannelOrderToUse != (cl_channel_order)-1 && gChannelOrderToUse != formatList[ j ].image_channel_order )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is given format standard channel order and type given by spec. We don't want to test it if this is vendor extension
|
||||
if( !IsChannelOrderSupported( formatList[ j ].image_channel_order ) || !IsChannelTypeSupported( formatList[ j ].image_channel_data_type ) )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't filter by channel type
|
||||
if( !channelDataTypesToFilter )
|
||||
{
|
||||
numSupported++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the format supported?
|
||||
int i;
|
||||
for ( i = 0; channelDataTypesToFilter[ i ] != (cl_channel_type)-1; i++ )
|
||||
{
|
||||
if ( formatList[ j ].image_channel_data_type == channelDataTypesToFilter[ i ] )
|
||||
{
|
||||
numSupported++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( channelDataTypesToFilter[ i ] == (cl_channel_type)-1 )
|
||||
{
|
||||
// Format is NOT supported, so mark it as such
|
||||
filterFlags[ j ] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return numSupported;
|
||||
}
|
||||
|
||||
|
||||
int get_format_list( cl_device_id device, cl_mem_object_type image_type, cl_image_format * &outFormatList,
|
||||
unsigned int &outFormatCount, cl_mem_flags flags )
|
||||
{
|
||||
int error;
|
||||
|
||||
cl_image_format tempList[ 128 ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
image_type, 128, tempList, &outFormatCount );
|
||||
test_error( error, "Unable to get count of supported image formats" );
|
||||
|
||||
outFormatList = new cl_image_format[ outFormatCount ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
image_type, outFormatCount, outFormatList, NULL );
|
||||
test_error( error, "Unable to get list of supported image formats" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_image_type( cl_device_id device, MethodsToTest testMethod, cl_mem_flags flags )
|
||||
{
|
||||
const char *name;
|
||||
cl_mem_object_type imageType;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
{
|
||||
name = "1D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
else if ( testMethod == k2D )
|
||||
{
|
||||
name = "2D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D;
|
||||
}
|
||||
else if ( testMethod == k1DArray )
|
||||
{
|
||||
name = "1D Image Array Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
}
|
||||
else if ( testMethod == k2DArray )
|
||||
{
|
||||
name = "2D Image Array Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if ( testMethod == k3D )
|
||||
{
|
||||
name = "3D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
log_info( "Running %s tests...\n", name );
|
||||
|
||||
int ret = 0;
|
||||
|
||||
// Grab the list of supported image formats
|
||||
cl_image_format *formatList;
|
||||
bool *filterFlags;
|
||||
unsigned int numFormats;
|
||||
|
||||
if ( get_format_list( device, imageType, formatList, numFormats, flags ) )
|
||||
return -1;
|
||||
|
||||
filterFlags = new bool[ numFormats ];
|
||||
if ( filterFlags == NULL )
|
||||
{
|
||||
log_error( "ERROR: Out of memory allocating filter flags list!\n" );
|
||||
return -1;
|
||||
}
|
||||
memset( filterFlags, 0, sizeof( bool ) * numFormats );
|
||||
|
||||
/////// float tests ///////
|
||||
|
||||
if( gTypesToTest & kTestFloat )
|
||||
{
|
||||
cl_channel_type floatFormats[] = { CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010,
|
||||
#ifdef OBSOLETE_FORAMT
|
||||
CL_UNORM_SHORT_565_REV, CL_UNORM_SHORT_555_REV, CL_UNORM_INT_8888, CL_UNORM_INT_8888_REV, CL_UNORM_INT_101010_REV,
|
||||
#endif
|
||||
#ifdef CL_SFIXED14_APPLE
|
||||
CL_SFIXED14_APPLE,
|
||||
#endif
|
||||
CL_UNORM_INT8, CL_SNORM_INT8,
|
||||
CL_UNORM_INT16, CL_SNORM_INT16, CL_FLOAT, CL_HALF_FLOAT, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, floatFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for float type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kFloat );
|
||||
|
||||
if (test_return)
|
||||
{
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////// int tests ///////
|
||||
if( gTypesToTest & kTestInt )
|
||||
{
|
||||
cl_channel_type intFormats[] = { CL_SIGNED_INT8, CL_SIGNED_INT16, CL_SIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, intFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for integer type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kInt );
|
||||
|
||||
if (test_return) {
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////// uint tests ///////
|
||||
|
||||
if( gTypesToTest & kTestUInt )
|
||||
{
|
||||
cl_channel_type uintFormats[] = { CL_UNSIGNED_INT8, CL_UNSIGNED_INT16, CL_UNSIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, uintFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for unsigned int type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kUInt );
|
||||
|
||||
if (test_return) {
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete filterFlags;
|
||||
delete formatList;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_image_set( cl_device_id device, MethodsToTest testMethod )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret += test_image_type( device, testMethod, CL_MEM_READ_ONLY );
|
||||
|
||||
return ret;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
extern bool gDebugTrace;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern int gTypesToTest;
|
||||
extern int gNormalizedModeToUse;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_channel_order gChannelOrderToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
|
||||
extern int test_fill_image_set_1D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_2D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_3D( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_1D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
extern int test_fill_image_set_2D_array( cl_device_id device, cl_image_format *format, ExplicitType outputType );
|
||||
|
||||
|
||||
int filter_formats( cl_image_format *formatList, bool *filterFlags, unsigned int formatCount, cl_channel_type *channelDataTypesToFilter )
|
||||
{
|
||||
int numSupported = 0;
|
||||
for ( unsigned int j = 0; j < formatCount; j++ )
|
||||
{
|
||||
// If this format has been previously filtered, remove the filter
|
||||
if ( filterFlags[ j ] )
|
||||
filterFlags[ j ] = false;
|
||||
|
||||
// Have we already discarded this via the command line?
|
||||
if ( gChannelTypeToUse != (cl_channel_type)-1 && gChannelTypeToUse != formatList[ j ].image_channel_data_type )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have we already discarded the channel order via the command line?
|
||||
if ( gChannelOrderToUse != (cl_channel_order)-1 && gChannelOrderToUse != formatList[ j ].image_channel_order )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is given format standard channel order and type given by spec. We don't want to test it if this is vendor extension
|
||||
if( !IsChannelOrderSupported( formatList[ j ].image_channel_order ) || !IsChannelTypeSupported( formatList[ j ].image_channel_data_type ) )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't filter by channel type
|
||||
if( !channelDataTypesToFilter )
|
||||
{
|
||||
numSupported++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the format supported?
|
||||
int i;
|
||||
for ( i = 0; channelDataTypesToFilter[ i ] != (cl_channel_type)-1; i++ )
|
||||
{
|
||||
if ( formatList[ j ].image_channel_data_type == channelDataTypesToFilter[ i ] )
|
||||
{
|
||||
numSupported++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( channelDataTypesToFilter[ i ] == (cl_channel_type)-1 )
|
||||
{
|
||||
// Format is NOT supported, so mark it as such
|
||||
filterFlags[ j ] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return numSupported;
|
||||
}
|
||||
|
||||
|
||||
int get_format_list( cl_device_id device, cl_mem_object_type image_type, cl_image_format * &outFormatList,
|
||||
unsigned int &outFormatCount, cl_mem_flags flags )
|
||||
{
|
||||
int error;
|
||||
|
||||
cl_image_format tempList[ 128 ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
image_type, 128, tempList, &outFormatCount );
|
||||
test_error( error, "Unable to get count of supported image formats" );
|
||||
|
||||
outFormatList = new cl_image_format[ outFormatCount ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
image_type, outFormatCount, outFormatList, NULL );
|
||||
test_error( error, "Unable to get list of supported image formats" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_image_type( cl_device_id device, MethodsToTest testMethod, cl_mem_flags flags )
|
||||
{
|
||||
const char *name;
|
||||
cl_mem_object_type imageType;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
{
|
||||
name = "1D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
else if ( testMethod == k2D )
|
||||
{
|
||||
name = "2D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D;
|
||||
}
|
||||
else if ( testMethod == k1DArray )
|
||||
{
|
||||
name = "1D Image Array Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
}
|
||||
else if ( testMethod == k2DArray )
|
||||
{
|
||||
name = "2D Image Array Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if ( testMethod == k3D )
|
||||
{
|
||||
name = "3D Image Fill";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
log_info( "Running %s tests...\n", name );
|
||||
|
||||
int ret = 0;
|
||||
|
||||
// Grab the list of supported image formats
|
||||
cl_image_format *formatList;
|
||||
bool *filterFlags;
|
||||
unsigned int numFormats;
|
||||
|
||||
if ( get_format_list( device, imageType, formatList, numFormats, flags ) )
|
||||
return -1;
|
||||
|
||||
filterFlags = new bool[ numFormats ];
|
||||
if ( filterFlags == NULL )
|
||||
{
|
||||
log_error( "ERROR: Out of memory allocating filter flags list!\n" );
|
||||
return -1;
|
||||
}
|
||||
memset( filterFlags, 0, sizeof( bool ) * numFormats );
|
||||
|
||||
/////// float tests ///////
|
||||
|
||||
if( gTypesToTest & kTestFloat )
|
||||
{
|
||||
cl_channel_type floatFormats[] = { CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010,
|
||||
#ifdef OBSOLETE_FORAMT
|
||||
CL_UNORM_SHORT_565_REV, CL_UNORM_SHORT_555_REV, CL_UNORM_INT_8888, CL_UNORM_INT_8888_REV, CL_UNORM_INT_101010_REV,
|
||||
#endif
|
||||
#ifdef CL_SFIXED14_APPLE
|
||||
CL_SFIXED14_APPLE,
|
||||
#endif
|
||||
CL_UNORM_INT8, CL_SNORM_INT8,
|
||||
CL_UNORM_INT16, CL_SNORM_INT16, CL_FLOAT, CL_HALF_FLOAT, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, floatFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for float type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kFloat );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kFloat );
|
||||
|
||||
if (test_return)
|
||||
{
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////// int tests ///////
|
||||
if( gTypesToTest & kTestInt )
|
||||
{
|
||||
cl_channel_type intFormats[] = { CL_SIGNED_INT8, CL_SIGNED_INT16, CL_SIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, intFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for integer type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kInt );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kInt );
|
||||
|
||||
if (test_return) {
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////// uint tests ///////
|
||||
|
||||
if( gTypesToTest & kTestUInt )
|
||||
{
|
||||
cl_channel_type uintFormats[] = { CL_UNSIGNED_INT8, CL_UNSIGNED_INT16, CL_UNSIGNED_INT32, (cl_channel_type)-1 };
|
||||
if( filter_formats( formatList, filterFlags, numFormats, uintFormats ) == 0 )
|
||||
{
|
||||
log_info( "No formats supported for unsigned int type\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the format list
|
||||
for ( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if ( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if ( testMethod == k1D )
|
||||
test_return = test_fill_image_set_1D( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k2D )
|
||||
test_return = test_fill_image_set_2D( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k1DArray )
|
||||
test_return = test_fill_image_set_1D_array( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k2DArray )
|
||||
test_return = test_fill_image_set_2D_array( device, &formatList[ i ], kUInt );
|
||||
else if ( testMethod == k3D )
|
||||
test_return = test_fill_image_set_3D( device, &formatList[ i ], kUInt );
|
||||
|
||||
if (test_return) {
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete filterFlags;
|
||||
delete formatList;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_image_set( cl_device_id device, MethodsToTest testMethod )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret += test_image_type( device, testMethod, CL_MEM_READ_ONLY );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user