mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 07:39:01 +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_copy_images
|
||||
: main.cpp
|
||||
test_copy_2D_3D.cpp
|
||||
test_copy_2D.cpp
|
||||
test_copy_3D.cpp
|
||||
test_loops.cpp
|
||||
/images//image_helpers
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_cl_copy_images
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/images/clCopyImage
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/images/clCopyImage
|
||||
;
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_cl_copy_images
|
||||
: main.cpp
|
||||
test_copy_2D_3D.cpp
|
||||
test_copy_2D.cpp
|
||||
test_copy_3D.cpp
|
||||
test_loops.cpp
|
||||
/images//image_helpers
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_cl_copy_images
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/images/clCopyImage
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/images/clCopyImage
|
||||
;
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
test_copy_generic.cpp \
|
||||
test_copy_1D.cpp \
|
||||
test_copy_2D.cpp \
|
||||
../image_helpers.cpp \
|
||||
test_loops.cpp \
|
||||
test_copy_3D.cpp \
|
||||
test_copy_1D_array.cpp \
|
||||
test_copy_2D_array.cpp \
|
||||
test_copy_2D_3D.cpp \
|
||||
test_copy_2D_2D_array.cpp \
|
||||
test_copy_3D_2D_array.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.c \
|
||||
../../../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_copy_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_copy_generic.cpp \
|
||||
test_copy_1D.cpp \
|
||||
test_copy_2D.cpp \
|
||||
../image_helpers.cpp \
|
||||
test_loops.cpp \
|
||||
test_copy_3D.cpp \
|
||||
test_copy_1D_array.cpp \
|
||||
test_copy_2D_array.cpp \
|
||||
test_copy_2D_3D.cpp \
|
||||
test_copy_2D_2D_array.cpp \
|
||||
test_copy_3D_2D_array.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.c \
|
||||
../../../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_copy_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,262 +1,262 @@
|
||||
//
|
||||
// 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, gUseRamp = 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( "\t2Dto3D - Only test 2D -> 3D images\n" );
|
||||
log_info( "\t3Dto2D - Only test 3D -> 2D images\n" );
|
||||
log_info( "\t2Darrayto2D - Only test 2D image arrays -> 2D images\n" );
|
||||
log_info( "\t2Dto2Darray - Only test 2D images -> 2D image arrays\n" );
|
||||
log_info( "\t2Darrayto3D - Only test 2D image arrays -> 3D images\n" );
|
||||
log_info( "\t3Dto2Darray - Only test 3D images -> 2D image arrays\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( "\trounding - Runs every format through a single image filled with every possible value for that image format, to verify rounding works properly\n" );
|
||||
//log_info( "\tuse_pitches - Enables row and slice pitches\n" );
|
||||
log_info( "\tuse_ramp - Instead of random data, uses images filled with ramps (and 0xff on any padding pixels) to ease debugging\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_ramps" ) == 0 )
|
||||
gUseRamp = 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, "2Dto3D" ) == 0 )
|
||||
testMethods |= k2DTo3D;
|
||||
else if( strcmp( str, "3Dto2D" ) == 0 )
|
||||
testMethods |= k3DTo2D;
|
||||
else if( strcmp( str, "2Darrayto2D" ) == 0 )
|
||||
testMethods |= k2DArrayTo2D;
|
||||
else if( strcmp( str, "2Dto2Darray" ) == 0 )
|
||||
testMethods |= k2DTo2DArray;
|
||||
else if( strcmp( str, "2Darrayto3D" ) == 0 )
|
||||
testMethods |= k2DArrayTo3D;
|
||||
else if( strcmp( str, "3Dto2Darray" ) == 0 )
|
||||
testMethods |= k3DTo2DArray;
|
||||
|
||||
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 | k2DTo3D | k3DTo2D | k2DArrayTo2D | k2DTo2DArray | k2DArrayTo3D | k3DTo2DArray;
|
||||
|
||||
// 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 <= k3DTo2DArray; 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, gUseRamp = 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( "\t2Dto3D - Only test 2D -> 3D images\n" );
|
||||
log_info( "\t3Dto2D - Only test 3D -> 2D images\n" );
|
||||
log_info( "\t2Darrayto2D - Only test 2D image arrays -> 2D images\n" );
|
||||
log_info( "\t2Dto2Darray - Only test 2D images -> 2D image arrays\n" );
|
||||
log_info( "\t2Darrayto3D - Only test 2D image arrays -> 3D images\n" );
|
||||
log_info( "\t3Dto2Darray - Only test 3D images -> 2D image arrays\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( "\trounding - Runs every format through a single image filled with every possible value for that image format, to verify rounding works properly\n" );
|
||||
//log_info( "\tuse_pitches - Enables row and slice pitches\n" );
|
||||
log_info( "\tuse_ramp - Instead of random data, uses images filled with ramps (and 0xff on any padding pixels) to ease debugging\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_ramps" ) == 0 )
|
||||
gUseRamp = 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, "2Dto3D" ) == 0 )
|
||||
testMethods |= k2DTo3D;
|
||||
else if( strcmp( str, "3Dto2D" ) == 0 )
|
||||
testMethods |= k3DTo2D;
|
||||
else if( strcmp( str, "2Darrayto2D" ) == 0 )
|
||||
testMethods |= k2DArrayTo2D;
|
||||
else if( strcmp( str, "2Dto2Darray" ) == 0 )
|
||||
testMethods |= k2DTo2DArray;
|
||||
else if( strcmp( str, "2Darrayto3D" ) == 0 )
|
||||
testMethods |= k2DArrayTo3D;
|
||||
else if( strcmp( str, "3Dto2Darray" ) == 0 )
|
||||
testMethods |= k3DTo2DArray;
|
||||
|
||||
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 | k2DTo3D | k3DTo2D | k2DArrayTo2D | k2DTo2DArray | k2DArrayTo3D | k3DTo2DArray;
|
||||
|
||||
// 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 <= k3DTo2DArray; 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,179 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_1D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = 1;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.height = imageInfo.depth = imageInfo.arraySize = imageInfo.slicePitch = 0;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D;
|
||||
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\n", (int)imageInfo.width );
|
||||
|
||||
int ret = test_copy_image_size_1D( device, &imageInfo, 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_copy_image_size_1D( device, &imageInfo, 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_copy_image_size_1D( device, &imageInfo, 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_1D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = 1;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.height = imageInfo.depth = imageInfo.arraySize = imageInfo.slicePitch = 0;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D;
|
||||
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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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\n", (int)imageInfo.width );
|
||||
|
||||
int ret = test_copy_image_size_1D( device, &imageInfo, 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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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_copy_image_size_1D( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
// 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_copy_image_size_1D( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,185 +1,191 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_1D_array( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = imageInfo->arraySize;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
regionSize[ 1 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
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_copy_image_size_1D_array( device, &imageInfo, 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_copy_image_size_1D_array( device, &imageInfo, 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_copy_image_size_1D_array( device, &imageInfo, 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_1D_array( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = imageInfo->arraySize;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
regionSize[ 1 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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_copy_image_size_1D_array( device, &imageInfo, 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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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_copy_image_size_1D_array( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
// 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_copy_image_size_1D_array( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,181 +1,187 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_2D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = imageInfo->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
regionSize[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( imageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( imageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D;
|
||||
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_copy_image_size_2D( device, &imageInfo, 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_copy_image_size_2D( device, &imageInfo, 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_copy_image_size_2D( device, &imageInfo, 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;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_size_2D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = imageInfo->width;
|
||||
regionSize[ 1 ] = imageInfo->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = ( imageInfo->width > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->width - 1, d ) : imageInfo->width;
|
||||
regionSize[ 1 ] = ( imageInfo->height > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->height - 1, d ) : imageInfo->height;
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( imageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( imageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( imageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D;
|
||||
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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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_copy_image_size_2D( device, &imageInfo, 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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
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_copy_image_size_2D( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 48 : 0;
|
||||
// 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_copy_image_size_2D( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,273 +1,290 @@
|
||||
//
|
||||
// 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->arraySize = arraySize;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
} while ((imageInfo->rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
if (arraySize == 0)
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageInfo->slicePitch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->arraySize == 0 )
|
||||
// 2D to 2D array
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
else
|
||||
// 2D array to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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 size from device" );
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D_ARRAY, dstImageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, sizes[ idx ][ 0 ], sizes[ idx ][ 1 ], sizes[ idx ][ 2 ], rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, (size_t)random_in_range( (int)sizes[ idx ][ 0 ], (int)maxWidth/4, seed ), (size_t)random_in_range( (int)sizes[ idx ][ 1 ], (int)maxHeight/4, seed ), 0, rowPadding, slicePadding );
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( "Testing %d x %d x %d to %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at max size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
log_info("Not testing max size %d x %d x %d to %d x %d due to memory constraints.\n",
|
||||
(int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height);
|
||||
else
|
||||
log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->arraySize = arraySize;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
} while ((imageInfo->rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
if (arraySize == 0)
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageInfo->slicePitch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->arraySize == 0 )
|
||||
// 2D to 2D array
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
else
|
||||
// 2D array to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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 size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numberOfSizes2DArray, numberOfSizes2D;
|
||||
size_t sizes2DArray[100][3], sizes2D[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
|
||||
get_max_sizes(&numberOfSizes2DArray, 100, sizes2DArray, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D_ARRAY, dstImageInfo.format);
|
||||
get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, dstImageInfo.format);
|
||||
|
||||
for( size_t i = 0; i < numberOfSizes2D; i++ )
|
||||
{
|
||||
for( size_t j = 0; j < numberOfSizes2DArray; j++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
set_image_dimensions( &dstImageInfo, sizes2DArray[ j ][ 0 ], sizes2DArray[ j ][ 1 ], sizes2DArray[ j ][ 2 ], rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding );
|
||||
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
cl_ulong srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
|
||||
if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( "Testing %d x %d x %d to %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at max size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
log_info("Not testing max size %d x %d x %d to %d x %d due to memory constraints.\n",
|
||||
(int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height);
|
||||
else
|
||||
log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
|
||||
else
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,249 +1,266 @@
|
||||
//
|
||||
// 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
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);
|
||||
|
||||
if (depth == 0)
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
|
||||
else
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_3D( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->depth > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->depth == 0 )
|
||||
// 2D to 3D
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
else
|
||||
// 3D to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, max3DDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( max3DDepth ), &max3DDepth, 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 or 3D size from device" );
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.depth = 4; dstImageInfo.depth < 9; dstImageInfo.depth++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes, max3DWidth, max3DHeight, max3DDepth, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, sizes[ idx ][ 0 ], sizes[ idx ][ 1 ], sizes[ idx ][ 2 ], rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, (size_t)random_in_range( (int)sizes[ idx ][ 0 ], (int)maxWidth/4, seed ), (size_t)random_in_range( (int)sizes[ idx ][ 1 ], (int)maxHeight/4, seed ), 0, rowPadding, slicePadding );
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4;
|
||||
if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) )
|
||||
{
|
||||
log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
if( gDebugTrace )
|
||||
log_info( " at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed );
|
||||
dstImageInfo.depth = (size_t)random_log_in_range( 16, (int)max3DDepth / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
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);
|
||||
|
||||
if (depth == 0)
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
|
||||
else
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_3D( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->depth > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->depth == 0 )
|
||||
// 2D to 3D
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
else
|
||||
// 3D to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, max3DDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( max3DDepth ), &max3DDepth, 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 or 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.depth = 4; dstImageInfo.depth < 9; dstImageInfo.depth++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numberOfSizes3D, numberOfSizes2D;
|
||||
size_t sizes3D[100][3], sizes2D[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
|
||||
get_max_sizes(&numberOfSizes3D, 100, sizes3D, max3DWidth, max3DHeight, max3DDepth, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format);
|
||||
get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, srcImageInfo.format);
|
||||
|
||||
for( size_t i = 0; i < numberOfSizes2D; i++ )
|
||||
for( size_t j = 0; j < numberOfSizes3D; j++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
|
||||
set_image_dimensions( &dstImageInfo, sizes3D[ j ][ 0 ], sizes3D[ j ][ 1 ], sizes3D[ j ][ 2 ], rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding );
|
||||
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4;
|
||||
cl_ulong srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
|
||||
if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) )
|
||||
{
|
||||
log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
if( gDebugTrace )
|
||||
log_info( " at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed );
|
||||
dstImageInfo.depth = (size_t)random_log_in_range( 16, (int)max3DDepth / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
log_info( " at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,156 +1,167 @@
|
||||
//
|
||||
// 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_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_2D_array( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t origin[] = { 0, 0, 0 };
|
||||
size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->arraySize };
|
||||
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, origin, origin, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
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_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_copy_image_2D_array( device, &imageInfo, 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, imageInfo.type, 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.height * (imageInfo.rowPitch + 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_copy_image_2D_array( device, &imageInfo, 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.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_copy_image_2D_array( device, &imageInfo,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_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_2D_array( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t origin[] = { 0, 0, 0 };
|
||||
size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->arraySize };
|
||||
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, origin, origin, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
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_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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
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_copy_image_2D_array( device, &imageInfo, 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, imageInfo.type, imageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
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_copy_image_2D_array( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
// 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.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_copy_image_2D_array( device, &imageInfo,seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,155 +1,166 @@
|
||||
//
|
||||
// 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_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_3D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t origin[] = { 0, 0, 0 };
|
||||
size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->depth };
|
||||
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, origin, origin, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_3D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE3D;
|
||||
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_copy_image_3D( device, &imageInfo, 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, imageInfo.type, 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.height * (imageInfo.rowPitch + 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_copy_image_3D( device, &imageInfo, 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_copy_image_3D( device, &imageInfo,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_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
int test_copy_image_3D( cl_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t origin[] = { 0, 0, 0 };
|
||||
size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->depth };
|
||||
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, origin, origin, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_3D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE3D;
|
||||
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++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
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_copy_image_3D( device, &imageInfo, 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, imageInfo.type, imageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
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_copy_image_3D( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
// 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_copy_image_3D( device, &imageInfo,seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,293 +1,297 @@
|
||||
//
|
||||
// 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
imageInfo->arraySize = arraySize;
|
||||
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);
|
||||
|
||||
if (arraySize == 0)
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE3D;
|
||||
else
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_3D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D )
|
||||
{
|
||||
// 3D to 2D array
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2D array to 3D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
if (srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d );
|
||||
else
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d );
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d );
|
||||
else
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d );
|
||||
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, maxDepth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, 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 2D image array or 3D size from device" );
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes3D[100][3];
|
||||
size_t sizes2Darray[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 3D ones as well for the copy.
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes2Darray, maxWidth, maxHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, srcImageInfo.format);
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes3D, max3DWidth, max3DHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
set_image_dimensions( &srcImageInfo, sizes3D[ idx ][ 0 ], sizes3D[ idx ][ 1 ], sizes3D[ idx ][ 2 ], 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, sizes2Darray[ idx ][ 0 ], sizes2Darray[ idx ][ 1 ], 0, sizes2Darray[ idx ][ 2 ], rowPadding, slicePadding );
|
||||
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize;
|
||||
cl_ulong srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth;
|
||||
|
||||
if ( ( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) ) &&
|
||||
( srcSize < maxAllocSize && srcSize < ( memSize / 3 ) ) )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
log_info("Not testing max size %d x %d x %d x %d to %d x %d due to memory constraints.\n",
|
||||
(int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth);
|
||||
else
|
||||
log_info("Not testing max size %d x %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed );
|
||||
srcImageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, 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, gTestRounding, gEnablePitch;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
imageInfo->arraySize = arraySize;
|
||||
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);
|
||||
|
||||
if (arraySize == 0)
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE3D;
|
||||
else
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_3D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D )
|
||||
{
|
||||
// 3D to 2D array
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2D array to 3D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, 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
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
if (srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d );
|
||||
else
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d );
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d );
|
||||
else
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d );
|
||||
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, maxDepth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, 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 2D image array or 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ )
|
||||
{
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, 0, rowPadding, slicePadding );
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes3D[100][3];
|
||||
size_t sizes2Darray[100][3];
|
||||
|
||||
// Try to allocate a bit smaller images because we need the 3D ones as well for the copy.
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes2Darray, maxWidth, maxHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, srcImageInfo.format);
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes3D, max3DWidth, max3DHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format);
|
||||
|
||||
for( size_t idx = 0; idx < numbeOfSizes; idx++ )
|
||||
{
|
||||
set_image_dimensions( &srcImageInfo, sizes3D[ idx ][ 0 ], sizes3D[ idx ][ 1 ], sizes3D[ idx ][ 2 ], 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, sizes2Darray[ idx ][ 0 ], sizes2Darray[ idx ][ 1 ], 0, sizes2Darray[ idx ][ 2 ], rowPadding, slicePadding );
|
||||
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize;
|
||||
cl_ulong srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth;
|
||||
|
||||
if ( ( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) ) &&
|
||||
( srcSize < maxAllocSize && srcSize < ( memSize / 3 ) ) )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
log_info("Not testing max size %d x %d x %d x %d to %d x %d due to memory constraints.\n",
|
||||
(int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth);
|
||||
else
|
||||
log_info("Not testing max size %d x %d x %d to %d x %d x %d due to memory constraints.\n",
|
||||
(int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
// 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
|
||||
{
|
||||
dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
|
||||
dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
|
||||
dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
srcImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed );
|
||||
srcImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed );
|
||||
srcImageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32, seed );
|
||||
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
|
||||
} while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
|
||||
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if (reverse)
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth );
|
||||
else
|
||||
log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,259 +1,259 @@
|
||||
//
|
||||
// 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 cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern int gTypesToTest;
|
||||
extern int gNormalizedModeToUse;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_channel_order gChannelOrderToUse;
|
||||
|
||||
|
||||
extern bool gDebugTrace;
|
||||
|
||||
extern int test_copy_image_set_1D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_3D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
|
||||
|
||||
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 imageType, 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,
|
||||
imageType, 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,
|
||||
imageType, 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 -> 1D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
else if( testMethod == k2D )
|
||||
{
|
||||
name = "2D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D;
|
||||
}
|
||||
else if( testMethod == k3D )
|
||||
{
|
||||
name = "3D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k1DArray )
|
||||
{
|
||||
name = "1D array -> 1D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArray )
|
||||
{
|
||||
name = "2D array -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo3D )
|
||||
{
|
||||
name = "2D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2D )
|
||||
{
|
||||
name = "3D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo2D )
|
||||
{
|
||||
name = "2D array -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo2DArray )
|
||||
{
|
||||
name = "2D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo3D )
|
||||
{
|
||||
name = "2D array -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2DArray )
|
||||
{
|
||||
name = "3D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
log_info( "Running %s tests...\n", name );
|
||||
|
||||
int ret = 0;
|
||||
|
||||
// Grab the list of supported image formats for integer reads
|
||||
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 );
|
||||
|
||||
filter_formats(formatList, filterFlags, numFormats, NULL);
|
||||
|
||||
// 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_copy_image_set_1D( device, &formatList[ i ] );
|
||||
else if( testMethod == k2D )
|
||||
test_return = test_copy_image_set_2D( device, &formatList[ i ] );
|
||||
else if( testMethod == k3D )
|
||||
test_return = test_copy_image_set_3D( device, &formatList[ i ] );
|
||||
else if( testMethod == k1DArray )
|
||||
test_return = test_copy_image_set_1D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DArray )
|
||||
test_return = test_copy_image_set_2D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DTo3D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], false );
|
||||
else if( testMethod == k3DTo2D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], true );
|
||||
else if( testMethod == k2DArrayTo2D)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k2DTo2DArray)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], false);
|
||||
else if( testMethod == k2DArrayTo3D)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k3DTo2DArray)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], false);
|
||||
|
||||
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 cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern int gTypesToTest;
|
||||
extern int gNormalizedModeToUse;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_channel_order gChannelOrderToUse;
|
||||
|
||||
|
||||
extern bool gDebugTrace;
|
||||
|
||||
extern int test_copy_image_set_1D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_3D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
|
||||
|
||||
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 imageType, 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,
|
||||
imageType, 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,
|
||||
imageType, 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 -> 1D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
else if( testMethod == k2D )
|
||||
{
|
||||
name = "2D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D;
|
||||
}
|
||||
else if( testMethod == k3D )
|
||||
{
|
||||
name = "3D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k1DArray )
|
||||
{
|
||||
name = "1D array -> 1D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArray )
|
||||
{
|
||||
name = "2D array -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo3D )
|
||||
{
|
||||
name = "2D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2D )
|
||||
{
|
||||
name = "3D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo2D )
|
||||
{
|
||||
name = "2D array -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo2DArray )
|
||||
{
|
||||
name = "2D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo3D )
|
||||
{
|
||||
name = "2D array -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2DArray )
|
||||
{
|
||||
name = "3D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
log_info( "Running %s tests...\n", name );
|
||||
|
||||
int ret = 0;
|
||||
|
||||
// Grab the list of supported image formats for integer reads
|
||||
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 );
|
||||
|
||||
filter_formats(formatList, filterFlags, numFormats, NULL);
|
||||
|
||||
// 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_copy_image_set_1D( device, &formatList[ i ] );
|
||||
else if( testMethod == k2D )
|
||||
test_return = test_copy_image_set_2D( device, &formatList[ i ] );
|
||||
else if( testMethod == k3D )
|
||||
test_return = test_copy_image_set_3D( device, &formatList[ i ] );
|
||||
else if( testMethod == k1DArray )
|
||||
test_return = test_copy_image_set_1D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DArray )
|
||||
test_return = test_copy_image_set_2D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DTo3D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], false );
|
||||
else if( testMethod == k3DTo2D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], true );
|
||||
else if( testMethod == k2DArrayTo2D)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k2DTo2DArray)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], false);
|
||||
else if( testMethod == k2DArrayTo3D)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k3DTo2DArray)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], false);
|
||||
|
||||
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