mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Merge branch 'main' into cl_khr_unified_svm
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +0,0 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
set(HARNESS_SOURCES
|
||||
harness/alloc.cpp
|
||||
harness/typeWrappers.cpp
|
||||
harness/mt19937.cpp
|
||||
harness/conversions.cpp
|
||||
|
||||
121
test_common/harness/alloc.cpp
Normal file
121
test_common/harness/alloc.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// Copyright (c) 2024 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 "alloc.h"
|
||||
#include "errorHelpers.h"
|
||||
#include "testHarness.h"
|
||||
|
||||
#if defined(linux) || defined(__linux__) || defined(__ANDROID__)
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
|
||||
#include <linux/dma-heap.h>
|
||||
|
||||
struct dma_buf_heap_helper_t
|
||||
{
|
||||
dma_buf_heap_type heap_type;
|
||||
const char* env_var = nullptr;
|
||||
const char* default_path = nullptr;
|
||||
|
||||
constexpr dma_buf_heap_helper_t(dma_buf_heap_type heap_type,
|
||||
const char* env_var,
|
||||
const char* default_path)
|
||||
: heap_type(heap_type), env_var(env_var), default_path(default_path)
|
||||
{}
|
||||
};
|
||||
|
||||
constexpr dma_buf_heap_helper_t DMA_BUF_HEAP_TABLE[] = {
|
||||
{ dma_buf_heap_type::SYSTEM, "OCL_CTS_DMA_HEAP_PATH_SYSTEM",
|
||||
"/dev/dma_heap/system" },
|
||||
};
|
||||
|
||||
static dma_buf_heap_helper_t lookup_dma_heap(dma_buf_heap_type heap_type)
|
||||
{
|
||||
for (const auto& entry : DMA_BUF_HEAP_TABLE)
|
||||
{
|
||||
if (heap_type == entry.heap_type)
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false
|
||||
&& "DMA heap type does not have an entry in DMA_BUF_HEAP_TABLE");
|
||||
return DMA_BUF_HEAP_TABLE[0];
|
||||
}
|
||||
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
|
||||
|
||||
int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
|
||||
constexpr int DMA_HEAP_FLAGS = O_RDWR | O_CLOEXEC;
|
||||
|
||||
const auto entry = lookup_dma_heap(heap_type);
|
||||
const auto override_path = getenv(entry.env_var);
|
||||
const auto dma_heap_path =
|
||||
(override_path == nullptr) ? entry.default_path : override_path;
|
||||
|
||||
const int dma_heap_fd = open(dma_heap_path, DMA_HEAP_FLAGS);
|
||||
if (dma_heap_fd == -1)
|
||||
{
|
||||
log_error(
|
||||
"Opening the DMA heap device: %s failed with error: %d (%s)\n",
|
||||
dma_heap_path, errno, strerror(errno));
|
||||
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
dma_heap_allocation_data dma_heap_data = { 0 };
|
||||
dma_heap_data.len = size;
|
||||
dma_heap_data.fd_flags = O_RDWR | O_CLOEXEC;
|
||||
|
||||
int result = ioctl(dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &dma_heap_data);
|
||||
if (result != 0)
|
||||
{
|
||||
log_error("DMA heap allocation IOCTL call failed, error: %d\n", result);
|
||||
|
||||
close(dma_heap_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = close(dma_heap_fd);
|
||||
if (result == -1)
|
||||
{
|
||||
log_info("Failed to close the DMA heap device: %s\n", dma_heap_path);
|
||||
}
|
||||
|
||||
return dma_heap_data.fd;
|
||||
#else
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
|
||||
}
|
||||
|
||||
#else
|
||||
int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type)
|
||||
{
|
||||
log_error(
|
||||
"OS doesn't have DMA buffer heaps (only Linux and Android do).\n");
|
||||
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
#endif // defined(linux) || defined(__linux__) || defined(__ANDROID__)
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
// Copyright (c) 2020 - 2024 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.
|
||||
@@ -24,11 +24,16 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#include "mingw_compat.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
inline void* align_malloc(size_t size, size_t alignment)
|
||||
{
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
@@ -66,4 +71,36 @@ inline void align_free(void* ptr)
|
||||
#endif
|
||||
}
|
||||
|
||||
enum class dma_buf_heap_type
|
||||
{
|
||||
SYSTEM
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Allocate a DMA buffer.
|
||||
*
|
||||
* On systems that support it, use the DMA buffer heaps to allocate a DMA buffer
|
||||
* of the requested size, using the requested heap type. The heap type defaults
|
||||
* to using the system heap if no type is specified.
|
||||
*
|
||||
* A heap type will use a default path if one exists, and can be overriden using
|
||||
* an environment variable for each type, as follows:
|
||||
*
|
||||
* SYSTEM:
|
||||
* * Default path: /dev/dma_heap/system
|
||||
* * Environment variable: OCL_CTS_DMA_HEAP_PATH_SYSTEM
|
||||
*
|
||||
* DMA buffer heaps require a minimum Linux kernel version 5.6. A compile-time
|
||||
* warning is issued on older systems, as well as an error message at runtime.
|
||||
*
|
||||
* @param size [in] The requested buffer size in bytes.
|
||||
* @param heap_type [in,opt] The heap type to use for the allocation.
|
||||
*
|
||||
* @retrun A file descriptor representing the allocated DMA buffer on success,
|
||||
* -1 otherwise. Failure to open the DMA device returns TEST_SKIPPED_ITSELF so
|
||||
* it can be handled separately to other failures.
|
||||
*/
|
||||
int allocate_dma_buf(uint64_t size,
|
||||
dma_buf_heap_type heap_type = dma_buf_heap_type::SYSTEM);
|
||||
|
||||
#endif // #ifndef HARNESS_ALLOC_H_
|
||||
|
||||
@@ -555,6 +555,39 @@ float Ulp_Error_Double(double test, long double reference)
|
||||
return result;
|
||||
}
|
||||
|
||||
cl_int OutputBuildLog(cl_program program, const cl_device_id device)
|
||||
{
|
||||
size_t size_ret;
|
||||
|
||||
// Get the build status
|
||||
cl_build_status build_status;
|
||||
cl_int error =
|
||||
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS,
|
||||
sizeof(build_status), &build_status, &size_ret);
|
||||
test_error(error, "Unable to query build status");
|
||||
|
||||
// If the build failed then print the status, obtain the build log and
|
||||
// print it.
|
||||
if (build_status != CL_BUILD_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n", (int)build_status);
|
||||
error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0,
|
||||
nullptr, &size_ret);
|
||||
test_error(error, "Unable to query build log size");
|
||||
|
||||
char *build_log = (char *)malloc(size_ret);
|
||||
error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
|
||||
size_ret, build_log, &size_ret);
|
||||
test_error(error, "Unable to query build log");
|
||||
|
||||
log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log);
|
||||
|
||||
free(build_log);
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
|
||||
cl_device_id *device_list)
|
||||
{
|
||||
@@ -594,33 +627,8 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
|
||||
unsigned int i;
|
||||
for (i = 0; i < num_devices; i++)
|
||||
{
|
||||
|
||||
// Get the build status
|
||||
cl_build_status build_status;
|
||||
error = clGetProgramBuildInfo(
|
||||
program, device_list[i], CL_PROGRAM_BUILD_STATUS,
|
||||
sizeof(build_status), &build_status, &size_ret);
|
||||
test_error(error, "Unable to query build status");
|
||||
|
||||
// If the build failed then log the status, and allocate the build
|
||||
// log, log it and free it
|
||||
if (build_status != CL_BUILD_SUCCESS)
|
||||
{
|
||||
|
||||
log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n",
|
||||
(int)build_status);
|
||||
error = clGetProgramBuildInfo(program, device_list[i],
|
||||
CL_PROGRAM_BUILD_LOG, 0, NULL,
|
||||
&size_ret);
|
||||
test_error(error, "Unable to query build log size");
|
||||
char *build_log = (char *)malloc(size_ret);
|
||||
error = clGetProgramBuildInfo(program, device_list[i],
|
||||
CL_PROGRAM_BUILD_LOG, size_ret,
|
||||
build_log, &size_ret);
|
||||
test_error(error, "Unable to query build log");
|
||||
log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log);
|
||||
free(build_log);
|
||||
}
|
||||
error = OutputBuildLog(program, device_list[i]);
|
||||
test_error(error, "OutputBuildLog failed");
|
||||
}
|
||||
|
||||
// Was the number of devices given
|
||||
|
||||
@@ -198,6 +198,7 @@ extern const char *GetQueuePropertyName(cl_command_queue_properties properties);
|
||||
|
||||
extern const char *GetDeviceTypeName(cl_device_type type);
|
||||
bool check_functions_for_offline_compiler(const char *subtestname);
|
||||
cl_int OutputBuildLog(cl_program program, const cl_device_id device);
|
||||
cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
|
||||
cl_device_id *device_list);
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ template <typename T> T *register_test(const char *name, Version version)
|
||||
#define REQUIRE_EXTENSION(name) \
|
||||
do \
|
||||
{ \
|
||||
if (!is_extension_available(deviceID, name)) \
|
||||
if (!is_extension_available(device, name)) \
|
||||
{ \
|
||||
log_info(name \
|
||||
" is not supported on this device. Skipping test.\n"); \
|
||||
|
||||
@@ -7,3 +7,8 @@ add_executable(${${MODULE_NAME}_OUT} ${${MODULE_NAME}_SOURCES})
|
||||
set_property(TARGET ${${MODULE_NAME}_OUT} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}")
|
||||
|
||||
TARGET_LINK_LIBRARIES(${${MODULE_NAME}_OUT} ${HARNESS_LIB} ${CLConform_LIBRARIES})
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(TARGETS ${${MODULE_NAME}_OUT}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/$<CONFIG>)
|
||||
|
||||
@@ -27,4 +27,24 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// scope guard helper to ensure proper releasing of sub devices
|
||||
struct SubDevicesScopeGuarded
|
||||
{
|
||||
SubDevicesScopeGuarded(const cl_int dev_count)
|
||||
{
|
||||
sub_devices.resize(dev_count);
|
||||
}
|
||||
~SubDevicesScopeGuarded()
|
||||
{
|
||||
for (auto &device : sub_devices)
|
||||
{
|
||||
cl_int err = clReleaseDevice(device);
|
||||
if (err != CL_SUCCESS)
|
||||
log_error("\n Releasing sub-device failed \n");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cl_device_id> sub_devices;
|
||||
};
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
#include "harness/propertyHelpers.h"
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
REGISTER_TEST(get_platform_info)
|
||||
@@ -476,18 +478,41 @@ REGISTER_TEST(get_command_queue_info_compatibility)
|
||||
REGISTER_TEST(get_context_info)
|
||||
{
|
||||
int error;
|
||||
|
||||
// query single device context and perform object comparability test
|
||||
cl_uint num_devices = 0;
|
||||
error = clGetContextInfo(context, CL_CONTEXT_NUM_DEVICES, sizeof(cl_uint),
|
||||
&num_devices, nullptr);
|
||||
test_error(error, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n");
|
||||
|
||||
test_assert_error(num_devices == 1,
|
||||
"Context must contain exactly one device\n");
|
||||
|
||||
cl_device_id comp_device = nullptr;
|
||||
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(cl_device_id),
|
||||
&comp_device, nullptr);
|
||||
test_error(error, "clGetContextInfo CL_CONTEXT_DEVICES failed\n");
|
||||
|
||||
test_assert_error(device == comp_device,
|
||||
"Unexpected result returned by CL_CONTEXT_DEVICES query");
|
||||
|
||||
// query context properties against valid size
|
||||
size_t size;
|
||||
cl_context_properties props;
|
||||
error = clGetContextInfo(context, CL_CONTEXT_PROPERTIES, sizeof(props),
|
||||
&props, &size);
|
||||
test_error(error, "Unable to get context props");
|
||||
|
||||
error = clGetContextInfo( context, CL_CONTEXT_PROPERTIES, sizeof( props ), &props, &size );
|
||||
test_error( error, "Unable to get context props" );
|
||||
|
||||
if (size == 0) {
|
||||
if (size == 0)
|
||||
{
|
||||
// Valid size
|
||||
return 0;
|
||||
} else if (size == sizeof(cl_context_properties)) {
|
||||
}
|
||||
else if (size == sizeof(cl_context_properties))
|
||||
{
|
||||
// Data must be NULL
|
||||
if (props != 0) {
|
||||
if (props != 0)
|
||||
{
|
||||
log_error("ERROR: Returned properties is no NULL.\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -495,11 +520,126 @@ REGISTER_TEST(get_context_info)
|
||||
return 0;
|
||||
}
|
||||
// Size was not 0 or 1
|
||||
log_error( "ERROR: Returned size of context props is not valid! (expected 0 or %d, got %d)\n",
|
||||
(int)sizeof(cl_context_properties), (int)size );
|
||||
log_error("ERROR: Returned size of context props is not valid! (expected 0 "
|
||||
"or %d, got %d)\n",
|
||||
(int)sizeof(cl_context_properties), (int)size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
REGISTER_TEST(get_context_info_mult_devices)
|
||||
{
|
||||
cl_int err = CL_SUCCESS;
|
||||
size_t size = 0;
|
||||
|
||||
// query multi-device context and perform objects comparability test
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES, 0, nullptr,
|
||||
&size);
|
||||
test_error_fail(err, "clGetDeviceInfo failed");
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
std::vector<cl_device_partition_property> supported_props(
|
||||
size / sizeof(cl_device_partition_property), 0);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES,
|
||||
supported_props.size()
|
||||
* sizeof(cl_device_partition_property),
|
||||
supported_props.data(), &size);
|
||||
test_error_fail(err, "clGetDeviceInfo failed");
|
||||
|
||||
if (supported_props.empty() || supported_props.front() == 0)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
cl_uint maxComputeUnits = 0;
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
sizeof(maxComputeUnits), &maxComputeUnits, NULL);
|
||||
test_error_fail(err, "Unable to get maximal number of compute units");
|
||||
|
||||
std::vector<std::array<cl_device_partition_property, 5>> partition_props = {
|
||||
{ CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 },
|
||||
{ CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1,
|
||||
CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 },
|
||||
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
|
||||
CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 }
|
||||
};
|
||||
|
||||
std::unique_ptr<SubDevicesScopeGuarded> scope_guard;
|
||||
cl_uint num_devices = 0;
|
||||
for (auto &sup_prop : supported_props)
|
||||
{
|
||||
for (auto &prop : partition_props)
|
||||
{
|
||||
if (sup_prop == prop[0])
|
||||
{
|
||||
// how many sub-devices can we create?
|
||||
err = clCreateSubDevices(device, prop.data(), 0, nullptr,
|
||||
&num_devices);
|
||||
test_error_fail(err, "clCreateSubDevices failed");
|
||||
if (num_devices < 2) continue;
|
||||
|
||||
// get the list of subDevices
|
||||
scope_guard.reset(new SubDevicesScopeGuarded(num_devices));
|
||||
err = clCreateSubDevices(device, prop.data(), num_devices,
|
||||
scope_guard->sub_devices.data(),
|
||||
&num_devices);
|
||||
test_error_fail(err, "clCreateSubDevices failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scope_guard.get() != nullptr) break;
|
||||
}
|
||||
|
||||
if (scope_guard.get() == nullptr)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
/* Create a multi device context */
|
||||
clContextWrapper multi_device_context = clCreateContext(
|
||||
NULL, (cl_uint)num_devices, scope_guard->sub_devices.data(), nullptr,
|
||||
nullptr, &err);
|
||||
test_error_fail(err, "Unable to create testing context");
|
||||
|
||||
err = clGetContextInfo(multi_device_context, CL_CONTEXT_NUM_DEVICES,
|
||||
sizeof(cl_uint), &num_devices, nullptr);
|
||||
test_error_fail(err, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n");
|
||||
|
||||
test_assert_error(num_devices == scope_guard->sub_devices.size(),
|
||||
"Context must contain exact number of devices\n");
|
||||
|
||||
std::vector<cl_device_id> devices(num_devices);
|
||||
err = clGetContextInfo(multi_device_context, CL_CONTEXT_DEVICES,
|
||||
num_devices * sizeof(cl_device_id), devices.data(),
|
||||
nullptr);
|
||||
test_error_fail(err, "clGetContextInfo CL_CONTEXT_DEVICES failed\n");
|
||||
|
||||
test_assert_error(devices.size() == scope_guard->sub_devices.size(),
|
||||
"Size of devices arrays must be in sync\n");
|
||||
|
||||
for (cl_uint i = 0; i < devices.size(); i++)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto &it : scope_guard->sub_devices)
|
||||
{
|
||||
if (it == devices[i])
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
test_error_fail(
|
||||
!found, "Unexpected result returned by CL_CONTEXT_DEVICES query");
|
||||
}
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
void CL_CALLBACK mem_obj_destructor_callback( cl_mem, void *data )
|
||||
{
|
||||
free( data );
|
||||
|
||||
@@ -177,7 +177,7 @@ test_status InitCL(cl_device_id device)
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("Error while acquiring half rounding mode");
|
||||
log_error("Error while acquiring half rounding mode\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ int test_copy2D(const cl_device_id deviceID, const cl_context context,
|
||||
{
|
||||
int error;
|
||||
|
||||
log_info("Testing %d byte element with srcMargin = %d, dstMargin = %d\n",
|
||||
log_info("Testing %zu byte element with srcMargin = %d, dstMargin = %d\n",
|
||||
elementSize, srcMargin, dstMargin);
|
||||
|
||||
cl_long max_local_mem_size;
|
||||
@@ -235,8 +235,8 @@ int test_copy2D(const cl_device_id deviceID, const cl_context context,
|
||||
|
||||
if ((localBufferSize / 4) > max_work_group_size)
|
||||
{
|
||||
log_info("Skipping due to resource requirements local:%db "
|
||||
"max_work_group_size:%d\n",
|
||||
log_info("Skipping due to resource requirements local:%zub "
|
||||
"max_work_group_size:%zu\n",
|
||||
localBufferSize, max_work_group_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ int test_copy3D(const cl_device_id deviceID, const cl_context context,
|
||||
int error;
|
||||
|
||||
log_info(
|
||||
"Testing %d byte element with srcLineMargin = %d, dstLineMargin = %d, "
|
||||
"Testing %zu byte element with srcLineMargin = %d, dstLineMargin = %d, "
|
||||
"srcPlaneMargin = %d, dstPlaneMargin = %d\n",
|
||||
elementSize, srcLineMargin, dstLineMargin, srcPlaneMargin,
|
||||
dstPlaneMargin);
|
||||
@@ -255,8 +255,8 @@ int test_copy3D(const cl_device_id deviceID, const cl_context context,
|
||||
|
||||
if ((localBufferSize / 4) > max_work_group_size)
|
||||
{
|
||||
log_info("Skipping due to resource requirements local:%db "
|
||||
"max_work_group_size:%d\n",
|
||||
log_info("Skipping due to resource requirements local:%zub "
|
||||
"max_work_group_size:%zu\n",
|
||||
localBufferSize, max_work_group_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ static void initialize_image(BufferType* ptr, size_t w, size_t h, size_t d, MTda
|
||||
|
||||
// This function prints the contents of a buffer to standard error.
|
||||
void print_buffer(BufferType* buf, size_t w, size_t h, size_t d) {
|
||||
log_error("Size = %lux%lux%lu (%lu total)\n",w,h,d,w*h*d);
|
||||
log_error("Size = %zux%zux%zu (%zu total)\n", w, h, d, w * h * d);
|
||||
for (unsigned k=0; k!=d;++k) {
|
||||
log_error("Slice: %u\n",k);
|
||||
for (unsigned j=0; j!=h;++j) {
|
||||
@@ -218,7 +218,9 @@ int verify_region(BufferType* device, size_t src, size_t soffset[3], size_t sreg
|
||||
size_t d_idx = (doffset[2]+sz)*dslice + (doffset[1]+sy)*dpitch + doffset[0]+sx;
|
||||
|
||||
if (device[d_idx] != verify[src][s_idx]) {
|
||||
log_error("Verify failed on comparsion %lu: coordinate (%lu, %lu, %lu) of region\n",i,sx,sy,sz);
|
||||
log_error("Verify failed on comparsion %zu: coordinate (%zu, %zu, "
|
||||
"%zu) of region\n",
|
||||
i, sx, sy, sz);
|
||||
log_error("0x%02x != 0x%02x\n", device[d_idx], verify[src][s_idx]);
|
||||
#if 0
|
||||
// Uncomment this section to print buffers.
|
||||
@@ -369,7 +371,7 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
max_mem_alloc_dim = max_mem_alloc_size;
|
||||
}
|
||||
|
||||
log_info("Using maximum dimension = %lu.\n", max_mem_alloc_dim);
|
||||
log_info("Using maximum dimension = %zu.\n", max_mem_alloc_dim);
|
||||
|
||||
// Create pairs of cl buffers and host buffers on which operations will be mirrored.
|
||||
log_info("Creating %u pairs of random sized host and cl buffers.\n", TotalImages);
|
||||
@@ -392,7 +394,8 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
|
||||
// Check to see if adequately sized buffers were found.
|
||||
if (tries >= max_tries) {
|
||||
log_error("Error: Could not find random buffer sized less than %llu bytes in %lu tries.\n",
|
||||
log_error("Error: Could not find random buffer sized less than "
|
||||
"%llu bytes in %zu tries.\n",
|
||||
max_mem_alloc_size, max_tries);
|
||||
return -1;
|
||||
}
|
||||
@@ -401,10 +404,11 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
max_size = (size_bytes > max_size) ? size_bytes : max_size;
|
||||
total_bytes += size_bytes;
|
||||
|
||||
log_info("Buffer[%u] is (%lu,%lu,%lu) = %lu MB (truncated)\n",i,width[i],height[i],depth[i],(size_bytes)/1048576);
|
||||
log_info("Buffer[%u] is (%zu,%zu,%zu) = %zu MB (truncated)\n", i,
|
||||
width[i], height[i], depth[i], (size_bytes) / 1048576);
|
||||
}
|
||||
|
||||
log_info( "Total size: %lu MB (truncated)\n", total_bytes/1048576 );
|
||||
log_info("Total size: %zu MB (truncated)\n", total_bytes / 1048576);
|
||||
|
||||
// Allocate a temporary buffer for read and write operations.
|
||||
tmp_buffer_size = max_size;
|
||||
@@ -491,32 +495,32 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
|
||||
switch (operation) {
|
||||
case 0:
|
||||
log_info("%lu Copy %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n",
|
||||
iter,
|
||||
src, soffset[0], soffset[1], soffset[2],
|
||||
dst, doffset[0], doffset[1], doffset[2],
|
||||
sregion[0], sregion[1], sregion[2],
|
||||
sregion[0]*sregion[1]*sregion[2]);
|
||||
log_info("%zu Copy %zu offset (%zu,%zu,%zu) -> %zu offset "
|
||||
"(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n",
|
||||
iter, src, soffset[0], soffset[1], soffset[2], dst,
|
||||
doffset[0], doffset[1], doffset[2], sregion[0],
|
||||
sregion[1], sregion[2],
|
||||
sregion[0] * sregion[1] * sregion[2]);
|
||||
if ((err = copy_region(src, soffset, sregion, dst, doffset, dregion)))
|
||||
return err;
|
||||
break;
|
||||
case 1:
|
||||
log_info("%lu Read %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n",
|
||||
iter,
|
||||
src, soffset[0], soffset[1], soffset[2],
|
||||
dst, doffset[0], doffset[1], doffset[2],
|
||||
sregion[0], sregion[1], sregion[2],
|
||||
sregion[0]*sregion[1]*sregion[2]);
|
||||
log_info("%zu Read %zu offset (%zu,%zu,%zu) -> %zu offset "
|
||||
"(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n",
|
||||
iter, src, soffset[0], soffset[1], soffset[2], dst,
|
||||
doffset[0], doffset[1], doffset[2], sregion[0],
|
||||
sregion[1], sregion[2],
|
||||
sregion[0] * sregion[1] * sregion[2]);
|
||||
if ((err = read_verify_region(src, soffset, sregion, dst, doffset, dregion)))
|
||||
return err;
|
||||
break;
|
||||
case 2:
|
||||
log_info("%lu Write %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n",
|
||||
iter,
|
||||
src, soffset[0], soffset[1], soffset[2],
|
||||
dst, doffset[0], doffset[1], doffset[2],
|
||||
sregion[0], sregion[1], sregion[2],
|
||||
sregion[0]*sregion[1]*sregion[2]);
|
||||
log_info("%zu Write %zu offset (%zu,%zu,%zu) -> %zu offset "
|
||||
"(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n",
|
||||
iter, src, soffset[0], soffset[1], soffset[2], dst,
|
||||
doffset[0], doffset[1], doffset[2], sregion[0],
|
||||
sregion[1], sregion[2],
|
||||
sregion[0] * sregion[1] * sregion[2]);
|
||||
if ((err = write_region(src, soffset, sregion, dst, doffset, dregion)))
|
||||
return err;
|
||||
break;
|
||||
@@ -526,11 +530,11 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
// Uncomment this section to verify each operation.
|
||||
// If commented out, verification won't occur until the end of the
|
||||
// test, and it will not be possible to determine which operation failed.
|
||||
log_info("Verify src %lu offset (%u,%u,%u) region (%lux%lux%lu)\n", src, 0, 0, 0, width[src], height[src], depth[src]);
|
||||
log_info("Verify src %zu offset (%u,%u,%u) region (%zux%zux%zu)\n", src, 0, 0, 0, width[src], height[src], depth[src]);
|
||||
if (err = map_verify_region(src))
|
||||
return err;
|
||||
|
||||
log_info("Verify dst %lu offset (%u,%u,%u) region (%lux%lux%lu)\n", dst, 0, 0, 0, width[dst], height[dst], depth[dst]);
|
||||
log_info("Verify dst %zu offset (%u,%u,%u) region (%zux%zux%zu)\n", dst, 0, 0, 0, width[dst], height[dst], depth[dst]);
|
||||
if (err = map_verify_region(dst))
|
||||
return err;
|
||||
|
||||
@@ -540,7 +544,8 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que
|
||||
} // end main for loop.
|
||||
|
||||
for (unsigned i=0;i<TotalImages;++i) {
|
||||
log_info("Verify %u offset (%u,%u,%u) region (%lux%lux%lu)\n", i, 0, 0, 0, width[i], height[i], depth[i]);
|
||||
log_info("Verify %u offset (%u,%u,%u) region (%zux%zux%zu)\n", i, 0, 0,
|
||||
0, width[i], height[i], depth[i]);
|
||||
if ((err = map_verify_region(i)))
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ int test_constant(cl_device_id device, cl_context context,
|
||||
|
||||
|
||||
log_info(
|
||||
"Test will attempt to use %lu bytes with one %lu byte constant int "
|
||||
"buffer and one %lu byte constant float buffer.\n",
|
||||
"Test will attempt to use %zu bytes with one %zu byte constant int "
|
||||
"buffer and one %zu byte constant float buffer.\n",
|
||||
constant_values * sizeof(cl_int) + constant_values * sizeof(cl_float),
|
||||
constant_values * sizeof(cl_int), constant_values * sizeof(cl_float));
|
||||
|
||||
|
||||
@@ -98,14 +98,20 @@ int verify_fp(std::vector<T> (&input)[2], std::vector<T> &output,
|
||||
auto &inB = input[1];
|
||||
for (size_t i = 0; i < output.size(); i++)
|
||||
{
|
||||
bool nan_test = false;
|
||||
|
||||
T r = test.ref(inA[i], inB[i]);
|
||||
bool both_nan = false;
|
||||
|
||||
if (std::is_same<T, cl_half>::value)
|
||||
nan_test = !(isHalfNan(r) && isHalfNan(output[i]));
|
||||
{
|
||||
both_nan = isHalfNan(r) && isHalfNan(output[i]);
|
||||
}
|
||||
else if (std::is_floating_point<T>::value)
|
||||
{
|
||||
both_nan = std::isnan(r) && std::isnan(output[i]);
|
||||
}
|
||||
|
||||
if (r != output[i] && nan_test)
|
||||
// If not both nan, check if the result is the same
|
||||
if (!both_nan && (r != output[i]))
|
||||
{
|
||||
log_error("FP math test for type: %s, vec size: %zu, failed at "
|
||||
"index %zu, %a '%c' %a, expected %a, get %a\n",
|
||||
|
||||
@@ -36,11 +36,12 @@ const char *work_offset_test[] = {
|
||||
#define NUM_TESTS 16
|
||||
#define MAX_OFFSET 256
|
||||
|
||||
#define CHECK_RANGE( v, m, c ) \
|
||||
if( ( v >= (cl_int)m ) || ( v < 0 ) ) \
|
||||
{ \
|
||||
log_error( "ERROR: ouputID_%c[%lu]: %d is < 0 or >= %lu\n", c, i, v, m ); \
|
||||
return -1; \
|
||||
#define CHECK_RANGE(v, m, c) \
|
||||
if ((v >= (cl_int)m) || (v < 0)) \
|
||||
{ \
|
||||
log_error("ERROR: ouputID_%c[%zu]: %d is < 0 or >= %zu\n", c, i, v, \
|
||||
m); \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int outputB[], cl_int outputC[] )
|
||||
@@ -76,13 +77,17 @@ int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int
|
||||
if( counts[ x ][ y ][ z ] < 1 )
|
||||
{
|
||||
if( missed < 3 )
|
||||
log_error( "ERROR: Map value (%ld,%ld,%ld) was missed%s\n", x, y, z, ( missed == 2 ) ? limitMsg : "" );
|
||||
log_error(
|
||||
"ERROR: Map value (%zu,%zu,%zu) was missed%s\n",
|
||||
x, y, z, (missed == 2) ? limitMsg : "");
|
||||
missed++;
|
||||
}
|
||||
else if( counts[ x ][ y ][ z ] > 1 )
|
||||
{
|
||||
if( multiple < 3 )
|
||||
log_error( "ERROR: Map value (%ld,%ld,%ld) was returned multiple times%s\n", x, y, z, ( multiple == 2 ) ? limitMsg : "" );
|
||||
log_error("ERROR: Map value (%zu,%zu,%zu) was "
|
||||
"returned multiple times%s\n",
|
||||
x, y, z, (multiple == 2) ? limitMsg : "");
|
||||
multiple++;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +96,9 @@ int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int
|
||||
if( counts[ x ][ y ][ z ] > 0 )
|
||||
{
|
||||
if( errored < 3 )
|
||||
log_error( "ERROR: Map value (%ld,%ld,%ld) was erroneously returned%s\n", x, y, z, ( errored == 2 ) ? limitMsg : "" );
|
||||
log_error("ERROR: Map value (%zu,%zu,%zu) was "
|
||||
"erroneously returned%s\n",
|
||||
x, y, z, (errored == 2) ? limitMsg : "");
|
||||
errored++;
|
||||
}
|
||||
}
|
||||
@@ -161,9 +168,11 @@ int test_global_work_offsets(cl_device_id deviceID, cl_context context, cl_comma
|
||||
for( int j = 0; j < 3; j++ )
|
||||
offsets[ j ] = random_in_range( 0, MAX_OFFSET, seed );
|
||||
|
||||
log_info( "\tTesting %ld,%ld,%ld (%ld,%ld,%ld) with offsets (%ld,%ld,%ld)...\n",
|
||||
threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ],
|
||||
offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] );
|
||||
log_info("\tTesting %zu,%zu,%zu (%zu,%zu,%zu) with offsets "
|
||||
"(%zu,%zu,%zu)...\n",
|
||||
threads[0], threads[1], threads[2], localThreads[0],
|
||||
localThreads[1], localThreads[2], offsets[0], offsets[1],
|
||||
offsets[2]);
|
||||
|
||||
// Now set up and run
|
||||
for( int i = 0; i < 3; i++ )
|
||||
@@ -187,9 +196,11 @@ int test_global_work_offsets(cl_device_id deviceID, cl_context context, cl_comma
|
||||
// but they won't be in order, so we need to construct a count map to determine what we got
|
||||
if( check_results( threads, offsets, outputA, outputB, outputC ) )
|
||||
{
|
||||
log_error( "\t(Test failed for global dim %ld,%ld,%ld, local dim %ld,%ld,%ld, offsets %ld,%ld,%ld)\n",
|
||||
threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ],
|
||||
offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] );
|
||||
log_error("\t(Test failed for global dim %zu,%zu,%zu, local dim "
|
||||
"%zu,%zu,%zu, offsets %zu,%zu,%zu)\n",
|
||||
threads[0], threads[1], threads[2], localThreads[0],
|
||||
localThreads[1], localThreads[2], offsets[0], offsets[1],
|
||||
offsets[2]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -252,9 +263,11 @@ int test_get_global_offset(cl_device_id deviceID, cl_context context, cl_command
|
||||
for( int j = 0; j < 3; j++ )
|
||||
offsets[ j ] = random_in_range( 0, MAX_OFFSET, seed );
|
||||
|
||||
log_info( "\tTesting %ld,%ld,%ld (%ld,%ld,%ld) with offsets (%ld,%ld,%ld)...\n",
|
||||
threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ],
|
||||
offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] );
|
||||
log_info("\tTesting %zu,%zu,%zu (%zu,%zu,%zu) with offsets "
|
||||
"(%zu,%zu,%zu)...\n",
|
||||
threads[0], threads[1], threads[2], localThreads[0],
|
||||
localThreads[1], localThreads[2], offsets[0], offsets[1],
|
||||
offsets[2]);
|
||||
|
||||
// Now set up and run
|
||||
error = clSetKernelArg( kernel, 0, sizeof( streams[0] ), &streams[0] );
|
||||
@@ -273,7 +286,9 @@ int test_get_global_offset(cl_device_id deviceID, cl_context context, cl_command
|
||||
{
|
||||
if( outOffsets[ j ] != (cl_int)offsets[ j ] )
|
||||
{
|
||||
log_error( "ERROR: get_global_offset( %d ) did not return expected value (expected %ld, got %d)\n", j, offsets[ j ], outOffsets[ j ] );
|
||||
log_error("ERROR: get_global_offset( %d ) did not return "
|
||||
"expected value (expected %zu, got %d)\n",
|
||||
j, offsets[j], outOffsets[j]);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context,
|
||||
{
|
||||
if (memcmp(&inchar[i], &outchar[i], elem_size) != 0)
|
||||
{
|
||||
log_error("%d(0x%x) -> expected [", i, i);
|
||||
log_error("%zu(0x%zx) -> expected [", i, i);
|
||||
for (size_t j = 0; j < elem_size; j++)
|
||||
log_error("0x%02x ", inchar[i + j]);
|
||||
log_error("] != actual [");
|
||||
|
||||
@@ -68,7 +68,7 @@ int get_max_image_dimensions(cl_device_id device, size_t &max_img_width,
|
||||
nullptr);
|
||||
test_error(err, "clGetDeviceInfo for CL_DEVICE_IMAGE2D_MAX_HEIGHT failed");
|
||||
|
||||
log_info("Device reported max image sizes of %lu x %lu, and max mem size "
|
||||
log_info("Device reported max image sizes of %zu x %zu, and max mem size "
|
||||
"of %gMB.\n",
|
||||
max_image2d_width, max_image2d_height,
|
||||
max_mem_size / (1024.0 * 1024.0));
|
||||
@@ -98,7 +98,7 @@ int get_max_image_dimensions(cl_device_id device, size_t &max_img_width,
|
||||
max_img_width = std::min(max_image2d_width, max_img_dim);
|
||||
max_img_height = std::min(max_image2d_height, max_img_dim);
|
||||
|
||||
log_info("Adjusted maximum image size to test is %d x %d, which is a max "
|
||||
log_info("Adjusted maximum image size to test is %zu x %zu, which is a max "
|
||||
"mem size of %gMB.\n",
|
||||
max_img_width, max_img_height,
|
||||
(max_img_width * max_img_height * 4) / (1024.0 * 1024.0));
|
||||
@@ -147,12 +147,12 @@ int test_imagedim_common(cl_context context, cl_command_queue queue,
|
||||
|
||||
size_t threads[] = { img_width, img_height };
|
||||
if (local_threads)
|
||||
log_info(
|
||||
"Testing image dimensions %d x %d with local threads %d x %d.\n",
|
||||
img_width, img_height, local_threads[0], local_threads[1]);
|
||||
log_info("Testing image dimensions %zu x %zu with local threads %zu x "
|
||||
"%zu.\n",
|
||||
img_width, img_height, local_threads[0], local_threads[1]);
|
||||
else
|
||||
log_info(
|
||||
"Testing image dimensions %d x %d with local threads nullptr.\n",
|
||||
"Testing image dimensions %zu x %zu with local threads nullptr.\n",
|
||||
img_width, img_height);
|
||||
err = clEnqueueNDRangeKernel(queue, kernel, 2, nullptr, threads,
|
||||
local_threads, 0, nullptr, nullptr);
|
||||
@@ -165,8 +165,8 @@ int test_imagedim_common(cl_context context, cl_command_queue queue,
|
||||
if (0 != memcmp(input.data(), output.data(), 4 * img_width * img_height))
|
||||
{
|
||||
total_errors++;
|
||||
log_error("Image Dimension test failed. image width = %d, "
|
||||
"image height = %d\n",
|
||||
log_error("Image Dimension test failed. image width = %zu, "
|
||||
"image height = %zu\n",
|
||||
img_width, img_height);
|
||||
}
|
||||
return total_errors;
|
||||
|
||||
@@ -198,8 +198,8 @@ int test_local_arg_def(cl_device_id device, cl_context context, cl_command_queue
|
||||
|
||||
// Adjust the local thread size to fit and be a nice multiple.
|
||||
if (kwgsize < wgsize) {
|
||||
log_info("Adjusting wgsize down from %lu to %lu.\n", wgsize, kwgsize);
|
||||
local_threads[0] = kwgsize;
|
||||
log_info("Adjusting wgsize down from %zu to %zu.\n", wgsize, kwgsize);
|
||||
local_threads[0] = kwgsize;
|
||||
}
|
||||
while (global_threads[0] % local_threads[0] != 0)
|
||||
local_threads[0]--;
|
||||
@@ -331,8 +331,8 @@ int test_local_kernel_def(cl_device_id device, cl_context context, cl_command_qu
|
||||
|
||||
// Adjust the local thread size to fit and be a nice multiple.
|
||||
if (kwgsize < wgsize) {
|
||||
log_info("Adjusting wgsize down from %lu to %lu.\n", wgsize, kwgsize);
|
||||
local_threads[0] = kwgsize;
|
||||
log_info("Adjusting wgsize down from %zu to %zu.\n", wgsize, kwgsize);
|
||||
local_threads[0] = kwgsize;
|
||||
}
|
||||
while (global_threads[0] % local_threads[0] != 0)
|
||||
local_threads[0]--;
|
||||
|
||||
@@ -82,7 +82,8 @@ int test_local_kernel_scope(cl_device_id device, cl_context context, cl_command_
|
||||
while( testSize < 1024 )
|
||||
testSize += workGroupSize;
|
||||
size_t numGroups = testSize / workGroupSize;
|
||||
log_info( "\tTesting with %ld groups, %ld elements per group...\n", numGroups, workGroupSize );
|
||||
log_info("\tTesting with %zu groups, %zu elements per group...\n",
|
||||
numGroups, workGroupSize);
|
||||
|
||||
// Create two buffers for operation
|
||||
cl_uint *inputData = (cl_uint*)malloc( testSize * sizeof(cl_uint) );
|
||||
@@ -124,7 +125,9 @@ int test_local_kernel_scope(cl_device_id device, cl_context context, cl_command_
|
||||
|
||||
if( outputData[ i ] != localMax )
|
||||
{
|
||||
log_error( "ERROR: Local max validation failed! (expected %u, got %u for i=%lu)\n", localMax, outputData[ i ] , i );
|
||||
log_error("ERROR: Local max validation failed! (expected %u, got "
|
||||
"%u for i=%zu)\n",
|
||||
localMax, outputData[i], i);
|
||||
free(inputData);
|
||||
free(outputData);
|
||||
return -1;
|
||||
|
||||
@@ -1100,7 +1100,7 @@ static int check_global_initialization(cl_context context, cl_program program,
|
||||
test_error_ret(status, "Failed to read buffer from device", status);
|
||||
if (is_init_valid == 0)
|
||||
{
|
||||
log_error("Unexpected default values were detected");
|
||||
log_error("Unexpected default values were detected\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,14 @@ int test_simple_read_image_pitch(cl_device_id device, cl_context cl_context_, cl
|
||||
for (size_t i=0;i<bufferW;++i) {
|
||||
char val = host_buffer[j*bufferW+i];
|
||||
if ((i<imageW*pixel_bytes) && (val != 0x1)) {
|
||||
log_error("Bad value %x in image at (byte: %lu, row: %lu)\n",val,i,j);
|
||||
++errors;
|
||||
log_error("Bad value %x in image at (byte: %zu, row: %zu)\n", val, i,
|
||||
j);
|
||||
++errors;
|
||||
}
|
||||
else if ((i>=imageW*pixel_bytes) && (val != 0xa)) {
|
||||
log_error("Bad value %x outside image at (byte: %lu, row: %lu)\n",val,i,j);
|
||||
++errors;
|
||||
log_error("Bad value %x outside image at (byte: %zu, row: %zu)\n",
|
||||
val, i, j);
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,8 +138,9 @@ int test_simple_write_image_pitch(cl_device_id device, cl_context cl_context_, c
|
||||
for (size_t i=0;i<mapped_pitch;++i) {
|
||||
char val = mapped_image[j*mapped_pitch+i];
|
||||
if ((i<imageW*pixel_bytes) && (val != 0xa)) {
|
||||
log_error("Bad value %x in image at (byte: %lu, row: %lu)\n",val,i,j);
|
||||
++errors;
|
||||
log_error("Bad value %x in image at (byte: %zu, row: %zu)\n", val, i,
|
||||
j);
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
}
|
||||
|
||||
char name[32];
|
||||
sprintf( name, "%s%ld", vector_table[i].name, j );
|
||||
sprintf(name, "%s%zu", vector_table[i].name, j);
|
||||
|
||||
test = CL_ULONG_MAX;
|
||||
err = get_type_size( context, queue, name, &test, device );
|
||||
@@ -197,12 +197,16 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
return err;
|
||||
if( test != j * vector_table[i].size )
|
||||
{
|
||||
log_error( "\nFAILED: Type %s has size %lld, but expected size %lld!\n", name, test, j * vector_table[i].size );
|
||||
log_error(
|
||||
"\nFAILED: Type %s has size %lld, but expected size %zu!\n",
|
||||
name, test, j * vector_table[i].size);
|
||||
return -1;
|
||||
}
|
||||
if( test != j * vector_table[i].cl_size )
|
||||
{
|
||||
log_error( "\nFAILED: Type %s has size %lld, but cl_ size is %lld!\n", name, test, j * vector_table[i].cl_size );
|
||||
log_error(
|
||||
"\nFAILED: Type %s has size %lld, but cl_ size is %zu!\n",
|
||||
name, test, j * vector_table[i].cl_size);
|
||||
return -2;
|
||||
}
|
||||
log_info( "%16s", name );
|
||||
@@ -317,7 +321,7 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
for( j = 2; j <= 16; j *= 2 )
|
||||
{
|
||||
char name[32];
|
||||
sprintf( name, "double%ld", j );
|
||||
sprintf(name, "double%zu", j);
|
||||
|
||||
test = CL_ULONG_MAX;
|
||||
err = get_type_size( context, queue, name, &test, device );
|
||||
@@ -325,7 +329,8 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
return err;
|
||||
if( test != 8*j )
|
||||
{
|
||||
log_error( "\nFAILED: %s has size %lld, but must be %ld!\n", name, test, 8 * j);
|
||||
log_error("\nFAILED: %s has size %lld, but must be %zu!\n",
|
||||
name, test, 8 * j);
|
||||
return -1;
|
||||
}
|
||||
log_info( "%16s", name );
|
||||
@@ -352,7 +357,7 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
for( j = 2; j <= 16; j *= 2 )
|
||||
{
|
||||
char name[32];
|
||||
sprintf( name, "half%ld", j );
|
||||
sprintf(name, "half%zu", j);
|
||||
|
||||
test = CL_ULONG_MAX;
|
||||
err = get_type_size( context, queue, name, &test, device );
|
||||
@@ -360,7 +365,8 @@ int test_sizeof(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
return err;
|
||||
if( test != 2*j )
|
||||
{
|
||||
log_error( "\nFAILED: %s has size %lld, but must be %ld!\n", name, test, 2 * j);
|
||||
log_error("\nFAILED: %s has size %lld, but must be %zu!\n",
|
||||
name, test, 2 * j);
|
||||
return -1;
|
||||
}
|
||||
log_info( "%16s", name );
|
||||
|
||||
@@ -439,7 +439,7 @@ struct TestWorkItemFnsOutOfRange
|
||||
"ERROR: get_enqueued_local_size(%d) did not return "
|
||||
"proper value for the argument out of range "
|
||||
"(expected 1, got %d)\n",
|
||||
(int)dim, (int)testData[q].globalSize);
|
||||
(int)dim, (int)testData[q].enqueuedLocalSize);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -526,7 +526,7 @@ struct TestWorkItemFnsOutOfRange
|
||||
// Validate
|
||||
if (!Validate(dim))
|
||||
{
|
||||
log_error("Validation failed");
|
||||
log_error("Validation failed\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
|
||||
|
||||
|
||||
int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(array_info_size)
|
||||
{
|
||||
cl_mem memobj;
|
||||
cl_int err;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -13,116 +13,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "procs.h"
|
||||
#include "harness/compat.h"
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST(buffer_read_async_int),
|
||||
ADD_TEST(buffer_read_async_uint),
|
||||
ADD_TEST(buffer_read_async_long),
|
||||
ADD_TEST(buffer_read_async_ulong),
|
||||
ADD_TEST(buffer_read_async_short),
|
||||
ADD_TEST(buffer_read_async_ushort),
|
||||
ADD_TEST(buffer_read_async_char),
|
||||
ADD_TEST(buffer_read_async_uchar),
|
||||
ADD_TEST(buffer_read_async_float),
|
||||
ADD_TEST(buffer_read_array_barrier_int),
|
||||
ADD_TEST(buffer_read_array_barrier_uint),
|
||||
ADD_TEST(buffer_read_array_barrier_long),
|
||||
ADD_TEST(buffer_read_array_barrier_ulong),
|
||||
ADD_TEST(buffer_read_array_barrier_short),
|
||||
ADD_TEST(buffer_read_array_barrier_ushort),
|
||||
ADD_TEST(buffer_read_array_barrier_char),
|
||||
ADD_TEST(buffer_read_array_barrier_uchar),
|
||||
ADD_TEST(buffer_read_array_barrier_float),
|
||||
ADD_TEST(buffer_read_int),
|
||||
ADD_TEST(buffer_read_uint),
|
||||
ADD_TEST(buffer_read_long),
|
||||
ADD_TEST(buffer_read_ulong),
|
||||
ADD_TEST(buffer_read_short),
|
||||
ADD_TEST(buffer_read_ushort),
|
||||
ADD_TEST(buffer_read_float),
|
||||
ADD_TEST(buffer_read_half),
|
||||
ADD_TEST(buffer_read_char),
|
||||
ADD_TEST(buffer_read_uchar),
|
||||
ADD_TEST(buffer_read_struct),
|
||||
ADD_TEST(buffer_read_random_size),
|
||||
ADD_TEST(buffer_map_read_int),
|
||||
ADD_TEST(buffer_map_read_uint),
|
||||
ADD_TEST(buffer_map_read_long),
|
||||
ADD_TEST(buffer_map_read_ulong),
|
||||
ADD_TEST(buffer_map_read_short),
|
||||
ADD_TEST(buffer_map_read_ushort),
|
||||
ADD_TEST(buffer_map_read_char),
|
||||
ADD_TEST(buffer_map_read_uchar),
|
||||
ADD_TEST(buffer_map_read_float),
|
||||
ADD_TEST(buffer_map_read_struct),
|
||||
|
||||
ADD_TEST(buffer_map_write_int),
|
||||
ADD_TEST(buffer_map_write_uint),
|
||||
ADD_TEST(buffer_map_write_long),
|
||||
ADD_TEST(buffer_map_write_ulong),
|
||||
ADD_TEST(buffer_map_write_short),
|
||||
ADD_TEST(buffer_map_write_ushort),
|
||||
ADD_TEST(buffer_map_write_char),
|
||||
ADD_TEST(buffer_map_write_uchar),
|
||||
ADD_TEST(buffer_map_write_float),
|
||||
ADD_TEST(buffer_map_write_struct),
|
||||
|
||||
ADD_TEST(buffer_write_int),
|
||||
ADD_TEST(buffer_write_uint),
|
||||
ADD_TEST(buffer_write_short),
|
||||
ADD_TEST(buffer_write_ushort),
|
||||
ADD_TEST(buffer_write_char),
|
||||
ADD_TEST(buffer_write_uchar),
|
||||
ADD_TEST(buffer_write_float),
|
||||
ADD_TEST(buffer_write_half),
|
||||
ADD_TEST(buffer_write_long),
|
||||
ADD_TEST(buffer_write_ulong),
|
||||
ADD_TEST(buffer_write_struct),
|
||||
ADD_TEST(buffer_write_async_int),
|
||||
ADD_TEST(buffer_write_async_uint),
|
||||
ADD_TEST(buffer_write_async_short),
|
||||
ADD_TEST(buffer_write_async_ushort),
|
||||
ADD_TEST(buffer_write_async_char),
|
||||
ADD_TEST(buffer_write_async_uchar),
|
||||
ADD_TEST(buffer_write_async_float),
|
||||
ADD_TEST(buffer_write_async_long),
|
||||
ADD_TEST(buffer_write_async_ulong),
|
||||
ADD_TEST(buffer_copy),
|
||||
ADD_TEST(buffer_partial_copy),
|
||||
ADD_TEST(mem_read_write_flags),
|
||||
ADD_TEST(mem_write_only_flags),
|
||||
ADD_TEST(mem_read_only_flags),
|
||||
ADD_TEST(mem_copy_host_flags),
|
||||
ADD_TEST(mem_alloc_ref_flags),
|
||||
ADD_TEST(array_info_size),
|
||||
|
||||
ADD_TEST(sub_buffers_read_write),
|
||||
ADD_TEST(sub_buffers_read_write_dual_devices),
|
||||
ADD_TEST(sub_buffers_overlapping),
|
||||
|
||||
ADD_TEST(buffer_fill_int),
|
||||
ADD_TEST(buffer_fill_uint),
|
||||
ADD_TEST(buffer_fill_short),
|
||||
ADD_TEST(buffer_fill_ushort),
|
||||
ADD_TEST(buffer_fill_char),
|
||||
ADD_TEST(buffer_fill_uchar),
|
||||
ADD_TEST(buffer_fill_long),
|
||||
ADD_TEST(buffer_fill_ulong),
|
||||
ADD_TEST(buffer_fill_float),
|
||||
ADD_TEST(buffer_fill_struct),
|
||||
|
||||
ADD_TEST(buffer_migrate),
|
||||
ADD_TEST(image_migrate),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
#include "testBase.h"
|
||||
|
||||
const cl_mem_flags flag_set[] = {
|
||||
CL_MEM_ALLOC_HOST_PTR,
|
||||
@@ -141,5 +36,6 @@ const char* flag_set_names[] = {
|
||||
|
||||
int main( int argc, const char *argv[] )
|
||||
{
|
||||
return runTestHarness(argc, argv, test_num, test_list, false, 0);
|
||||
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, 0);
|
||||
}
|
||||
|
||||
@@ -1,132 +0,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.
|
||||
//
|
||||
#ifndef __PROCS_H__
|
||||
#define __PROCS_H__
|
||||
|
||||
#include "harness/kernelHelpers.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/mt19937.h"
|
||||
#include "harness/conversions.h"
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
extern const cl_mem_flags flag_set[];
|
||||
extern const char* flag_set_names[];
|
||||
#define NUM_FLAGS 5
|
||||
|
||||
extern int test_buffer_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_random_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_read_array_barrier_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_mem_read_write_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_mem_write_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_mem_alloc_ref_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
#endif // #ifndef __PROCS_H__
|
||||
|
||||
30
test_conformance/buffers/testBase.h
Normal file
30
test_conformance/buffers/testBase.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright (c) 2025 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.
|
||||
//
|
||||
#ifndef _testBase_h
|
||||
#define _testBase_h
|
||||
|
||||
#include <CL/cl.h>
|
||||
|
||||
#include "harness/conversions.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
extern const cl_mem_flags flag_set[];
|
||||
extern const char* flag_set_names[];
|
||||
|
||||
#define NUM_FLAGS 5
|
||||
|
||||
#endif // _testBase_h
|
||||
@@ -21,10 +21,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
|
||||
|
||||
static int verify_copy_buffer(int *inptr, int *outptr, int n)
|
||||
{
|
||||
int i;
|
||||
@@ -245,7 +244,7 @@ static int testPartialCopy( cl_command_queue queue, cl_context context, int num_
|
||||
} // end testPartialCopy()
|
||||
|
||||
|
||||
int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_copy)
|
||||
{
|
||||
int i, err = 0;
|
||||
int size;
|
||||
@@ -271,7 +270,7 @@ int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
} // end test_buffer_copy()
|
||||
|
||||
|
||||
int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_partial_copy)
|
||||
{
|
||||
int i, err = 0;
|
||||
int size;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
|
||||
#define TEST_PRIME_CHAR 0x77
|
||||
@@ -557,10 +557,13 @@ static int verify_fill_struct( void *ptr1, void *ptr2, int n )
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type,
|
||||
int loops, void *inptr[5], void *hostptr[5], void *pattern[5], size_t offset_elements, size_t fill_elements,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) )
|
||||
static int test_buffer_fill(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops, void *inptr[5],
|
||||
void *hostptr[5], void *pattern[5],
|
||||
size_t offset_elements, size_t fill_elements,
|
||||
const char *kernelCode[], const char *kernelName[],
|
||||
int (*fn)(void *, void *, int))
|
||||
{
|
||||
void *outptr[5];
|
||||
clProgramWrapper program[5];
|
||||
@@ -700,7 +703,7 @@ int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
} // end test_buffer_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_struct)
|
||||
{
|
||||
TestStruct pattern;
|
||||
size_t ptrSize = sizeof( TestStruct );
|
||||
@@ -890,7 +893,7 @@ int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_fill_struct()
|
||||
|
||||
|
||||
int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_int)
|
||||
{
|
||||
cl_int *inptr[5];
|
||||
cl_int *hostptr[5];
|
||||
@@ -934,10 +937,11 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
if (test_buffer_fill(device, context, queue, num_elements,
|
||||
sizeof(cl_int), (char *)"int", 5, (void **)inptr,
|
||||
(void **)hostptr, (void **)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_int_kernel_code, int_kernel_name, foo ))
|
||||
buffer_fill_int_kernel_code, int_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -955,7 +959,7 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_
|
||||
} // end test_buffer_int_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_uint)
|
||||
{
|
||||
cl_uint *inptr[5];
|
||||
cl_uint *hostptr[5];
|
||||
@@ -999,10 +1003,11 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_uint_kernel_code, uint_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_uint),
|
||||
(char *)"uint", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_uint_kernel_code, uint_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1020,7 +1025,7 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command
|
||||
} // end test_buffer_uint_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_short)
|
||||
{
|
||||
cl_short *inptr[5];
|
||||
cl_short *hostptr[5];
|
||||
@@ -1064,10 +1069,11 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_short_kernel_code, short_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_short),
|
||||
(char *)"short", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_short_kernel_code, short_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1085,7 +1091,7 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_short_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_ushort)
|
||||
{
|
||||
cl_ushort *inptr[5];
|
||||
cl_ushort *hostptr[5];
|
||||
@@ -1129,10 +1135,11 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_ushort_kernel_code, ushort_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_ushort),
|
||||
(char *)"ushort", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_ushort_kernel_code, ushort_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1150,7 +1157,7 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_ushort_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_char)
|
||||
{
|
||||
cl_char *inptr[5];
|
||||
cl_char *hostptr[5];
|
||||
@@ -1194,10 +1201,11 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_char_kernel_code, char_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_char),
|
||||
(char *)"char", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_char_kernel_code, char_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1215,7 +1223,7 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command
|
||||
} // end test_buffer_char_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_uchar)
|
||||
{
|
||||
cl_uchar *inptr[5];
|
||||
cl_uchar *hostptr[5];
|
||||
@@ -1259,10 +1267,11 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_uchar_kernel_code, uchar_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_uchar),
|
||||
(char *)"uchar", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_uchar_kernel_code, uchar_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1280,7 +1289,7 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_uchar_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_long)
|
||||
{
|
||||
cl_long *inptr[5];
|
||||
cl_long *hostptr[5];
|
||||
@@ -1331,10 +1340,11 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_long_kernel_code, long_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_long),
|
||||
(char *)"long", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_long_kernel_code, long_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1352,7 +1362,7 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command
|
||||
} // end test_buffer_long_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_ulong)
|
||||
{
|
||||
cl_ulong *inptr[5];
|
||||
cl_ulong *hostptr[5];
|
||||
@@ -1402,10 +1412,11 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_ulong_kernel_code, ulong_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_ulong),
|
||||
(char *)"ulong", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_ulong_kernel_code, ulong_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
@@ -1423,7 +1434,7 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_ulong_fill()
|
||||
|
||||
|
||||
int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_fill_float)
|
||||
{
|
||||
cl_float *inptr[5];
|
||||
cl_float *hostptr[5];
|
||||
@@ -1467,10 +1478,11 @@ int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_comman
|
||||
memset(hostptr[i], 0, ptrSizes[i] * num_elements);
|
||||
}
|
||||
|
||||
if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float",
|
||||
5, (void**)inptr, (void**)hostptr, (void**)pattern,
|
||||
offset_elements, fill_elements,
|
||||
buffer_fill_float_kernel_code, float_kernel_name, foo ))
|
||||
if (test_buffer_fill(
|
||||
device, context, queue, num_elements, sizeof(cl_float),
|
||||
(char *)"float", 5, (void **)inptr, (void **)hostptr,
|
||||
(void **)pattern, offset_elements, fill_elements,
|
||||
buffer_fill_float_kernel_code, float_kernel_name, foo))
|
||||
err++;
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
|
||||
|
||||
@@ -672,12 +672,14 @@ static int test_buffer_map_read( cl_device_id deviceID, cl_context context, cl_c
|
||||
} // end test_buffer_map_read()
|
||||
|
||||
|
||||
#define DECLARE_LOCK_TEST(type, realType) \
|
||||
int test_buffer_map_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_LOCK_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_map_read_##type) \
|
||||
{ \
|
||||
return test_buffer_map_read(device, context, queue, num_elements, \
|
||||
sizeof(realType), (char *)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_LOCK_TEST(int, cl_int)
|
||||
DECLARE_LOCK_TEST(uint, cl_uint)
|
||||
@@ -689,13 +691,14 @@ DECLARE_LOCK_TEST(char, cl_char)
|
||||
DECLARE_LOCK_TEST(uchar, cl_uchar)
|
||||
DECLARE_LOCK_TEST(float, cl_float)
|
||||
|
||||
int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_read_struct)
|
||||
{
|
||||
int (*foo)(void *,int);
|
||||
foo = verify_read_struct;
|
||||
|
||||
return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( TestStruct ), (char*)"struct", 1,
|
||||
buffer_read_struct_kernel_code, struct_kernel_name, foo );
|
||||
|
||||
return test_buffer_map_read(device, context, queue, num_elements,
|
||||
sizeof(TestStruct), (char *)"struct", 1,
|
||||
buffer_read_struct_kernel_code,
|
||||
struct_kernel_name, foo);
|
||||
} // end test_buffer_map_struct_read()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#ifndef uchar
|
||||
typedef unsigned char uchar;
|
||||
@@ -66,9 +66,9 @@ static int verify_mem( int *outptr, int n )
|
||||
}
|
||||
|
||||
|
||||
int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements,
|
||||
cl_mem_flags flags, const char **kernel_program,
|
||||
const char *kernel_name)
|
||||
static int test_mem_flags(cl_context context, cl_command_queue queue,
|
||||
int num_elements, cl_mem_flags flags,
|
||||
const char **kernel_program, const char *kernel_name)
|
||||
{
|
||||
clMemWrapper buffers[2];
|
||||
cl_int *inptr, *outptr;
|
||||
@@ -205,38 +205,35 @@ int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements,
|
||||
return err;
|
||||
} // end test_mem_flags()
|
||||
|
||||
int test_mem_read_write_flags(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(mem_read_write_flags)
|
||||
{
|
||||
return test_mem_flags(context, queue, num_elements, CL_MEM_READ_WRITE,
|
||||
&mem_read_write_kernel_code, "test_mem_read_write");
|
||||
}
|
||||
|
||||
|
||||
int test_mem_write_only_flags(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(mem_write_only_flags)
|
||||
{
|
||||
return test_mem_flags(context, queue, num_elements, CL_MEM_WRITE_ONLY,
|
||||
&mem_write_kernel_code, "test_mem_write");
|
||||
}
|
||||
|
||||
|
||||
int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(mem_read_only_flags)
|
||||
{
|
||||
return test_mem_flags(context, queue, num_elements, CL_MEM_READ_ONLY,
|
||||
&mem_read_kernel_code, "test_mem_read");
|
||||
}
|
||||
|
||||
|
||||
int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(mem_copy_host_flags)
|
||||
{
|
||||
return test_mem_flags(context, queue, num_elements,
|
||||
CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE,
|
||||
&mem_read_write_kernel_code, "test_mem_read_write");
|
||||
}
|
||||
|
||||
int test_mem_alloc_ref_flags(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(mem_alloc_ref_flags)
|
||||
{
|
||||
return test_mem_flags(context, queue, num_elements,
|
||||
CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
@@ -96,7 +96,7 @@ static cl_int restoreBuffer(cl_command_queue *queues, cl_mem *buffers, cl_uint n
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_migrate)
|
||||
{
|
||||
int failed = 0;
|
||||
cl_uint i, j;
|
||||
@@ -119,9 +119,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu
|
||||
const size_t wgs[1] = {BUFFER_SIZE};
|
||||
|
||||
/* Allocate arrays whose size varies according to the maximum number of sub-devices */
|
||||
if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) {
|
||||
print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed");
|
||||
return -1;
|
||||
if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
sizeof(max_sub_devices), &max_sub_devices, NULL))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed");
|
||||
return -1;
|
||||
}
|
||||
if (max_sub_devices < 1) {
|
||||
log_error("ERROR: Invalid number of compute units returned.\n");
|
||||
@@ -156,9 +159,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu
|
||||
}
|
||||
|
||||
// Attempt to partition the device along each of the allowed affinity domain.
|
||||
if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) {
|
||||
print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed");
|
||||
return -1;
|
||||
if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
|
||||
sizeof(domains), &domains, NULL))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE |
|
||||
@@ -175,7 +181,9 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu
|
||||
// Determine the number of partitions for the device given the specific domain.
|
||||
if (domain) {
|
||||
property[1] = domain;
|
||||
err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices);
|
||||
err = clCreateSubDevices(device,
|
||||
(const cl_device_partition_property *)property,
|
||||
-1, NULL, &num_devices);
|
||||
if ((err != CL_SUCCESS) || (num_devices == 0)) {
|
||||
print_error(err, "Obtaining the number of partions by affinity failed.");
|
||||
failed = 1;
|
||||
@@ -187,10 +195,14 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu
|
||||
|
||||
if (num_devices > 1) {
|
||||
// Create each of the sub-devices and a corresponding context.
|
||||
if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) {
|
||||
print_error(err, "Failed creating sub devices.");
|
||||
failed = 1;
|
||||
goto cleanup;
|
||||
if ((err = clCreateSubDevices(
|
||||
device, (const cl_device_partition_property *)property,
|
||||
num_devices, devices, &num_devices))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "Failed creating sub devices.");
|
||||
failed = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Create a context containing all the sub-devices
|
||||
@@ -213,7 +225,7 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu
|
||||
}
|
||||
} else {
|
||||
// No partitioning available. Just exercise the APIs on a single device.
|
||||
devices[0] = deviceID;
|
||||
devices[0] = device;
|
||||
queues[0] = queue;
|
||||
ctx = context;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <CL/cl_half.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
|
||||
//#define HK_DO_NOT_RUN_SHORT_ASYNC 1
|
||||
//#define HK_DO_NOT_RUN_USHORT_ASYNC 1
|
||||
@@ -618,8 +618,11 @@ static int verify_read_struct(TestStruct *outptr, int n)
|
||||
}
|
||||
|
||||
//----- the test functions
|
||||
int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[],
|
||||
int (*fn)(void *, int))
|
||||
{
|
||||
void *outptr[5];
|
||||
void *inptr[5];
|
||||
@@ -758,8 +761,12 @@ int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
|
||||
} // end test_buffer_read()
|
||||
|
||||
int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read_async(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops,
|
||||
const char *kernelCode[],
|
||||
const char *kernelName[],
|
||||
int (*fn)(void *, int))
|
||||
{
|
||||
clProgramWrapper program[5];
|
||||
clKernelWrapper kernel[5];
|
||||
@@ -894,8 +901,10 @@ int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_read_array_async()
|
||||
|
||||
|
||||
int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read_array_barrier(
|
||||
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *, int))
|
||||
{
|
||||
clProgramWrapper program[5];
|
||||
clKernelWrapper kernel[5];
|
||||
@@ -1033,12 +1042,14 @@ int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, c
|
||||
} // end test_buffer_read_array_barrier()
|
||||
|
||||
|
||||
#define DECLARE_READ_TEST(type, realType) \
|
||||
int test_buffer_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_READ_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_##type) \
|
||||
{ \
|
||||
return test_buffer_read(device, context, queue, num_elements, \
|
||||
sizeof(realType), (char *)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_READ_TEST(int, cl_int)
|
||||
DECLARE_READ_TEST(uint, cl_uint)
|
||||
@@ -1050,21 +1061,24 @@ DECLARE_READ_TEST(float, cl_float)
|
||||
DECLARE_READ_TEST(char, cl_char)
|
||||
DECLARE_READ_TEST(uchar, cl_uchar)
|
||||
|
||||
int test_buffer_read_half(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_half)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID)
|
||||
return test_buffer_read( deviceID, context, queue, num_elements, sizeof( cl_float ) / 2, (char*)"half", 5,
|
||||
buffer_read_half_kernel_code, half_kernel_name, verify_read_half );
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(device)
|
||||
return test_buffer_read(device, context, queue, num_elements,
|
||||
sizeof(cl_float) / 2, (char *)"half", 5,
|
||||
buffer_read_half_kernel_code, half_kernel_name,
|
||||
verify_read_half);
|
||||
}
|
||||
|
||||
|
||||
#define DECLARE_ASYNC_TEST(type, realType) \
|
||||
int test_buffer_read_async_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read_async( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_ASYNC_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_async_##type) \
|
||||
{ \
|
||||
return test_buffer_read_async(device, context, queue, num_elements, \
|
||||
sizeof(realType), (char *)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_ASYNC_TEST(char, cl_char)
|
||||
DECLARE_ASYNC_TEST(uchar, cl_uchar)
|
||||
@@ -1077,12 +1091,14 @@ DECLARE_ASYNC_TEST(ulong, cl_ulong)
|
||||
DECLARE_ASYNC_TEST(float, cl_float)
|
||||
|
||||
|
||||
#define DECLARE_BARRIER_TEST(type, realType) \
|
||||
int test_buffer_read_array_barrier_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read_array_barrier( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_BARRIER_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_array_barrier_##type) \
|
||||
{ \
|
||||
return test_buffer_read_array_barrier( \
|
||||
device, context, queue, num_elements, sizeof(realType), \
|
||||
(char *)#type, 5, buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_BARRIER_TEST(int, cl_int)
|
||||
DECLARE_BARRIER_TEST(uint, cl_uint)
|
||||
@@ -1094,7 +1110,7 @@ DECLARE_BARRIER_TEST(char, cl_char)
|
||||
DECLARE_BARRIER_TEST(uchar, cl_uchar)
|
||||
DECLARE_BARRIER_TEST(float, cl_float)
|
||||
|
||||
int test_buffer_read_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_struct)
|
||||
{
|
||||
cl_mem buffers[1];
|
||||
TestStruct *output_ptr;
|
||||
@@ -1305,7 +1321,7 @@ static int testRandomReadSize( cl_device_id deviceID, cl_context context, cl_com
|
||||
} // end testRandomReadSize()
|
||||
|
||||
|
||||
int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_random_size)
|
||||
{
|
||||
int err = 0;
|
||||
int i;
|
||||
@@ -1317,7 +1333,8 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c
|
||||
for ( i = 0; i < 8; i++ ){
|
||||
start = (cl_uint)get_random_float( 0.f, (float)(num_elements - 8), d );
|
||||
size = (size_t)get_random_float( 8.f, (float)(num_elements - start), d );
|
||||
if (testRandomReadSize( deviceID, context, queue, num_elements, start, size ))
|
||||
if (testRandomReadSize(device, context, queue, num_elements, start,
|
||||
size))
|
||||
err++;
|
||||
}
|
||||
|
||||
@@ -1325,4 +1342,3 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
|
||||
|
||||
@@ -621,8 +621,11 @@ static int verify_write_struct( void *ptr1, void *ptr2, int n )
|
||||
}
|
||||
|
||||
|
||||
int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int), MTdata d )
|
||||
static int test_buffer_write(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops, void *inptr[5],
|
||||
const char *kernelCode[], const char *kernelName[],
|
||||
int (*fn)(void *, void *, int), MTdata d)
|
||||
{
|
||||
void *outptr[5];
|
||||
clProgramWrapper program[5];
|
||||
@@ -787,9 +790,7 @@ int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_que
|
||||
} // end test_buffer_write()
|
||||
|
||||
|
||||
|
||||
|
||||
int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_struct)
|
||||
{
|
||||
|
||||
void *outptr[5];
|
||||
@@ -966,8 +967,11 @@ int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_comm
|
||||
} // end test_buffer_struct_write()
|
||||
|
||||
|
||||
int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) )
|
||||
static int test_buffer_write_array_async(
|
||||
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements, size_t size, char *type, int loops, void *inptr[5],
|
||||
const char *kernelCode[], const char *kernelName[],
|
||||
int (*fn)(void *, void *, int))
|
||||
{
|
||||
cl_mem buffers[10];
|
||||
void *outptr[5];
|
||||
@@ -1098,7 +1102,7 @@ int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl
|
||||
} // end test_buffer_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_int)
|
||||
{
|
||||
int *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1124,8 +1128,9 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command
|
||||
inptr[i][j] = (int)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr,
|
||||
buffer_write_int_kernel_code, int_kernel_name, foo, d );
|
||||
err = test_buffer_write(
|
||||
device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5,
|
||||
(void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1137,7 +1142,7 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command
|
||||
} // end test_buffer_int_write()
|
||||
|
||||
|
||||
int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_uint)
|
||||
{
|
||||
cl_uint *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1163,8 +1168,10 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman
|
||||
inptr[i][j] = genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr,
|
||||
buffer_write_uint_kernel_code, uint_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_uint), (char *)"uint", 5, (void **)inptr,
|
||||
buffer_write_uint_kernel_code, uint_kernel_name,
|
||||
foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1176,7 +1183,7 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_uint_write()
|
||||
|
||||
|
||||
int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_short)
|
||||
{
|
||||
short *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1202,8 +1209,10 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma
|
||||
inptr[i][j] = (cl_short)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr,
|
||||
buffer_write_short_kernel_code, short_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_short), (char *)"short", 5,
|
||||
(void **)inptr, buffer_write_short_kernel_code,
|
||||
short_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1216,7 +1225,7 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_short_write()
|
||||
|
||||
|
||||
int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_ushort)
|
||||
{
|
||||
cl_ushort *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1242,8 +1251,10 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm
|
||||
inptr[i][j] = (cl_ushort)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr,
|
||||
buffer_write_ushort_kernel_code, ushort_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_ushort), (char *)"ushort", 5,
|
||||
(void **)inptr, buffer_write_ushort_kernel_code,
|
||||
ushort_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1256,7 +1267,7 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm
|
||||
} // end test_buffer_ushort_write()
|
||||
|
||||
|
||||
int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_char)
|
||||
{
|
||||
char *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1282,8 +1293,10 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman
|
||||
inptr[i][j] = (char)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr,
|
||||
buffer_write_char_kernel_code, char_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_char), (char *)"char", 5, (void **)inptr,
|
||||
buffer_write_char_kernel_code, char_kernel_name,
|
||||
foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1296,7 +1309,7 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_char_write()
|
||||
|
||||
|
||||
int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_uchar)
|
||||
{
|
||||
uchar *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1322,8 +1335,10 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma
|
||||
inptr[i][j] = (uchar)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr,
|
||||
buffer_write_uchar_kernel_code, uchar_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_uchar), (char *)"uchar", 5,
|
||||
(void **)inptr, buffer_write_uchar_kernel_code,
|
||||
uchar_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1336,7 +1351,7 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_uchar_write()
|
||||
|
||||
|
||||
int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_float)
|
||||
{
|
||||
float *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1362,8 +1377,10 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma
|
||||
inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d );
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr,
|
||||
buffer_write_float_kernel_code, float_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_float), (char *)"float", 5,
|
||||
(void **)inptr, buffer_write_float_kernel_code,
|
||||
float_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1375,9 +1392,9 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_float_write()
|
||||
|
||||
|
||||
int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_half)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID)
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(device)
|
||||
float *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
int i, err;
|
||||
@@ -1402,7 +1419,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman
|
||||
inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d );
|
||||
}
|
||||
|
||||
err = test_buffer_write(deviceID, context, queue, num_elements,
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_half), (char *)"half", 5, (void **)inptr,
|
||||
buffer_write_half_kernel_code, half_kernel_name,
|
||||
foo, d);
|
||||
@@ -1417,7 +1434,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_half_write()
|
||||
|
||||
|
||||
int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_long)
|
||||
{
|
||||
cl_long *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1450,8 +1467,10 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman
|
||||
inptr[i][j] = (cl_long) genrand_int32(d) ^ ((cl_long) genrand_int32(d) << 32);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr,
|
||||
buffer_write_long_kernel_code, long_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_long), (char *)"cl_long", 5,
|
||||
(void **)inptr, buffer_write_long_kernel_code,
|
||||
long_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1463,7 +1482,7 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_long_write()
|
||||
|
||||
|
||||
int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_ulong)
|
||||
{
|
||||
cl_ulong *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1495,8 +1514,10 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma
|
||||
inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32);
|
||||
}
|
||||
|
||||
err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr,
|
||||
buffer_write_ulong_kernel_code, ulong_kernel_name, foo, d );
|
||||
err = test_buffer_write(device, context, queue, num_elements,
|
||||
sizeof(cl_ulong), (char *)"ulong long", 5,
|
||||
(void **)inptr, buffer_write_ulong_kernel_code,
|
||||
ulong_kernel_name, foo, d);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1509,68 +1530,68 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma
|
||||
} // end test_buffer_ulong_write()
|
||||
|
||||
|
||||
int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_int)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_int(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_int(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_uint)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_uint(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_uint(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_long)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_long(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_long(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_ulong)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_ulong(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_ulong(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_short)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_short(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_short(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_ushort)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_ushort(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_ushort(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_char)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_char(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_char(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_uchar)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_uchar(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_uchar(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_float)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_float(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_float(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_map_write_struct)
|
||||
{
|
||||
gTestMap = 1;
|
||||
return test_buffer_write_struct(deviceID, context, queue, num_elements);
|
||||
return test_buffer_write_struct(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
|
||||
int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_int)
|
||||
{
|
||||
int *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1596,8 +1617,9 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c
|
||||
inptr[i][j] = (int)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr,
|
||||
buffer_write_int_kernel_code, int_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5,
|
||||
(void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1609,7 +1631,7 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c
|
||||
} // end test_buffer_int_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_uint)
|
||||
{
|
||||
cl_uint *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1635,8 +1657,10 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_
|
||||
inptr[i][j] = (cl_uint)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr,
|
||||
buffer_write_uint_kernel_code, uint_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_uint), (char *)"uint",
|
||||
5, (void **)inptr, buffer_write_uint_kernel_code, uint_kernel_name,
|
||||
foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1648,7 +1672,7 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_
|
||||
} // end test_buffer_uint_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_short)
|
||||
{
|
||||
short *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1674,8 +1698,10 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl
|
||||
inptr[i][j] = (short)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr,
|
||||
buffer_write_short_kernel_code, short_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_short), (char *)"short",
|
||||
5, (void **)inptr, buffer_write_short_kernel_code, short_kernel_name,
|
||||
foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1688,7 +1714,7 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl
|
||||
} // end test_buffer_short_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_ushort)
|
||||
{
|
||||
cl_ushort *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1714,8 +1740,10 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c
|
||||
inptr[i][j] = (cl_ushort)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr,
|
||||
buffer_write_ushort_kernel_code, ushort_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_ushort),
|
||||
(char *)"ushort", 5, (void **)inptr, buffer_write_ushort_kernel_code,
|
||||
ushort_kernel_name, foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1728,7 +1756,7 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c
|
||||
} // end test_buffer_ushort_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_char)
|
||||
{
|
||||
char *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1754,8 +1782,10 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_
|
||||
inptr[i][j] = (char)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr,
|
||||
buffer_write_char_kernel_code, char_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_char), (char *)"char",
|
||||
5, (void **)inptr, buffer_write_char_kernel_code, char_kernel_name,
|
||||
foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1768,7 +1798,7 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_
|
||||
} // end test_buffer_char_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_uchar)
|
||||
{
|
||||
uchar *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1794,8 +1824,10 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl
|
||||
inptr[i][j] = (uchar)genrand_int32(d);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr,
|
||||
buffer_write_uchar_kernel_code, uchar_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_uchar), (char *)"uchar",
|
||||
5, (void **)inptr, buffer_write_uchar_kernel_code, uchar_kernel_name,
|
||||
foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1808,7 +1840,7 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl
|
||||
} // end test_buffer_uchar_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_float)
|
||||
{
|
||||
float *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1834,8 +1866,10 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl
|
||||
inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d );
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr,
|
||||
buffer_write_float_kernel_code, float_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_float), (char *)"float",
|
||||
5, (void **)inptr, buffer_write_float_kernel_code, float_kernel_name,
|
||||
foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1847,7 +1881,7 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl
|
||||
} // end test_buffer_float_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_long)
|
||||
{
|
||||
cl_long *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1879,8 +1913,10 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_
|
||||
inptr[i][j] = ((cl_long) genrand_int32(d)) ^ ((cl_long) genrand_int32(d) << 32);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr,
|
||||
buffer_write_long_kernel_code, long_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_long),
|
||||
(char *)"cl_long", 5, (void **)inptr, buffer_write_long_kernel_code,
|
||||
long_kernel_name, foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
@@ -1892,7 +1928,7 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_
|
||||
} // end test_buffer_long_write_array_async()
|
||||
|
||||
|
||||
int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(buffer_write_async_ulong)
|
||||
{
|
||||
cl_ulong *inptr[5];
|
||||
size_t ptrSizes[5];
|
||||
@@ -1924,8 +1960,10 @@ int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl
|
||||
inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32);
|
||||
}
|
||||
|
||||
err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr,
|
||||
buffer_write_ulong_kernel_code, ulong_kernel_name, foo );
|
||||
err = test_buffer_write_array_async(
|
||||
device, context, queue, num_elements, sizeof(cl_ulong),
|
||||
(char *)"ulong long", 5, (void **)inptr, buffer_write_ulong_kernel_code,
|
||||
ulong_kernel_name, foo);
|
||||
|
||||
for ( i = 0; i < 5; i++ ){
|
||||
align_free( (void *)inptr[i] );
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
|
||||
#define MAX_SUB_DEVICES 16 // Limit the sub-devices to ensure no out of resource errors.
|
||||
@@ -113,7 +113,7 @@ static cl_int restoreImage(cl_command_queue *queues, cl_mem *mem_objects, cl_uin
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(image_migrate)
|
||||
{
|
||||
int failed = 0;
|
||||
cl_uint i, j;
|
||||
@@ -139,15 +139,19 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
const size_t wls[2] = {1, 1};
|
||||
|
||||
// Check for image support.
|
||||
if(checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED) {
|
||||
log_info("Device does not support images. Skipping test.\n");
|
||||
return 0;
|
||||
if (checkForImageSupport(device) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
||||
{
|
||||
log_info("Device does not support images. Skipping test.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate arrays whose size varies according to the maximum number of sub-devices.
|
||||
if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) {
|
||||
print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed");
|
||||
return -1;
|
||||
if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
sizeof(max_sub_devices), &max_sub_devices, NULL))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed");
|
||||
return -1;
|
||||
}
|
||||
if (max_sub_devices < 1) {
|
||||
log_error("ERROR: Invalid number of compute units returned.\n");
|
||||
@@ -188,9 +192,12 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
|
||||
|
||||
// Attempt to partition the device along each of the allowed affinity domain.
|
||||
if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) {
|
||||
print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed");
|
||||
return -1;
|
||||
if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
|
||||
sizeof(domains), &domains, NULL))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE |
|
||||
@@ -207,7 +214,9 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
// Determine the number of partitions for the device given the specific domain.
|
||||
if (domain) {
|
||||
property[1] = domain;
|
||||
err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices);
|
||||
err = clCreateSubDevices(device,
|
||||
(const cl_device_partition_property *)property,
|
||||
-1, NULL, &num_devices);
|
||||
if ((err != CL_SUCCESS) || (num_devices == 0)) {
|
||||
print_error(err, "Obtaining the number of partions by affinity failed.");
|
||||
failed = 1;
|
||||
@@ -219,10 +228,14 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
|
||||
if (num_devices > 1) {
|
||||
// Create each of the sub-devices and a corresponding context.
|
||||
if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) {
|
||||
print_error(err, "Failed creating sub devices.");
|
||||
failed = 1;
|
||||
goto cleanup;
|
||||
if ((err = clCreateSubDevices(
|
||||
device, (const cl_device_partition_property *)property,
|
||||
num_devices, devices, &num_devices))
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
print_error(err, "Failed creating sub devices.");
|
||||
failed = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Create a context containing all the sub-devices
|
||||
@@ -245,7 +258,7 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
}
|
||||
} else {
|
||||
// No partitioning available. Just exercise the APIs on a single device.
|
||||
devices[0] = deviceID;
|
||||
devices[0] = device;
|
||||
queues[0] = queue;
|
||||
ctx = context;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -13,7 +13,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@@ -232,7 +232,11 @@ size_t find_subbuffer_by_index( SubBufferWrapper * subBuffers, size_t numSubBuff
|
||||
|
||||
// This tests the read/write capabilities of sub buffers (if we are read/write, the sub buffers
|
||||
// can't overlap)
|
||||
int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queueA, cl_command_queue queueB, size_t mainSize, size_t addressAlign )
|
||||
static int test_sub_buffers_read_write_core(cl_context context,
|
||||
cl_command_queue queueA,
|
||||
cl_command_queue queueB,
|
||||
size_t mainSize,
|
||||
size_t addressAlign)
|
||||
{
|
||||
clMemWrapper mainBuffer;
|
||||
SubBufferWrapper subBuffers[ 8 ];
|
||||
@@ -380,18 +384,19 @@ int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queue
|
||||
return numErrors;
|
||||
}
|
||||
|
||||
int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(sub_buffers_read_write)
|
||||
{
|
||||
cl_int error;
|
||||
size_t mainSize;
|
||||
cl_uint addressAlignBits;
|
||||
|
||||
// Get the size of the main buffer to use
|
||||
error = get_reasonable_buffer_size( deviceID, mainSize );
|
||||
error = get_reasonable_buffer_size(device, mainSize);
|
||||
test_error( error, "Unable to get reasonable buffer size" );
|
||||
|
||||
// Determine the alignment of the device so we can make sure sub buffers are valid
|
||||
error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlignBits ), &addressAlignBits, NULL );
|
||||
error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
||||
sizeof(addressAlignBits), &addressAlignBits, NULL);
|
||||
test_error( error, "Unable to get device's address alignment" );
|
||||
|
||||
size_t addressAlign = addressAlignBits/8;
|
||||
@@ -402,19 +407,19 @@ int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_c
|
||||
// This test performs the same basic operations as sub_buffers_read_write, but instead of a single
|
||||
// device, it creates a context and buffer shared between two devices, then executes commands
|
||||
// on queues for each device to ensure that everything still operates as expected.
|
||||
int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(sub_buffers_read_write_dual_devices)
|
||||
{
|
||||
cl_int error;
|
||||
|
||||
|
||||
// First obtain the second device
|
||||
cl_device_id otherDevice = GetOpposingDevice( deviceID );
|
||||
cl_device_id otherDevice = GetOpposingDevice(device);
|
||||
if ( otherDevice == NULL )
|
||||
{
|
||||
log_error( "ERROR: Unable to obtain a second device for sub-buffer dual-device test.\n" );
|
||||
return -1;
|
||||
}
|
||||
if ( otherDevice == deviceID )
|
||||
if (otherDevice == device)
|
||||
{
|
||||
log_info( "Note: Unable to run dual-device sub-buffer test (only one device available). Skipping test (implicitly passing).\n" );
|
||||
return 0;
|
||||
@@ -433,12 +438,13 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context
|
||||
device_name.data());
|
||||
|
||||
// Create a shared context for these two devices
|
||||
cl_device_id devices[ 2 ] = { deviceID, otherDevice };
|
||||
cl_device_id devices[2] = { device, otherDevice };
|
||||
clContextWrapper testingContext = clCreateContext( NULL, 2, devices, NULL, NULL, &error );
|
||||
test_error( error, "Unable to create shared context" );
|
||||
|
||||
// Create two queues (can't use the existing one, because it's on the wrong context)
|
||||
clCommandQueueWrapper queue1 = clCreateCommandQueue( testingContext, deviceID, 0, &error );
|
||||
clCommandQueueWrapper queue1 =
|
||||
clCreateCommandQueue(testingContext, device, 0, &error);
|
||||
test_error( error, "Unable to create command queue on main device" );
|
||||
|
||||
clCommandQueueWrapper queue2 = clCreateCommandQueue( testingContext, otherDevice, 0, &error );
|
||||
@@ -446,7 +452,7 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context
|
||||
|
||||
// Determine the reasonable buffer size and address alignment that applies to BOTH devices
|
||||
size_t maxBuffer1, maxBuffer2;
|
||||
error = get_reasonable_buffer_size( deviceID, maxBuffer1 );
|
||||
error = get_reasonable_buffer_size(device, maxBuffer1);
|
||||
test_error( error, "Unable to get buffer size for main device" );
|
||||
|
||||
error = get_reasonable_buffer_size( otherDevice, maxBuffer2 );
|
||||
@@ -454,7 +460,9 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context
|
||||
maxBuffer1 = std::min(maxBuffer1, maxBuffer2);
|
||||
|
||||
cl_uint addressAlign1Bits, addressAlign2Bits;
|
||||
error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign1Bits ), &addressAlign1Bits, NULL );
|
||||
error =
|
||||
clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
||||
sizeof(addressAlign1Bits), &addressAlign1Bits, NULL);
|
||||
test_error( error, "Unable to get main device's address alignment" );
|
||||
|
||||
error = clGetDeviceInfo( otherDevice, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign2Bits ), &addressAlign2Bits, NULL );
|
||||
@@ -503,7 +511,7 @@ cl_int read_buffer_via_kernel( cl_context context, cl_command_queue queue, cl_me
|
||||
}
|
||||
|
||||
|
||||
int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(sub_buffers_overlapping)
|
||||
{
|
||||
cl_int error;
|
||||
size_t mainSize;
|
||||
@@ -514,14 +522,15 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_
|
||||
|
||||
|
||||
// Create the main buffer to test against
|
||||
error = get_reasonable_buffer_size( deviceID, mainSize );
|
||||
error = get_reasonable_buffer_size(device, mainSize);
|
||||
test_error( error, "Unable to get reasonable buffer size" );
|
||||
|
||||
mainBuffer = clCreateBuffer( context, CL_MEM_READ_WRITE, mainSize, NULL, &error );
|
||||
test_error( error, "Unable to create test main buffer" );
|
||||
|
||||
// Determine the alignment of the device so we can make sure sub buffers are valid
|
||||
error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign ), &addressAlign, NULL );
|
||||
error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
||||
sizeof(addressAlign), &addressAlign, NULL);
|
||||
test_error( error, "Unable to get device's address alignment" );
|
||||
|
||||
// Create some sub-buffers to use. Note: they don't have to not overlap (we actually *want* them to overlap)
|
||||
@@ -638,4 +647,3 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_
|
||||
|
||||
return numErrors;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,84 +29,6 @@ int gMaxDeviceThreads = 1024; // maximum number of threads executed on OCL devic
|
||||
cl_device_atomic_capabilities gAtomicMemCap,
|
||||
gAtomicFenceCap; // atomic memory and fence capabilities for this device
|
||||
|
||||
extern int test_atomic_init(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_store(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_store_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_exchange(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_compare_exchange_strong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_add(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_sub(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_or(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_orand(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_xor(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_min(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fetch_max(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_flag(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_atomic_fence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_svm_atomic_init(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_store(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_store_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_exchange(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_compare_exchange_strong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_add(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_sub(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_or(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_orand(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_xor(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_min(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fetch_max(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_flag(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_svm_atomic_fence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST( atomic_init ),
|
||||
ADD_TEST( atomic_store ),
|
||||
ADD_TEST( atomic_load ),
|
||||
ADD_TEST( atomic_exchange ),
|
||||
ADD_TEST( atomic_compare_exchange_weak ),
|
||||
ADD_TEST( atomic_compare_exchange_strong ),
|
||||
ADD_TEST( atomic_fetch_add ),
|
||||
ADD_TEST( atomic_fetch_sub ),
|
||||
ADD_TEST( atomic_fetch_and ),
|
||||
ADD_TEST( atomic_fetch_or ),
|
||||
ADD_TEST( atomic_fetch_orand ),
|
||||
ADD_TEST( atomic_fetch_xor ),
|
||||
ADD_TEST( atomic_fetch_xor2 ),
|
||||
ADD_TEST( atomic_fetch_min ),
|
||||
ADD_TEST( atomic_fetch_max ),
|
||||
ADD_TEST( atomic_flag ),
|
||||
ADD_TEST( atomic_fence ),
|
||||
|
||||
ADD_TEST( svm_atomic_init ),
|
||||
ADD_TEST( svm_atomic_store ),
|
||||
ADD_TEST( svm_atomic_load ),
|
||||
ADD_TEST( svm_atomic_exchange ),
|
||||
ADD_TEST( svm_atomic_compare_exchange_weak ),
|
||||
ADD_TEST( svm_atomic_compare_exchange_strong ),
|
||||
ADD_TEST( svm_atomic_fetch_add ),
|
||||
ADD_TEST( svm_atomic_fetch_sub ),
|
||||
ADD_TEST( svm_atomic_fetch_and ),
|
||||
ADD_TEST( svm_atomic_fetch_or ),
|
||||
ADD_TEST( svm_atomic_fetch_orand ),
|
||||
ADD_TEST( svm_atomic_fetch_xor ),
|
||||
ADD_TEST( svm_atomic_fetch_xor2 ),
|
||||
ADD_TEST( svm_atomic_fetch_min ),
|
||||
ADD_TEST( svm_atomic_fetch_max ),
|
||||
ADD_TEST( svm_atomic_flag ),
|
||||
ADD_TEST( svm_atomic_fence ),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
|
||||
test_status InitCL(cl_device_id device) {
|
||||
auto version = get_device_cl_version(device);
|
||||
auto expected_min_version = Version(2, 0);
|
||||
@@ -285,5 +207,7 @@ int main(int argc, const char *argv[])
|
||||
log_info("*** Use of this mode is not sufficient to verify correctness. ***\n");
|
||||
log_info("*** ***\n");
|
||||
}
|
||||
return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, false, InitCL);
|
||||
return runTestHarnessWithCheck(
|
||||
argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, false, InitCL);
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_store_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_store_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestStore<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -156,17 +156,15 @@ int test_atomic_store_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_store(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_store)
|
||||
{
|
||||
return test_atomic_store_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_store_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_store(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_store)
|
||||
{
|
||||
return test_atomic_store_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_store_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -202,9 +200,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_init_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_init_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestInit<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT, useSVM);
|
||||
@@ -277,18 +275,15 @@ int test_atomic_init_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_init(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_init)
|
||||
{
|
||||
return test_atomic_init_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_init_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_init(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_init)
|
||||
{
|
||||
return test_atomic_init_generic(deviceID, context, queue, num_elements,
|
||||
true);
|
||||
return test_atomic_init_generic(device, context, queue, num_elements, true);
|
||||
}
|
||||
|
||||
template <typename HostAtomicType, typename HostDataType>
|
||||
@@ -377,9 +372,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_load_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_load_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestLoad<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT, useSVM);
|
||||
@@ -452,18 +447,15 @@ int test_atomic_load_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_load(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_load)
|
||||
{
|
||||
return test_atomic_load_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_load_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_load(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_load)
|
||||
{
|
||||
return test_atomic_load_generic(deviceID, context, queue, num_elements,
|
||||
true);
|
||||
return test_atomic_load_generic(device, context, queue, num_elements, true);
|
||||
}
|
||||
|
||||
template <typename HostAtomicType, typename HostDataType>
|
||||
@@ -568,9 +560,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_exchange_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_exchange_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestExchange<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -644,17 +637,15 @@ int test_atomic_exchange_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_exchange(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_exchange)
|
||||
{
|
||||
return test_atomic_exchange_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_exchange_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_exchange(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_exchange)
|
||||
{
|
||||
return test_atomic_exchange_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_exchange_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -830,10 +821,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
static int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestCompareStrong<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -899,21 +891,15 @@ int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_compare_exchange_strong(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(atomic_compare_exchange_strong)
|
||||
{
|
||||
return test_atomic_compare_exchange_strong_generic(deviceID, context, queue,
|
||||
return test_atomic_compare_exchange_strong_generic(device, context, queue,
|
||||
num_elements, false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_compare_exchange_strong(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(svm_atomic_compare_exchange_strong)
|
||||
{
|
||||
return test_atomic_compare_exchange_strong_generic(deviceID, context, queue,
|
||||
return test_atomic_compare_exchange_strong_generic(device, context, queue,
|
||||
num_elements, true);
|
||||
}
|
||||
|
||||
@@ -966,10 +952,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
static int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestCompareWeak<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1035,19 +1022,15 @@ int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_compare_exchange_weak)
|
||||
{
|
||||
return test_atomic_compare_exchange_weak_generic(deviceID, context, queue,
|
||||
return test_atomic_compare_exchange_weak_generic(device, context, queue,
|
||||
num_elements, false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_compare_exchange_weak(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(svm_atomic_compare_exchange_weak)
|
||||
{
|
||||
return test_atomic_compare_exchange_weak_generic(deviceID, context, queue,
|
||||
return test_atomic_compare_exchange_weak_generic(device, context, queue,
|
||||
num_elements, true);
|
||||
}
|
||||
|
||||
@@ -1111,9 +1094,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_add_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_add_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchAdd<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1179,17 +1163,15 @@ int test_atomic_fetch_add_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_add(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_add)
|
||||
{
|
||||
return test_atomic_fetch_add_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_add_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_add(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_add)
|
||||
{
|
||||
return test_atomic_fetch_add_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_add_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -1238,9 +1220,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_sub_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_sub_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchSub<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1306,17 +1289,15 @@ int test_atomic_fetch_sub_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_sub(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_sub)
|
||||
{
|
||||
return test_atomic_fetch_sub_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_sub_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_sub(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_sub)
|
||||
{
|
||||
return test_atomic_fetch_sub_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_sub_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -1389,9 +1370,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_or_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_or_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchOr<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1457,17 +1439,15 @@ int test_atomic_fetch_or_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_or(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_or)
|
||||
{
|
||||
return test_atomic_fetch_or_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_or_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_or(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_or)
|
||||
{
|
||||
return test_atomic_fetch_or_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_or_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -1524,9 +1504,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_xor_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_xor_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchXor<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1592,17 +1573,15 @@ int test_atomic_fetch_xor_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_xor(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_xor)
|
||||
{
|
||||
return test_atomic_fetch_xor_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_xor_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_xor(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_xor)
|
||||
{
|
||||
return test_atomic_fetch_xor_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_xor_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -1675,9 +1654,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_and_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_and_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchAnd<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1743,17 +1723,15 @@ int test_atomic_fetch_and_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_and(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_and)
|
||||
{
|
||||
return test_atomic_fetch_and_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_and_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_and(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_and)
|
||||
{
|
||||
return test_atomic_fetch_and_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_and_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -1855,9 +1833,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_orand_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_orand_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchOrAnd<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -1923,18 +1902,16 @@ int test_atomic_fetch_orand_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_orand(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_orand)
|
||||
{
|
||||
return test_atomic_fetch_orand_generic(deviceID, context, queue,
|
||||
num_elements, false);
|
||||
return test_atomic_fetch_orand_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_orand(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_orand)
|
||||
{
|
||||
return test_atomic_fetch_orand_generic(deviceID, context, queue,
|
||||
num_elements, true);
|
||||
return test_atomic_fetch_orand_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename HostAtomicType, typename HostDataType>
|
||||
@@ -2035,9 +2012,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_xor2_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_xor2_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchXor2<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -2103,18 +2081,16 @@ int test_atomic_fetch_xor2_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_xor2(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_xor2)
|
||||
{
|
||||
return test_atomic_fetch_xor2_generic(deviceID, context, queue,
|
||||
num_elements, false);
|
||||
return test_atomic_fetch_xor2_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_xor2(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_xor2)
|
||||
{
|
||||
return test_atomic_fetch_xor2_generic(deviceID, context, queue,
|
||||
num_elements, true);
|
||||
return test_atomic_fetch_xor2_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename HostAtomicType, typename HostDataType>
|
||||
@@ -2170,9 +2146,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_min_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_min_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchMin<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -2238,17 +2215,15 @@ int test_atomic_fetch_min_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_min(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_min)
|
||||
{
|
||||
return test_atomic_fetch_min_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_min_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_min(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_min)
|
||||
{
|
||||
return test_atomic_fetch_min_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_min_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -2305,9 +2280,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_fetch_max_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fetch_max_generic(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements, bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFetchMax<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -2373,17 +2349,15 @@ int test_atomic_fetch_max_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fetch_max(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fetch_max)
|
||||
{
|
||||
return test_atomic_fetch_max_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_max_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fetch_max(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fetch_max)
|
||||
{
|
||||
return test_atomic_fetch_max_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fetch_max_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -2597,9 +2571,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int test_atomic_flag_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_flag_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFlag<HOST_ATOMIC_FLAG, HOST_FLAG> test_flag(TYPE_ATOMIC_FLAG,
|
||||
@@ -2609,18 +2583,15 @@ int test_atomic_flag_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_flag(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_flag)
|
||||
{
|
||||
return test_atomic_flag_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_flag_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_flag(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_flag)
|
||||
{
|
||||
return test_atomic_flag_generic(deviceID, context, queue, num_elements,
|
||||
true);
|
||||
return test_atomic_flag_generic(device, context, queue, num_elements, true);
|
||||
}
|
||||
|
||||
template <typename HostAtomicType, typename HostDataType>
|
||||
@@ -3149,9 +3120,9 @@ private:
|
||||
struct TestDefinition _subCase;
|
||||
};
|
||||
|
||||
int test_atomic_fence_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
static int test_atomic_fence_generic(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
bool useSVM)
|
||||
{
|
||||
int error = 0;
|
||||
CBasicTestFence<HOST_ATOMIC_INT, HOST_INT> test_int(TYPE_ATOMIC_INT,
|
||||
@@ -3217,16 +3188,14 @@ int test_atomic_fence_generic(cl_device_id deviceID, cl_context context,
|
||||
return error;
|
||||
}
|
||||
|
||||
int test_atomic_fence(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(atomic_fence)
|
||||
{
|
||||
return test_atomic_fence_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fence_generic(device, context, queue, num_elements,
|
||||
false);
|
||||
}
|
||||
|
||||
int test_svm_atomic_fence(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(svm_atomic_fence)
|
||||
{
|
||||
return test_atomic_fence_generic(deviceID, context, queue, num_elements,
|
||||
return test_atomic_fence_generic(device, context, queue, num_elements,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -182,27 +182,6 @@ template <typename T> inline half conv_to_half(const T &val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T> bool isfinite_fp(const T &v)
|
||||
{
|
||||
if (std::is_same<T, half>::value)
|
||||
{
|
||||
// Extract FP16 exponent and mantissa
|
||||
uint16_t h_exp = (((half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
||||
uint16_t h_mant = ((half)v) & 0x3FF;
|
||||
|
||||
// !Inf test
|
||||
return !(h_exp == 0x1F && h_mant == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
return std::isfinite(v);
|
||||
#else
|
||||
return isfinite(v);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> float UlpFn(const T &val, const double &r)
|
||||
{
|
||||
if (std::is_same<T, half>::value)
|
||||
|
||||
@@ -65,10 +65,6 @@ int verify_degrees(const T *const inptr, const T *const outptr, int n)
|
||||
{
|
||||
r = (180.0 / M_PI) * conv_to_dbl(inptr[i]);
|
||||
|
||||
if (std::is_same<T, half>::value)
|
||||
if (!isfinite_fp(conv_to_half(r)) && !isfinite_fp(outptr[i]))
|
||||
continue;
|
||||
|
||||
error = UlpFn(outptr[i], r);
|
||||
|
||||
if (fabsf(error) > max_error)
|
||||
@@ -115,10 +111,6 @@ int verify_radians(const T *const inptr, const T *const outptr, int n)
|
||||
{
|
||||
r = (M_PI / 180.0) * conv_to_dbl(inptr[i]);
|
||||
|
||||
if (std::is_same<T, half>::value)
|
||||
if (!isfinite_fp(conv_to_half(r)) && !isfinite_fp(outptr[i]))
|
||||
continue;
|
||||
|
||||
error = UlpFn(outptr[i], r);
|
||||
|
||||
if (fabsf(error) > max_error)
|
||||
|
||||
@@ -31,3 +31,10 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CLConform_SOURCE_DIR}/test_conformance/compiler/secondIncludeTestDirectory
|
||||
${COMPILER_TEST_RESOURCES}/secondIncludeTestDirectory)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(DIRECTORY
|
||||
${CLConform_SOURCE_DIR}/test_conformance/compiler/includeTestDirectory
|
||||
${CLConform_SOURCE_DIR}/test_conformance/compiler/secondIncludeTestDirectory
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}/$<CONFIG>)
|
||||
|
||||
@@ -35,6 +35,8 @@ test_definition test_list[] = {
|
||||
ADD_TEST(get_program_source),
|
||||
ADD_TEST(get_program_build_info),
|
||||
ADD_TEST(get_program_info),
|
||||
ADD_TEST(get_program_info_kernel_names),
|
||||
ADD_TEST(get_program_info_mult_devices),
|
||||
|
||||
ADD_TEST(large_compile),
|
||||
ADD_TEST(async_build),
|
||||
|
||||
@@ -71,7 +71,14 @@ extern int test_get_program_build_info(cl_device_id deviceID,
|
||||
int num_elements);
|
||||
extern int test_get_program_info(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_get_program_info_kernel_names(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements);
|
||||
extern int test_get_program_info_mult_devices(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
int num_elements);
|
||||
extern int test_large_compile(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
extern int test_async_build(cl_device_id deviceID, cl_context context,
|
||||
|
||||
@@ -25,6 +25,26 @@
|
||||
|
||||
#include "procs.h"
|
||||
|
||||
// scope guard helper to ensure proper releasing of sub devices
|
||||
struct SubDevicesScopeGuarded
|
||||
{
|
||||
SubDevicesScopeGuarded(const cl_int dev_count)
|
||||
{
|
||||
sub_devices.resize(dev_count);
|
||||
}
|
||||
~SubDevicesScopeGuarded()
|
||||
{
|
||||
for (auto &device : sub_devices)
|
||||
{
|
||||
cl_int err = clReleaseDevice(device);
|
||||
if (err != CL_SUCCESS)
|
||||
log_error("\n Releasing sub-device failed \n");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cl_device_id> sub_devices;
|
||||
};
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/parseParameters.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
const char *sample_kernel_code_single_line[] = {
|
||||
"__kernel void sample_test(__global float *src, __global int *dst)\n"
|
||||
"{\n"
|
||||
@@ -61,6 +65,28 @@ const char *sample_kernel_code_bad_multi_line[] = {
|
||||
"",
|
||||
"}" };
|
||||
|
||||
const char *sample_multi_kernel_code_with_macro = R"(
|
||||
__kernel void sample_test_A(__global float *src, __global int *dst)
|
||||
{
|
||||
size_t tid = get_global_id(0);
|
||||
dst[tid] = (int)src[tid];
|
||||
}
|
||||
|
||||
#ifdef USE_SAMPLE_TEST_B
|
||||
__kernel void sample_test_B(__global float *src, __global int *dst)
|
||||
{
|
||||
size_t tid = get_global_id(0);
|
||||
dst[tid] = (int)src[tid];
|
||||
}
|
||||
#endif
|
||||
|
||||
__kernel void sample_test_C(__global float *src, __global int *dst)
|
||||
{
|
||||
size_t tid = get_global_id(0);
|
||||
dst[tid] = (int)src[tid];
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
int test_load_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
@@ -238,7 +264,6 @@ int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_contex
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_load_discreet_length_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
int error;
|
||||
@@ -333,8 +358,9 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_
|
||||
size_t paramSize;
|
||||
cl_uint numInstances;
|
||||
|
||||
|
||||
error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line);
|
||||
test_error(error, "create_single_kernel_helper_create_program failed");
|
||||
|
||||
if( program == NULL )
|
||||
{
|
||||
log_error( "ERROR: Unable to create reference program!\n" );
|
||||
@@ -346,18 +372,9 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_
|
||||
error = clGetProgramInfo( program, CL_PROGRAM_DEVICES, sizeof( device1 ), &device1, NULL );
|
||||
test_error( error, "Unable to get device of program" );
|
||||
|
||||
/* Since the device IDs are opaque types we check the CL_DEVICE_VENDOR_ID which is unique for identical hardware. */
|
||||
cl_uint device1_vid, deviceID_vid;
|
||||
error = clGetDeviceInfo(device1, CL_DEVICE_VENDOR_ID, sizeof(device1_vid), &device1_vid, NULL );
|
||||
test_error( error, "Unable to get device CL_DEVICE_VENDOR_ID" );
|
||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_VENDOR_ID, sizeof(deviceID_vid), &deviceID_vid, NULL );
|
||||
test_error( error, "Unable to get device CL_DEVICE_VENDOR_ID" );
|
||||
|
||||
if( device1_vid != deviceID_vid )
|
||||
{
|
||||
log_error( "ERROR: Incorrect device returned for program! (Expected vendor ID 0x%x, got 0x%x)\n", deviceID_vid, device1_vid );
|
||||
return -1;
|
||||
}
|
||||
/* Object comparability test. */
|
||||
test_assert_error(device1 == deviceID,
|
||||
"Unexpected result returned by CL_PROGRAM_DEVICES query");
|
||||
|
||||
cl_uint devCount;
|
||||
error = clGetProgramInfo( program, CL_PROGRAM_NUM_DEVICES, sizeof( devCount ), &devCount, NULL );
|
||||
@@ -422,6 +439,248 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_get_program_info_kernel_names(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
int error = CL_SUCCESS;
|
||||
size_t total_kernels = 0;
|
||||
size_t kernel_names_len = 0;
|
||||
|
||||
clProgramWrapper program = nullptr;
|
||||
|
||||
// 1) Program without build call. Query CL_PROGRAM_NUM_KERNELS and check
|
||||
// that it fails with CL_INVALID_PROGRAM_EXECUTABLE. Query
|
||||
// CL_PROGRAM_KERNEL_NAMES and check that it fails with
|
||||
// CL_INVALID_PROGRAM_EXECUTABLE.
|
||||
{
|
||||
program = clCreateProgramWithSource(
|
||||
context, 1, &sample_multi_kernel_code_with_macro, nullptr, &error);
|
||||
test_error(error, "clCreateProgramWithSource failed");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS,
|
||||
sizeof(size_t), &total_kernels, nullptr);
|
||||
test_failure_error(error, CL_INVALID_PROGRAM_EXECUTABLE,
|
||||
"Unexpected clGetProgramInfo result");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr,
|
||||
&kernel_names_len);
|
||||
test_failure_error(error, CL_INVALID_PROGRAM_EXECUTABLE,
|
||||
"Unexpected clGetProgramInfo result");
|
||||
}
|
||||
|
||||
// 2) Build the program with the preprocessor macro undefined.
|
||||
// Query CL_PROGRAM_NUM_KERNELS and check that the correct number is
|
||||
// returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right
|
||||
// kernel names are returned.
|
||||
{
|
||||
error =
|
||||
clBuildProgram(program, 1, &deviceID, nullptr, nullptr, nullptr);
|
||||
test_error(error, "clBuildProgram failed");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS,
|
||||
sizeof(size_t), &total_kernels, nullptr);
|
||||
test_error(error, "clGetProgramInfo failed");
|
||||
|
||||
test_assert_error(total_kernels == 2,
|
||||
"Unexpected clGetProgramInfo result");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr,
|
||||
&kernel_names_len);
|
||||
test_error(error, "clGetProgramInfo failed");
|
||||
|
||||
std::vector<std::string> actual_names = { "sample_test_A",
|
||||
"sample_test_C" };
|
||||
|
||||
const size_t len = kernel_names_len + 1;
|
||||
std::vector<char> kernel_names(len, '\0');
|
||||
error =
|
||||
clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len,
|
||||
kernel_names.data(), &kernel_names_len);
|
||||
test_error(error, "Unable to get kernel names list.");
|
||||
|
||||
std::string program_names = kernel_names.data();
|
||||
for (const auto &name : actual_names)
|
||||
{
|
||||
test_assert_error(program_names.find(name) != std::string::npos,
|
||||
"Unexpected kernel name");
|
||||
}
|
||||
|
||||
test_assert_error(program_names.find("sample_test_B")
|
||||
== std::string::npos,
|
||||
"sample_test_B should not be present");
|
||||
}
|
||||
|
||||
// 3) Build the program again with the preprocessor macro defined.
|
||||
// Query CL_PROGRAM_NUM_KERNELS and check that the correct number is
|
||||
// returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right
|
||||
// kernel names are returned.
|
||||
{
|
||||
const char *build_options = "-DUSE_SAMPLE_TEST_B";
|
||||
error = clBuildProgram(program, 1, &deviceID, build_options, nullptr,
|
||||
nullptr);
|
||||
test_error(error, "clBuildProgram failed");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS,
|
||||
sizeof(size_t), &total_kernels, nullptr);
|
||||
test_error(error, "clGetProgramInfo failed");
|
||||
|
||||
test_assert_error(total_kernels == 3,
|
||||
"Unexpected clGetProgramInfo result");
|
||||
|
||||
error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr,
|
||||
&kernel_names_len);
|
||||
test_error(error, "clGetProgramInfo failed");
|
||||
|
||||
std::vector<std::string> actual_names = { "sample_test_A",
|
||||
"sample_test_B",
|
||||
"sample_test_C" };
|
||||
|
||||
const size_t len = kernel_names_len + 1;
|
||||
std::vector<char> kernel_names(len, '\0');
|
||||
error =
|
||||
clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len,
|
||||
kernel_names.data(), &kernel_names_len);
|
||||
test_error(error, "Unable to get kernel names list.");
|
||||
|
||||
std::string program_names = kernel_names.data();
|
||||
for (const auto &name : actual_names)
|
||||
{
|
||||
test_assert_error(program_names.find(name) != std::string::npos,
|
||||
"Unexpected kernel name");
|
||||
}
|
||||
}
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
int test_get_program_info_mult_devices(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
// query multi-device context and perform objects comparability test
|
||||
cl_int err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, 0,
|
||||
nullptr, &size);
|
||||
test_error_fail(err, "clGetDeviceInfo failed");
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
std::vector<cl_device_partition_property> supported_props(
|
||||
size / sizeof(cl_device_partition_property), 0);
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES,
|
||||
supported_props.size()
|
||||
* sizeof(cl_device_partition_property),
|
||||
supported_props.data(), &size);
|
||||
test_error_fail(err, "clGetDeviceInfo failed");
|
||||
|
||||
if (supported_props.empty() || supported_props.front() == 0)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
cl_uint maxComputeUnits = 0;
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
sizeof(maxComputeUnits), &maxComputeUnits, nullptr);
|
||||
test_error_ret(err, "Unable to get maximal number of compute units",
|
||||
TEST_FAIL);
|
||||
|
||||
std::vector<std::array<cl_device_partition_property, 5>> partition_props = {
|
||||
{ CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 },
|
||||
{ CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1,
|
||||
CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 },
|
||||
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
|
||||
CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 }
|
||||
};
|
||||
|
||||
std::unique_ptr<SubDevicesScopeGuarded> scope_guard;
|
||||
cl_uint num_devices = 0;
|
||||
for (auto &sup_prop : supported_props)
|
||||
{
|
||||
for (auto &prop : partition_props)
|
||||
{
|
||||
if (sup_prop == prop[0])
|
||||
{
|
||||
// how many sub-devices can we create?
|
||||
err = clCreateSubDevices(deviceID, prop.data(), 0, nullptr,
|
||||
&num_devices);
|
||||
test_error_fail(err, "clCreateSubDevices failed");
|
||||
if (num_devices < 2) continue;
|
||||
|
||||
// get the list of subDevices
|
||||
scope_guard.reset(new SubDevicesScopeGuarded(num_devices));
|
||||
err = clCreateSubDevices(deviceID, prop.data(), num_devices,
|
||||
scope_guard->sub_devices.data(),
|
||||
&num_devices);
|
||||
test_error_fail(err, "clCreateSubDevices failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scope_guard.get() != nullptr) break;
|
||||
}
|
||||
|
||||
if (scope_guard.get() == nullptr)
|
||||
{
|
||||
log_info("Can't partition device, test not supported\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
/* Create a multi device context */
|
||||
clContextWrapper multi_device_context = clCreateContext(
|
||||
nullptr, (cl_uint)num_devices, scope_guard->sub_devices.data(), nullptr,
|
||||
nullptr, &err);
|
||||
test_error_ret(err, "Unable to create testing context",
|
||||
TEST_SKIPPED_ITSELF);
|
||||
|
||||
clProgramWrapper program = nullptr;
|
||||
err = create_single_kernel_helper_create_program(
|
||||
multi_device_context, &program, 1, sample_kernel_code_single_line);
|
||||
test_error_ret(err, "create_single_kernel_helper_create_program failed",
|
||||
TEST_FAIL);
|
||||
|
||||
if (program == nullptr)
|
||||
{
|
||||
log_error("ERROR: Unable to create reference program!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES, sizeof(num_devices),
|
||||
&num_devices, nullptr);
|
||||
test_error_ret(err, "Unable to get device count of program", TEST_FAIL);
|
||||
|
||||
test_assert_error_ret(
|
||||
num_devices == scope_guard->sub_devices.size(),
|
||||
"Program must be associated to exact number of devices\n", TEST_FAIL);
|
||||
|
||||
std::vector<cl_device_id> devices(num_devices);
|
||||
err = clGetProgramInfo(program, CL_PROGRAM_DEVICES,
|
||||
num_devices * sizeof(cl_device_id), devices.data(),
|
||||
nullptr);
|
||||
test_error_ret(err, "Unable to get devices of program", TEST_FAIL);
|
||||
|
||||
for (cl_uint i = 0; i < devices.size(); i++)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto &it : scope_guard->sub_devices)
|
||||
{
|
||||
if (it == devices[i])
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
test_error_fail(
|
||||
!found, "Unexpected result returned by CL_CONTEXT_DEVICES query");
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
int test_get_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
cl_program program;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -13,33 +13,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/mt19937.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST( partition_equally ),
|
||||
ADD_TEST( partition_by_counts ),
|
||||
ADD_TEST( partition_by_affinity_domain_numa ),
|
||||
ADD_TEST( partition_by_affinity_domain_l4_cache ),
|
||||
ADD_TEST( partition_by_affinity_domain_l3_cache ),
|
||||
ADD_TEST( partition_by_affinity_domain_l2_cache ),
|
||||
ADD_TEST( partition_by_affinity_domain_l1_cache ),
|
||||
ADD_TEST( partition_by_affinity_domain_next_partitionable ),
|
||||
ADD_TEST( partition_all ),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return runTestHarness(argc, argv, test_num, test_list, true, 0);
|
||||
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), true, 0);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,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 "harness/errorHelpers.h"
|
||||
#include "harness/kernelHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/mt19937.h"
|
||||
|
||||
extern int test_partition_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_equally(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_counts(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_numa(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_l4_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_l3_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_l2_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_l1_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_partition_by_affinity_domain_next_partitionable(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -23,9 +23,4 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -416,14 +416,16 @@ int test_device_partition_type_support(cl_device_id parentDevice, const cl_devic
|
||||
return -1;
|
||||
}
|
||||
|
||||
int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, cl_device_partition_property *partition_type,
|
||||
int test_partition_of_device(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
cl_device_partition_property *partition_type,
|
||||
cl_uint starting_property, cl_uint ending_property)
|
||||
{
|
||||
cl_uint maxComputeUnits;
|
||||
cl_uint maxSubDevices; // maximal number of sub-devices that can be created in one call to clCreateSubDevices
|
||||
int err = 0;
|
||||
|
||||
if (init_device_partition_test(deviceID, maxComputeUnits, maxSubDevices) != 0)
|
||||
if (init_device_partition_test(device, maxComputeUnits, maxSubDevices) != 0)
|
||||
return -1;
|
||||
|
||||
if (maxComputeUnits <= 1)
|
||||
@@ -432,10 +434,11 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
if (partition_type != NULL)
|
||||
{ // if we're not the root device
|
||||
size_t psize;
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_TYPE, 0, NULL, &psize);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_TYPE, 0, NULL, &psize);
|
||||
test_error( err, "Unable to get CL_DEVICE_PARTITION_TYPE" );
|
||||
cl_device_partition_property *properties_returned = (cl_device_partition_property *)alloca(psize);
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_TYPE, psize, (void *) properties_returned, NULL);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_TYPE, psize,
|
||||
(void *)properties_returned, NULL);
|
||||
test_error( err, "Unable to get CL_DEVICE_PARTITION_TYPE" );
|
||||
|
||||
// test returned type
|
||||
@@ -480,31 +483,36 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
// loop thru each type, creating sub-devices for each type
|
||||
for (cl_uint i = starting_property;i < ending_property;i++) {
|
||||
|
||||
if (test_device_partition_type_support(deviceID, partitionProp[i][0], partitionProp[i][1]) != 0)
|
||||
{
|
||||
if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN)
|
||||
if (test_device_partition_type_support(device, partitionProp[i][0],
|
||||
partitionProp[i][1])
|
||||
!= 0)
|
||||
{
|
||||
log_info( "Device partition type \"%s\" \"%s\" is not supported on device %p. Skipping test...\n",
|
||||
printPartition(partitionProp[i][0]),
|
||||
printAffinity(partitionProp[i][1]), deviceID);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info( "Device partition type \"%s\" is not supported on device %p. Skipping test...\n",
|
||||
printPartition(partitionProp[i][0]), deviceID);
|
||||
}
|
||||
continue;
|
||||
if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN)
|
||||
{
|
||||
log_info("Device partition type \"%s\" \"%s\" is not supported "
|
||||
"on device %p. Skipping test...\n",
|
||||
printPartition(partitionProp[i][0]),
|
||||
printAffinity(partitionProp[i][1]), device);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Device partition type \"%s\" is not supported on "
|
||||
"device %p. Skipping test...\n",
|
||||
printPartition(partitionProp[i][0]), device);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN)
|
||||
{
|
||||
log_info("Testing on device %p partition type \"%s\" \"%s\"\n", deviceID, printPartition(partitionProp[i][0]),
|
||||
printAffinity(partitionProp[i][1]));
|
||||
log_info("Testing on device %p partition type \"%s\" \"%s\"\n",
|
||||
device, printPartition(partitionProp[i][0]),
|
||||
printAffinity(partitionProp[i][1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Testing on device %p partition type \"%s\" (%d,%d)\n",
|
||||
deviceID, printPartition(partitionProp[i][0]),
|
||||
device, printPartition(partitionProp[i][0]),
|
||||
static_cast<unsigned int>(partitionProp[i][1]),
|
||||
static_cast<unsigned int>(partitionProp[i][2]));
|
||||
}
|
||||
@@ -512,9 +520,9 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
cl_uint deviceCount;
|
||||
|
||||
// how many sub-devices can we create?
|
||||
err = clCreateSubDevices(deviceID, partitionProp[i], 0, NULL, &deviceCount);
|
||||
err = clCreateSubDevices(device, partitionProp[i], 0, NULL, &deviceCount);
|
||||
if ( err == CL_DEVICE_PARTITION_FAILED ) {
|
||||
log_info( "The device %p could not be further partitioned.\n", deviceID );
|
||||
log_info("The device %p could not be further partitioned.\n", device);
|
||||
continue;
|
||||
}
|
||||
test_error( err, "Failed to get number of sub-devices" );
|
||||
@@ -522,7 +530,8 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
// get the list of subDevices
|
||||
// create room for 1 more device_id, so that we can put the parent device in there.
|
||||
cl_device_id *subDevices = (cl_device_id*)alloca(sizeof(cl_device_id) * (deviceCount + 1));
|
||||
err = clCreateSubDevices(deviceID, partitionProp[i], deviceCount, subDevices, &deviceCount);
|
||||
err = clCreateSubDevices(device, partitionProp[i], deviceCount,
|
||||
subDevices, &deviceCount);
|
||||
test_error( err, "Actual creation of sub-devices failed" );
|
||||
|
||||
log_info("Testing on all devices in context\n");
|
||||
@@ -532,8 +541,9 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
log_info("Testing on a parent device for context\n");
|
||||
|
||||
// add the parent device
|
||||
subDevices[deviceCount] = deviceID;
|
||||
err = test_device_set(deviceCount + 1, deviceCount, subDevices, num_elements, &deviceID);
|
||||
subDevices[deviceCount] = device;
|
||||
err = test_device_set(deviceCount + 1, deviceCount, subDevices,
|
||||
num_elements, &device);
|
||||
}
|
||||
if (err != 0)
|
||||
{
|
||||
@@ -557,52 +567,61 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma
|
||||
|
||||
} // for
|
||||
|
||||
log_info("Testing on all device %p finished\n", deviceID);
|
||||
log_info("Testing on all device %p finished\n", device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_partition_equally(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_equally)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 0, 1);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
0, 1);
|
||||
}
|
||||
|
||||
int test_partition_by_counts(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_counts)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 1, 2);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
1, 2);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_numa(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_numa)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 2, 3);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
2, 3);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_l4_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_l4_cache)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 3, 4);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
3, 4);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_l3_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_l3_cache)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 4, 5);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
4, 5);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_l2_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_l2_cache)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 5, 6);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
5, 6);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_l1_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_l1_cache)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 6, 7);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
6, 7);
|
||||
}
|
||||
|
||||
int test_partition_by_affinity_domain_next_partitionable(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_by_affinity_domain_next_partitionable)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 7, 8);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
7, 8);
|
||||
}
|
||||
|
||||
int test_partition_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(partition_all)
|
||||
{
|
||||
return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 0, 8);
|
||||
return test_partition_of_device(device, context, queue, num_elements, NULL,
|
||||
0, 8);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
add_subdirectory( cl_ext_cxx_for_opencl )
|
||||
add_subdirectory( cl_khr_command_buffer )
|
||||
add_subdirectory( cl_khr_dx9_media_sharing )
|
||||
add_subdirectory( cl_khr_external_memory_dma_buf )
|
||||
add_subdirectory( cl_khr_semaphore )
|
||||
add_subdirectory( cl_khr_kernel_clock )
|
||||
if(VULKAN_IS_SUPPORTED)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
set(MODULE_NAME CL_KHR_EXTERNAL_MEMORY_DMA_BUF)
|
||||
|
||||
set(${MODULE_NAME}_SOURCES
|
||||
main.cpp
|
||||
test_external_memory_dma_buf.cpp
|
||||
)
|
||||
|
||||
include(../../CMakeCommon.txt)
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright (c) 2024 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 "harness/testHarness.h"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, 0);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// Copyright (c) 2024 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 <numeric>
|
||||
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
static const char* kernel_function_inc_buffer = R"(
|
||||
kernel void inc_buffer(global uint *src, global uint *imp, global uint *dst)
|
||||
{
|
||||
uint global_id = get_global_id(0);
|
||||
|
||||
imp[global_id] = src[global_id] + 1;
|
||||
dst[global_id] = imp[global_id] + 1;
|
||||
}
|
||||
)";
|
||||
|
||||
/**
|
||||
* Demonstrate the functionality of the cl_khr_external_memory_dma_buf extension
|
||||
* by creating an imported buffer from a DMA buffer, then writing into, and
|
||||
* reading from it.
|
||||
*/
|
||||
|
||||
REGISTER_TEST(external_memory_dma_buf)
|
||||
{
|
||||
if (!is_extension_available(device, "cl_khr_external_memory_dma_buf"))
|
||||
{
|
||||
log_info("The device does not support the "
|
||||
"cl_khr_external_memory_dma_buf extension.\n");
|
||||
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
const size_t buffer_size = static_cast<size_t>(num_elements);
|
||||
const size_t buffer_size_bytes = sizeof(uint32_t) * buffer_size;
|
||||
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
cl_int error;
|
||||
|
||||
error =
|
||||
create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&kernel_function_inc_buffer, "inc_buffer");
|
||||
test_error(error, "Failed to create program with source.");
|
||||
|
||||
/* Source buffer initialisation */
|
||||
std::vector<uint32_t> src_data(buffer_size);
|
||||
// Arithmetic progression starting at 0 and incrementing by 1
|
||||
std::iota(std::begin(src_data), std::end(src_data), 0);
|
||||
|
||||
clMemWrapper src_buffer =
|
||||
clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
buffer_size_bytes, src_data.data(), &error);
|
||||
test_error(error, "Failed to create the source buffer.");
|
||||
|
||||
/* Imported buffer creation */
|
||||
int dma_buf_fd = allocate_dma_buf(buffer_size_bytes);
|
||||
if (dma_buf_fd < 0)
|
||||
{
|
||||
if (dma_buf_fd == TEST_SKIPPED_ITSELF)
|
||||
{
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
log_error(
|
||||
"Failed to obtain a valid DMA buffer file descriptor, got %i.\n",
|
||||
dma_buf_fd);
|
||||
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
const cl_mem_properties ext_mem_properties[] = {
|
||||
CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
|
||||
static_cast<cl_mem_properties>(dma_buf_fd), CL_PROPERTIES_LIST_END_EXT
|
||||
};
|
||||
|
||||
clMemWrapper imp_buffer = clCreateBufferWithProperties(
|
||||
context, ext_mem_properties, CL_MEM_READ_WRITE, buffer_size_bytes,
|
||||
nullptr, &error);
|
||||
test_error(error, "Failed to create the imported buffer.");
|
||||
|
||||
/* Destination buffer creation */
|
||||
clMemWrapper dst_buffer = clCreateBuffer(
|
||||
context, CL_MEM_WRITE_ONLY, buffer_size_bytes, nullptr, &error);
|
||||
test_error(error, "Failed to create the destination buffer.");
|
||||
|
||||
/* Kernel arguments setup */
|
||||
error = clSetKernelArg(kernel, 0, sizeof(src_buffer), &src_buffer);
|
||||
test_error(error, "Failed to set kernel argument 0 to src_buffer.");
|
||||
|
||||
error = clSetKernelArg(kernel, 1, sizeof(imp_buffer), &imp_buffer);
|
||||
test_error(error, "Failed to set kernel argument 1 to imp_buffer.");
|
||||
|
||||
error = clSetKernelArg(kernel, 2, sizeof(dst_buffer), &dst_buffer);
|
||||
test_error(error, "Failed to set kernel argument 2 to dst_buffer.");
|
||||
|
||||
/* Kernel execution */
|
||||
error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &buffer_size,
|
||||
nullptr, 0, nullptr, nullptr);
|
||||
test_error(error, "Failed to enqueue the kernel.");
|
||||
|
||||
error = clFinish(queue);
|
||||
test_error(error, "Failed to finish the queue.");
|
||||
|
||||
/* Verification */
|
||||
std::vector<uint32_t> dst_data(buffer_size, 0);
|
||||
|
||||
error = clEnqueueReadBuffer(queue, dst_buffer, CL_BLOCKING, 0,
|
||||
buffer_size_bytes, dst_data.data(), 0, nullptr,
|
||||
nullptr);
|
||||
test_error(error, "Failed to read the contents of the destination buffer.");
|
||||
|
||||
std::vector<uint32_t> expected_data(buffer_size);
|
||||
std::iota(std::begin(expected_data), std::end(expected_data), 2);
|
||||
|
||||
for (size_t i = 0; i < buffer_size; ++i)
|
||||
{
|
||||
if (dst_data[i] != expected_data[i])
|
||||
{
|
||||
log_error(
|
||||
"Verification failed at index %zu, expected %u but got %u\n", i,
|
||||
expected_data[i], dst_data[i]);
|
||||
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
@@ -119,14 +119,14 @@ static cl_int get_device_semaphore_handle_types(
|
||||
}
|
||||
|
||||
// Confirm the semaphores can be successfully queried
|
||||
int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
|
||||
int test_external_semaphores_queries(cl_device_id device, cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_semaphore");
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -135,13 +135,13 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
|
||||
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
GET_PFN(deviceID, clGetSemaphoreInfoKHR);
|
||||
GET_PFN(deviceID, clReleaseSemaphoreKHR);
|
||||
GET_PFN(deviceID, clRetainSemaphoreKHR);
|
||||
GET_PFN(device, clGetSemaphoreInfoKHR);
|
||||
GET_PFN(device, clReleaseSemaphoreKHR);
|
||||
GET_PFN(device, clRetainSemaphoreKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -156,7 +156,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
|
||||
vkExternalSemaphoreHandleType);
|
||||
|
||||
clExternalImportableSemaphore sema_ext(
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
|
||||
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, device);
|
||||
|
||||
// Needed by the macro
|
||||
cl_semaphore_khr sema = sema_ext.getCLSemaphore();
|
||||
@@ -165,7 +165,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
|
||||
CL_SEMAPHORE_TYPE_BINARY_KHR);
|
||||
|
||||
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id,
|
||||
deviceID);
|
||||
device);
|
||||
|
||||
// Confirm that querying CL_SEMAPHORE_CONTEXT_KHR returns the right
|
||||
// context
|
||||
@@ -199,30 +199,30 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
int test_external_semaphores_cross_context(cl_device_id deviceID,
|
||||
int test_external_semaphores_cross_context(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(deviceID, clCreateSemaphoreWithPropertiesKHR);
|
||||
GET_PFN(deviceID, clGetSemaphoreHandleForTypeKHR);
|
||||
GET_PFN(deviceID, clReleaseSemaphoreKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clCreateSemaphoreWithPropertiesKHR);
|
||||
GET_PFN(device, clGetSemaphoreHandleForTypeKHR);
|
||||
GET_PFN(device, clReleaseSemaphoreKHR);
|
||||
|
||||
std::vector<cl_external_semaphore_handle_type_khr> import_handle_types;
|
||||
std::vector<cl_external_semaphore_handle_type_khr> export_handle_types;
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
err = get_device_semaphore_handle_types(
|
||||
deviceID, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR,
|
||||
device, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR,
|
||||
import_handle_types);
|
||||
test_error(err, "Failed to query import handle types");
|
||||
|
||||
err = get_device_semaphore_handle_types(
|
||||
deviceID, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR,
|
||||
device, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR,
|
||||
export_handle_types);
|
||||
test_error(err, "Failed to query export handle types");
|
||||
|
||||
@@ -243,15 +243,15 @@ int test_external_semaphores_cross_context(cl_device_id deviceID,
|
||||
std::back_inserter(import_export_handle_types));
|
||||
|
||||
cl_context context2 =
|
||||
clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &err);
|
||||
clCreateContext(NULL, 1, &device, notify_callback, NULL, &err);
|
||||
test_error(err, "Failed to create context2");
|
||||
|
||||
clCommandQueueWrapper queue1 =
|
||||
clCreateCommandQueue(context, deviceID, 0, &err);
|
||||
clCreateCommandQueue(context, device, 0, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
clCommandQueueWrapper queue2 =
|
||||
clCreateCommandQueue(context2, deviceID, 0, &err);
|
||||
clCreateCommandQueue(context2, device, 0, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
if (import_export_handle_types.empty())
|
||||
@@ -284,7 +284,7 @@ int test_external_semaphores_cross_context(cl_device_id deviceID,
|
||||
|
||||
cl_semaphore_properties_khr handle =
|
||||
0; // The handle must fit in cl_semaphore_properties_khr
|
||||
err = clGetSemaphoreHandleForTypeKHR(exportable_semaphore, deviceID,
|
||||
err = clGetSemaphoreHandleForTypeKHR(exportable_semaphore, device,
|
||||
handle_type, sizeof(handle),
|
||||
&handle, nullptr);
|
||||
test_error(err, "Failed to export handle from semaphore");
|
||||
@@ -325,13 +325,13 @@ int test_external_semaphores_cross_context(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
// Confirm that a signal followed by a wait will complete successfully
|
||||
int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
|
||||
int test_external_semaphores_simple_1(cl_device_id device, cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -341,12 +341,12 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -363,14 +363,14 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext(raw_sema_ext);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
// Create ooo queue
|
||||
clCommandQueueWrapper queue = clCreateCommandQueue(
|
||||
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Signal semaphore
|
||||
@@ -400,13 +400,13 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
|
||||
|
||||
// Confirm that signal a semaphore with no event dependencies will not result
|
||||
// in an implicit dependency on everything previously submitted
|
||||
int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
|
||||
int test_external_semaphores_simple_2(cl_device_id device, cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -416,12 +416,12 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -437,14 +437,14 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext(raw_sema_ext);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
// Create ooo queue
|
||||
clCommandQueueWrapper queue = clCreateCommandQueue(
|
||||
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Create user event
|
||||
@@ -507,13 +507,13 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
|
||||
}
|
||||
|
||||
// Confirm that a semaphore can be reused multiple times
|
||||
int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
|
||||
int test_external_semaphores_reuse(cl_device_id device, cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -523,12 +523,12 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -544,14 +544,14 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext(raw_sema_ext);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
// Create ooo queue
|
||||
clCommandQueueWrapper queue = clCreateCommandQueue(
|
||||
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Create Kernel
|
||||
@@ -626,14 +626,14 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
|
||||
|
||||
// Helper function that signals and waits on semaphore across two different
|
||||
// queues.
|
||||
static int external_semaphore_cross_queue_helper(cl_device_id deviceID,
|
||||
static int external_semaphore_cross_queue_helper(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue queue_1,
|
||||
cl_command_queue queue_2)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -643,12 +643,12 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -664,7 +664,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext(raw_sema_ext);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
@@ -741,14 +741,14 @@ int test_external_semaphores_cross_queues_io(cl_device_id deviceID,
|
||||
queue_2);
|
||||
}
|
||||
|
||||
int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
|
||||
int test_external_semaphores_cross_queues_io2(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -760,19 +760,19 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
clContextWrapper context2 =
|
||||
clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &err);
|
||||
clCreateContext(NULL, 1, &device, notify_callback, NULL, &err);
|
||||
if (!context2)
|
||||
{
|
||||
print_error(err, "Unable to create testing context");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -788,20 +788,20 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_1 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_1(raw_sema_ext_1);
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_2 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore, context2,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_2(raw_sema_ext_2);
|
||||
|
||||
clCommandQueueWrapper queue1 =
|
||||
clCreateCommandQueue(context, deviceID, 0, &err);
|
||||
clCreateCommandQueue(context, device, 0, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
clCommandQueueWrapper queue2 =
|
||||
clCreateCommandQueue(context2, deviceID, 0, &err);
|
||||
clCreateCommandQueue(context2, device, 0, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Signal semaphore 1
|
||||
@@ -850,14 +850,14 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
// Confirm that we can signal multiple semaphores with one command
|
||||
int test_external_semaphores_multi_signal(cl_device_id deviceID,
|
||||
int test_external_semaphores_multi_signal(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -867,12 +867,12 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -890,19 +890,19 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_1 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore1, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_1(raw_sema_ext_1);
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_2 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore2, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_2(raw_sema_ext_2);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
// Create ooo queue
|
||||
clCommandQueueWrapper queue = clCreateCommandQueue(
|
||||
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Signal semaphore 1 and 2
|
||||
@@ -941,14 +941,13 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
// Confirm that we can wait for multiple semaphores with one command
|
||||
int test_external_semaphores_multi_wait(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
int test_external_semaphores_multi_wait(cl_device_id device, cl_context context,
|
||||
cl_command_queue defaultQueue,
|
||||
int num_elements)
|
||||
{
|
||||
REQUIRE_EXTENSION("cl_khr_external_semaphore");
|
||||
|
||||
if (init_vulkan_device(1, &deviceID))
|
||||
if (init_vulkan_device(1, &device))
|
||||
{
|
||||
log_info("Cannot initialise Vulkan. "
|
||||
"Skipping test.\n");
|
||||
@@ -958,12 +957,12 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID,
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
// Obtain pointers to semaphore's API
|
||||
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
|
||||
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
|
||||
|
||||
std::vector<VulkanExternalSemaphoreHandleType>
|
||||
vkExternalSemaphoreHandleTypeList =
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice);
|
||||
getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice);
|
||||
|
||||
if (vkExternalSemaphoreHandleTypeList.empty())
|
||||
{
|
||||
@@ -981,19 +980,19 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID,
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_1 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore1, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_1(raw_sema_ext_1);
|
||||
|
||||
clExternalSemaphore *raw_sema_ext_2 = NULL;
|
||||
CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore2, context,
|
||||
vkExternalSemaphoreHandleType, deviceID, true);
|
||||
vkExternalSemaphoreHandleType, device, true);
|
||||
std::unique_ptr<clExternalSemaphore> sema_ext_2(raw_sema_ext_2);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
// Create ooo queue
|
||||
clCommandQueueWrapper queue = clCreateCommandQueue(
|
||||
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
|
||||
test_error(err, "Could not create command queue");
|
||||
|
||||
// Signal semaphore 1
|
||||
|
||||
@@ -266,6 +266,15 @@ struct SemaphoreOutOfOrderOps : public SemaphoreTestBase
|
||||
err = clEnqueueBarrierWithWaitList(consumer_queue, 0, nullptr, nullptr);
|
||||
test_error(err, " clEnqueueBarrierWithWaitList ");
|
||||
|
||||
if (!single_queue)
|
||||
{
|
||||
// Both producer and consumer queues run independently.
|
||||
// A blocking call to clEnqueueReadBuffer in consumer_queue will not
|
||||
// flush the producer queue.
|
||||
err = clFlush(producer_queue);
|
||||
test_error(err, "clFlush failed");
|
||||
}
|
||||
|
||||
std::vector<cl_int> host_buffer(num_elems, 0);
|
||||
auto verify_result = [&](const cl_mem &out_mem, const cl_int pattern) {
|
||||
err = clEnqueueReadBuffer(consumer_queue, out_mem, CL_TRUE, 0,
|
||||
|
||||
@@ -15,406 +15,7 @@
|
||||
//
|
||||
#include "../testBase.h"
|
||||
#include <CL/cl.h>
|
||||
|
||||
struct pitch_buffer_data
|
||||
{
|
||||
void *buf;
|
||||
bool is_aligned;
|
||||
};
|
||||
|
||||
static void CL_CALLBACK free_pitch_buffer(cl_mem image, void *data)
|
||||
{
|
||||
pitch_buffer_data *d = static_cast<pitch_buffer_data *>(data);
|
||||
if (d->is_aligned)
|
||||
{
|
||||
align_free(d->buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(d->buf);
|
||||
}
|
||||
free(d);
|
||||
}
|
||||
|
||||
static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf)
|
||||
{
|
||||
clReleaseMemObject((cl_mem)buf);
|
||||
}
|
||||
|
||||
cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr<char>& data, image_descriptor *imageInfo, int *error )
|
||||
{
|
||||
cl_mem img;
|
||||
cl_image_desc imageDesc;
|
||||
cl_mem_flags mem_flags = CL_MEM_READ_ONLY;
|
||||
void *host_ptr = NULL;
|
||||
bool is_host_ptr_aligned = false;
|
||||
|
||||
memset(&imageDesc, 0x0, sizeof(cl_image_desc));
|
||||
imageDesc.image_type = imageInfo->type;
|
||||
imageDesc.image_width = imageInfo->width;
|
||||
imageDesc.image_height = imageInfo->height;
|
||||
imageDesc.image_depth = imageInfo->depth;
|
||||
imageDesc.image_array_size = imageInfo->arraySize;
|
||||
imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0;
|
||||
imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0;
|
||||
imageDesc.num_mip_levels = gTestMipmaps ? imageInfo->num_mip_levels : 0;
|
||||
|
||||
Version version;
|
||||
cl_device_id device;
|
||||
{
|
||||
cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE,
|
||||
sizeof(device), &device, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Could not get CL_QUEUE_DEVICE from queue");
|
||||
return nullptr;
|
||||
}
|
||||
version = get_device_cl_version(device);
|
||||
}
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image %d ...\n", (int)imageInfo->width );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image %d by %d ...\n", (int)imageInfo->width, (int)imageInfo->height );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->height * imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 3D image %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->depth * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image array %d by %d...\n", (int)imageInfo->width, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image array %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 1D buffer image %d ...\n",
|
||||
(int)imageInfo->width);
|
||||
{
|
||||
cl_int err;
|
||||
cl_mem_flags buffer_flags = CL_MEM_READ_WRITE;
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if (version.major() == 1)
|
||||
{
|
||||
host_ptr = malloc(imageInfo->rowPitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
cl_uint base_address_alignment = 0;
|
||||
err = clGetDeviceInfo(
|
||||
device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
|
||||
sizeof(base_address_alignment),
|
||||
&base_address_alignment, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not get "
|
||||
"CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT "
|
||||
"from device");
|
||||
return NULL;
|
||||
}
|
||||
host_ptr = align_malloc(imageInfo->rowPitch,
|
||||
base_address_alignment);
|
||||
is_host_ptr_aligned = true;
|
||||
}
|
||||
buffer_flags |= CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
|
||||
cl_mem buffer = clCreateBuffer(
|
||||
context, buffer_flags, imageInfo->rowPitch, host_ptr, &err);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not create buffer for 1D buffer "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->width);
|
||||
return NULL;
|
||||
}
|
||||
imageDesc.buffer = buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ( gDebugTrace && gTestMipmaps )
|
||||
log_info(" - with %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if ( NULL == host_ptr )
|
||||
{
|
||||
log_error("ERROR: Unable to create backing store for pitched 3D "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->depth * imageInfo->slicePitch);
|
||||
return NULL;
|
||||
}
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
}
|
||||
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
host_ptr, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
nullptr, error);
|
||||
}
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
pitch_buffer_data *data =
|
||||
static_cast<pitch_buffer_data *>(malloc(sizeof(pitch_buffer_data)));
|
||||
data->buf = host_ptr;
|
||||
data->is_aligned = is_host_ptr_aligned;
|
||||
if ( *error == CL_SUCCESS )
|
||||
{
|
||||
int callbackError =
|
||||
clSetMemObjectDestructorCallback(img, free_pitch_buffer, data);
|
||||
if ( CL_SUCCESS != callbackError )
|
||||
{
|
||||
free_pitch_buffer(img, data);
|
||||
log_error( "ERROR: Unable to attach destructor callback to pitched 3D image. Err: %d\n", callbackError );
|
||||
clReleaseMemObject( img );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free_pitch_buffer(img, data);
|
||||
}
|
||||
}
|
||||
|
||||
if (imageDesc.buffer != NULL)
|
||||
{
|
||||
int callbackError = clSetMemObjectDestructorCallback(
|
||||
img, release_cl_buffer, imageDesc.buffer);
|
||||
if (callbackError != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Unable to attach destructor callback to 1d "
|
||||
"buffer image. Err: %d\n",
|
||||
callbackError);
|
||||
clReleaseMemObject(imageDesc.buffer);
|
||||
clReleaseMemObject(img);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( *error != CL_SUCCESS )
|
||||
{
|
||||
long long unsigned imageSize = get_image_size_mb(imageInfo);
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
log_error("ERROR: Unable to create 1D image of size %d (%llu "
|
||||
"MB):(%s)",
|
||||
(int)imageInfo->width, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
log_error("ERROR: Unable to create 2D image of size %d x %d "
|
||||
"(%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
log_error("ERROR: Unable to create 3D image of size %d x %d x "
|
||||
"%d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->depth, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
log_error("ERROR: Unable to create 1D image array of size %d x "
|
||||
"%d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->arraySize,
|
||||
imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
log_error("ERROR: Unable to create 2D image array of size %d x "
|
||||
"%d x %d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->arraySize, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
log_error(
|
||||
"ERROR: Unable to create 1D buffer image of size %d (%llu "
|
||||
"MB):(%s)",
|
||||
(int)imageInfo->width, imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
}
|
||||
log_error("ERROR: and %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Copy the specified data to the image via a Map operation.
|
||||
size_t mappedRow, mappedSlice;
|
||||
size_t width = imageInfo->width;
|
||||
size_t height = 1;
|
||||
size_t depth = 1;
|
||||
size_t row_pitch_lod, slice_pitch_lod;
|
||||
row_pitch_lod = imageInfo->rowPitch;
|
||||
slice_pitch_lod = imageInfo->slicePitch;
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
height = imageInfo->arraySize;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
height = depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = imageInfo->height;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->arraySize;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->depth;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t origin[ 4 ] = { 0, 0, 0, 0 };
|
||||
size_t region[ 3 ] = { imageInfo->width, height, depth };
|
||||
|
||||
for ( size_t lod = 0; (gTestMipmaps && (lod < imageInfo->num_mip_levels)) || (!gTestMipmaps && (lod < 1)); lod++)
|
||||
{
|
||||
// Map the appropriate miplevel to copy the specified data.
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
origin[ 3 ] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
origin[ 2 ] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
origin[ 1 ] = lod;
|
||||
break;
|
||||
}
|
||||
|
||||
//Adjust image dimensions as per miplevel
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
depth = ( imageInfo->depth >> lod ) ? (imageInfo->depth >> lod) : 1;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = ( imageInfo->height >> lod ) ? (imageInfo->height >> lod) : 1;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
width = ( imageInfo->width >> lod ) ? (imageInfo->width >> lod) : 1;
|
||||
}
|
||||
row_pitch_lod = width * get_pixel_size(imageInfo->format);
|
||||
slice_pitch_lod = row_pitch_lod * height;
|
||||
region[0] = width;
|
||||
region[1] = height;
|
||||
region[2] = depth;
|
||||
}
|
||||
|
||||
void* mapped = (char*)clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, error);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to map image for writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
size_t mappedSlicePad = mappedSlice - (mappedRow * height);
|
||||
|
||||
// For 1Darray, the height variable actually contains the arraysize,
|
||||
// so it can't be used for calculating the slice padding.
|
||||
if (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY)
|
||||
mappedSlicePad = mappedSlice - (mappedRow * 1);
|
||||
|
||||
// Copy the image.
|
||||
size_t scanlineSize = row_pitch_lod;
|
||||
size_t sliceSize = slice_pitch_lod - scanlineSize * height;
|
||||
size_t imageSize = scanlineSize * height * depth;
|
||||
size_t data_lod_offset = 0;
|
||||
if( gTestMipmaps )
|
||||
data_lod_offset = compute_mip_level_offset(imageInfo, lod);
|
||||
|
||||
char* src = (char*)data + data_lod_offset;
|
||||
char* dst = (char*)mapped;
|
||||
|
||||
if ((mappedRow == scanlineSize) && (mappedSlicePad==0 || (imageInfo->depth==0 && imageInfo->arraySize==0))) {
|
||||
// Copy the whole image.
|
||||
memcpy( dst, src, imageSize );
|
||||
}
|
||||
else {
|
||||
// Else copy one scan line at a time.
|
||||
size_t dstPitch2D = 0;
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
dstPitch2D = mappedRow;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
dstPitch2D = mappedSlice;
|
||||
break;
|
||||
}
|
||||
for ( size_t z = 0; z < depth; z++ )
|
||||
{
|
||||
for ( size_t y = 0; y < height; y++ )
|
||||
{
|
||||
memcpy( dst, src, scanlineSize );
|
||||
dst += dstPitch2D;
|
||||
src += scanlineSize;
|
||||
}
|
||||
|
||||
// mappedSlicePad is incorrect for 2D images here, but we will exit the z loop before this is a problem.
|
||||
dst += mappedSlicePad;
|
||||
src += sliceSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Unmap the image.
|
||||
*error = clEnqueueUnmapMemObject(queue, img, mapped, 0, NULL, NULL);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to unmap image after writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
#include "../common.h"
|
||||
|
||||
int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d )
|
||||
@@ -463,7 +64,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d
|
||||
if( gDebugTrace )
|
||||
log_info( " - Writing source image...\n" );
|
||||
|
||||
srcImage = create_image( context, queue, srcData, srcImageInfo, &error );
|
||||
srcImage = create_image(context, queue, srcData, srcImageInfo, gEnablePitch,
|
||||
gTestMipmaps, &error);
|
||||
if( srcImage == NULL )
|
||||
return error;
|
||||
|
||||
@@ -508,7 +110,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d
|
||||
if( gDebugTrace )
|
||||
log_info( " - Writing destination image...\n" );
|
||||
|
||||
dstImage = create_image( context, queue, dstData, dstImageInfo, &error );
|
||||
dstImage = create_image(context, queue, dstData, dstImageInfo, gEnablePitch,
|
||||
gTestMipmaps, &error);
|
||||
if( dstImage == NULL )
|
||||
return error;
|
||||
|
||||
|
||||
@@ -14,338 +14,10 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
extern void read_image_pixel_float( void *imageData, image_descriptor *imageInfo, int x, int y, int z, float *outData );
|
||||
#include "../common.h"
|
||||
|
||||
struct pitch_buffer_data
|
||||
{
|
||||
void *buf;
|
||||
bool is_aligned;
|
||||
};
|
||||
static void CL_CALLBACK free_pitch_buffer(cl_mem image, void *data)
|
||||
{
|
||||
struct pitch_buffer_data *d = (struct pitch_buffer_data *)data;
|
||||
if (d->is_aligned)
|
||||
{
|
||||
align_free(d->buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(d->buf);
|
||||
}
|
||||
free(d);
|
||||
}
|
||||
static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf)
|
||||
{
|
||||
clReleaseMemObject((cl_mem)buf);
|
||||
}
|
||||
|
||||
cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr<char>& data, image_descriptor *imageInfo, int *error )
|
||||
{
|
||||
cl_mem img;
|
||||
cl_image_desc imageDesc;
|
||||
cl_mem_flags mem_flags = CL_MEM_READ_ONLY;
|
||||
void *host_ptr = NULL;
|
||||
|
||||
memset(&imageDesc, 0x0, sizeof(cl_image_desc));
|
||||
imageDesc.image_type = imageInfo->type;
|
||||
imageDesc.image_width = imageInfo->width;
|
||||
imageDesc.image_height = imageInfo->height;
|
||||
imageDesc.image_depth = imageInfo->depth;
|
||||
imageDesc.image_array_size = imageInfo->arraySize;
|
||||
imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0;
|
||||
imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0;
|
||||
cl_device_id device;
|
||||
Version version;
|
||||
{
|
||||
cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE,
|
||||
sizeof(device), &device, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Could not get CL_QUEUE_DEVICE from queue");
|
||||
return NULL;
|
||||
}
|
||||
version = get_device_cl_version(device);
|
||||
}
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image %d ...\n", (int)imageInfo->width );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image %d by %d ...\n", (int)imageInfo->width, (int)imageInfo->height );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->height * imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 3D image %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->depth * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image array %d by %d...\n", (int)imageInfo->width, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image array %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 1D buffer image %d ...\n",
|
||||
(int)imageInfo->width);
|
||||
{
|
||||
cl_int err;
|
||||
cl_mem_flags buffer_flags = CL_MEM_READ_WRITE;
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if (version.major() == 1)
|
||||
{
|
||||
host_ptr = malloc(imageInfo->rowPitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
cl_uint base_address_alignment = 0;
|
||||
err = clGetDeviceInfo(
|
||||
device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
|
||||
sizeof(base_address_alignment),
|
||||
&base_address_alignment, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not get "
|
||||
"CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT "
|
||||
"from device");
|
||||
return NULL;
|
||||
}
|
||||
host_ptr = align_malloc(imageInfo->rowPitch,
|
||||
base_address_alignment);
|
||||
}
|
||||
buffer_flags |= CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
cl_mem buffer = clCreateBuffer(
|
||||
context, buffer_flags, imageInfo->rowPitch, host_ptr, &err);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not create buffer for 1D buffer "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->rowPitch);
|
||||
return NULL;
|
||||
}
|
||||
imageDesc.buffer = buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if ( NULL == host_ptr )
|
||||
{
|
||||
log_error("ERROR: Unable to create backing store for pitched 3D "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->depth * imageInfo->slicePitch);
|
||||
return NULL;
|
||||
}
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
}
|
||||
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
host_ptr, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
nullptr, error);
|
||||
}
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
struct pitch_buffer_data *data = (struct pitch_buffer_data *)malloc(
|
||||
sizeof(struct pitch_buffer_data));
|
||||
data->buf = host_ptr;
|
||||
data->is_aligned = (version.major() != 1)
|
||||
&& (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_BUFFER);
|
||||
if (*error == CL_SUCCESS)
|
||||
{
|
||||
int callbackError =
|
||||
clSetMemObjectDestructorCallback(img, free_pitch_buffer, data);
|
||||
if (CL_SUCCESS != callbackError)
|
||||
{
|
||||
free_pitch_buffer(img, data);
|
||||
log_error("ERROR: Unable to attach destructor callback to "
|
||||
"pitched 3D image. Err: %d\n",
|
||||
callbackError);
|
||||
clReleaseMemObject(img);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free_pitch_buffer(img, data);
|
||||
}
|
||||
}
|
||||
|
||||
if (imageDesc.buffer != NULL)
|
||||
{
|
||||
int callbackError = clSetMemObjectDestructorCallback(
|
||||
img, release_cl_buffer, imageDesc.buffer);
|
||||
if (callbackError != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Unable to attach destructor callback to 1d "
|
||||
"buffer image. Err: %d\n",
|
||||
callbackError);
|
||||
clReleaseMemObject(imageDesc.buffer);
|
||||
clReleaseMemObject(img);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( *error != CL_SUCCESS )
|
||||
{
|
||||
long long unsigned imageSize = get_image_size_mb( imageInfo );
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
log_error( "ERROR: Unable to create 1D image of size %d (%llu MB): %s\n", (int)imageInfo->width, imageSize, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
log_error( "ERROR: Unable to create 2D image of size %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, imageSize, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
log_error( "ERROR: Unable to create 3D image of size %d x %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth, imageSize, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
log_error( "ERROR: Unable to create 1D image array of size %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->arraySize, imageSize, IGetErrorString( *error ) );
|
||||
break;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
log_error( "ERROR: Unable to create 2D image array of size %d x %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize, imageSize, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
log_error(
|
||||
"ERROR: Unable to create 1D buffer image of size %d (%llu "
|
||||
"MB):(%s)",
|
||||
(int)imageInfo->width, imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Copy the specified data to the image via a Map operation.
|
||||
size_t mappedRow, mappedSlice;
|
||||
size_t height;
|
||||
size_t depth;
|
||||
size_t imageSize = 0;
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
height = imageInfo->arraySize;
|
||||
depth = 1;
|
||||
imageSize = imageInfo->rowPitch * imageInfo->arraySize;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
height = depth = 1;
|
||||
imageSize = imageInfo->rowPitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = imageInfo->height;
|
||||
depth = 1;
|
||||
imageSize = imageInfo->rowPitch * imageInfo->height;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->arraySize;
|
||||
imageSize = imageInfo->slicePitch * imageInfo->arraySize;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->depth;
|
||||
imageSize = imageInfo->slicePitch * imageInfo->depth;
|
||||
break;
|
||||
default:
|
||||
log_error("ERROR Invalid imageInfo->type = %d\n", imageInfo->type);
|
||||
height = 0;
|
||||
depth = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t origin[ 3 ] = { 0, 0, 0 };
|
||||
size_t region[ 3 ] = { imageInfo->width, height, depth };
|
||||
|
||||
void* mapped = (char*)clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, error);
|
||||
if (*error != CL_SUCCESS || !mapped)
|
||||
{
|
||||
log_error( "ERROR: Unable to map image for writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
size_t mappedSlicePad = mappedSlice - (mappedRow * height);
|
||||
|
||||
// Copy the image.
|
||||
size_t scanlineSize = imageInfo->rowPitch;
|
||||
size_t sliceSize = imageInfo->slicePitch - scanlineSize * height;
|
||||
|
||||
char* src = (char*)data;
|
||||
char* dst = (char*)mapped;
|
||||
|
||||
if ((mappedRow == scanlineSize) && ((mappedSlice == imageInfo->slicePitch) || (imageInfo->depth==0 && imageInfo->arraySize==0))) {
|
||||
// Copy the whole image.
|
||||
memcpy( dst, src, imageSize );
|
||||
}
|
||||
else {
|
||||
// Else copy one scan line at a time.
|
||||
size_t dstPitch2D = 0;
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
dstPitch2D = mappedRow;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER: dstPitch2D = mappedSlice; break;
|
||||
}
|
||||
|
||||
for ( size_t z = 0; z < depth; z++ )
|
||||
{
|
||||
for ( size_t y = 0; y < height; y++ )
|
||||
{
|
||||
memcpy( dst, src, imageInfo->width * get_pixel_size(imageInfo->format) );
|
||||
dst += dstPitch2D;
|
||||
src += scanlineSize;
|
||||
}
|
||||
|
||||
// mappedSlicePad is incorrect for 2D images here, but we will exit the z loop before this is a problem.
|
||||
dst += mappedSlicePad;
|
||||
src += sliceSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Unmap the image.
|
||||
*error = clEnqueueUnmapMemObject(queue, img, mapped, 0, NULL, NULL);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to unmap image after writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
extern void read_image_pixel_float(void *imageData, image_descriptor *imageInfo,
|
||||
int x, int y, int z, float *outData);
|
||||
|
||||
static void fill_region_with_value( image_descriptor *imageInfo, void *imageValues,
|
||||
void *value, const size_t origin[], const size_t region[] )
|
||||
@@ -438,7 +110,8 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating image...\n" );
|
||||
|
||||
image = create_image( context, queue, imgData, imageInfo, &error );
|
||||
image = create_image(context, queue, imgData, imageInfo, gEnablePitch,
|
||||
false, &error);
|
||||
if ( image == NULL )
|
||||
return error;
|
||||
|
||||
|
||||
@@ -146,3 +146,446 @@ size_t random_in_ranges(size_t minimum, size_t rangeA, size_t rangeB, MTdata d)
|
||||
if (rangeA < minimum) return rangeA;
|
||||
return (size_t)random_in_range((int)minimum, (int)rangeA - 1, d);
|
||||
}
|
||||
|
||||
using free_function_t = void (*)(void *);
|
||||
struct pitch_buffer_data
|
||||
{
|
||||
void *buf;
|
||||
free_function_t free_fn;
|
||||
|
||||
static void CL_CALLBACK free_buffer(cl_mem, void *data)
|
||||
{
|
||||
pitch_buffer_data *d = static_cast<pitch_buffer_data *>(data);
|
||||
d->free_fn(d->buf);
|
||||
delete d;
|
||||
}
|
||||
};
|
||||
|
||||
static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf)
|
||||
{
|
||||
clReleaseMemObject((cl_mem)buf);
|
||||
}
|
||||
|
||||
clMemWrapper create_image(cl_context context, cl_command_queue queue,
|
||||
BufferOwningPtr<char> &data,
|
||||
image_descriptor *imageInfo, bool enable_pitch,
|
||||
bool create_mipmaps, int *error)
|
||||
{
|
||||
cl_mem img;
|
||||
cl_image_desc imageDesc;
|
||||
cl_mem_flags mem_flags = CL_MEM_READ_ONLY;
|
||||
void *host_ptr = nullptr;
|
||||
bool is_host_ptr_aligned = false;
|
||||
|
||||
memset(&imageDesc, 0x0, sizeof(cl_image_desc));
|
||||
imageDesc.image_type = imageInfo->type;
|
||||
imageDesc.image_width = imageInfo->width;
|
||||
imageDesc.image_height = imageInfo->height;
|
||||
imageDesc.image_depth = imageInfo->depth;
|
||||
imageDesc.image_array_size = imageInfo->arraySize;
|
||||
imageDesc.image_row_pitch = enable_pitch ? imageInfo->rowPitch : 0;
|
||||
imageDesc.image_slice_pitch = enable_pitch ? imageInfo->slicePitch : 0;
|
||||
imageDesc.num_mip_levels = create_mipmaps ? imageInfo->num_mip_levels : 0;
|
||||
|
||||
Version version;
|
||||
cl_device_id device;
|
||||
{
|
||||
cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE,
|
||||
sizeof(device), &device, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Could not get CL_QUEUE_DEVICE from queue");
|
||||
return nullptr;
|
||||
}
|
||||
version = get_device_cl_version(device);
|
||||
}
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 1D image %d ...\n",
|
||||
(int)imageInfo->width);
|
||||
if (enable_pitch) host_ptr = malloc(imageInfo->rowPitch);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 2D image %d by %d ...\n",
|
||||
(int)imageInfo->width, (int)imageInfo->height);
|
||||
if (enable_pitch)
|
||||
host_ptr = malloc(imageInfo->height * imageInfo->rowPitch);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 3D image %d by %d by %d...\n",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->depth);
|
||||
if (enable_pitch)
|
||||
host_ptr = malloc(imageInfo->depth * imageInfo->slicePitch);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 1D image array %d by %d...\n",
|
||||
(int)imageInfo->width, (int)imageInfo->arraySize);
|
||||
if (enable_pitch)
|
||||
host_ptr = malloc(imageInfo->arraySize * imageInfo->slicePitch);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 2D image array %d by %d by %d...\n",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->arraySize);
|
||||
if (enable_pitch)
|
||||
host_ptr = malloc(imageInfo->arraySize * imageInfo->slicePitch);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
if (gDebugTrace)
|
||||
log_info(" - Creating 1D buffer image %d ...\n",
|
||||
(int)imageInfo->width);
|
||||
{
|
||||
cl_int err;
|
||||
cl_mem_flags buffer_flags = CL_MEM_READ_WRITE;
|
||||
if (enable_pitch)
|
||||
{
|
||||
if (version.major() == 1)
|
||||
{
|
||||
host_ptr = malloc(imageInfo->rowPitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
cl_uint base_address_alignment = 0;
|
||||
err = clGetDeviceInfo(
|
||||
device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
|
||||
sizeof(base_address_alignment),
|
||||
&base_address_alignment, nullptr);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not get "
|
||||
"CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT "
|
||||
"from device");
|
||||
return nullptr;
|
||||
}
|
||||
host_ptr = align_malloc(imageInfo->rowPitch,
|
||||
base_address_alignment);
|
||||
is_host_ptr_aligned = true;
|
||||
}
|
||||
buffer_flags |= CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
|
||||
cl_mem buffer = clCreateBuffer(
|
||||
context, buffer_flags, imageInfo->rowPitch, host_ptr, &err);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Could not create buffer for 1D buffer "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->width);
|
||||
if (host_ptr)
|
||||
{
|
||||
if (is_host_ptr_aligned)
|
||||
{
|
||||
align_free(host_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(host_ptr);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
imageDesc.buffer = buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (gDebugTrace && create_mipmaps)
|
||||
log_info(" - with %llu mip levels\n",
|
||||
(unsigned long long)imageInfo->num_mip_levels);
|
||||
|
||||
if (enable_pitch)
|
||||
{
|
||||
if (nullptr == host_ptr)
|
||||
{
|
||||
log_error("ERROR: Unable to create backing store for pitched 3D "
|
||||
"image. %zu bytes\n",
|
||||
imageInfo->depth * imageInfo->slicePitch);
|
||||
return nullptr;
|
||||
}
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
}
|
||||
|
||||
if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER)
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
host_ptr, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc,
|
||||
nullptr, error);
|
||||
}
|
||||
|
||||
if (enable_pitch)
|
||||
{
|
||||
free_function_t free_fn = is_host_ptr_aligned ? align_free : free;
|
||||
if (*error == CL_SUCCESS)
|
||||
{
|
||||
pitch_buffer_data *buf_data = new pitch_buffer_data;
|
||||
buf_data->buf = host_ptr;
|
||||
buf_data->free_fn = free_fn;
|
||||
|
||||
int callbackError = clSetMemObjectDestructorCallback(
|
||||
img, pitch_buffer_data::free_buffer, buf_data);
|
||||
if (CL_SUCCESS != callbackError)
|
||||
{
|
||||
pitch_buffer_data::free_buffer(img, buf_data);
|
||||
log_error("ERROR: Unable to attach destructor callback to "
|
||||
"pitched 3D image. Err: %d\n",
|
||||
callbackError);
|
||||
clReleaseMemObject(img);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free_fn(host_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (imageDesc.buffer != nullptr)
|
||||
{
|
||||
int callbackError = clSetMemObjectDestructorCallback(
|
||||
img, release_cl_buffer, imageDesc.buffer);
|
||||
if (callbackError != CL_SUCCESS)
|
||||
{
|
||||
log_error("Error: Unable to attach destructor callback to 1d "
|
||||
"buffer image. Err: %d\n",
|
||||
callbackError);
|
||||
clReleaseMemObject(imageDesc.buffer);
|
||||
clReleaseMemObject(img);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
long long unsigned imageSize = get_image_size_mb(imageInfo);
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
log_error("ERROR: Unable to create 1D image of size %d (%llu "
|
||||
"MB):(%s)",
|
||||
(int)imageInfo->width, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
log_error("ERROR: Unable to create 2D image of size %d x %d "
|
||||
"(%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
log_error("ERROR: Unable to create 3D image of size %d x %d x "
|
||||
"%d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->depth, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
log_error("ERROR: Unable to create 1D image array of size %d x "
|
||||
"%d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->arraySize,
|
||||
imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
log_error("ERROR: Unable to create 2D image array of size %d x "
|
||||
"%d x %d (%llu MB):(%s)",
|
||||
(int)imageInfo->width, (int)imageInfo->height,
|
||||
(int)imageInfo->arraySize, imageSize,
|
||||
IGetErrorString(*error));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
log_error(
|
||||
"ERROR: Unable to create 1D buffer image of size %d (%llu "
|
||||
"MB):(%s)",
|
||||
(int)imageInfo->width, imageSize, IGetErrorString(*error));
|
||||
break;
|
||||
}
|
||||
log_error("ERROR: and %llu mip levels\n",
|
||||
(unsigned long long)imageInfo->num_mip_levels);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Copy the specified data to the image via a Map operation.
|
||||
size_t mappedRow, mappedSlice;
|
||||
size_t width = imageInfo->width;
|
||||
size_t height = 1;
|
||||
size_t depth = 1;
|
||||
size_t row_pitch_lod, slice_pitch_lod;
|
||||
row_pitch_lod = imageInfo->rowPitch;
|
||||
slice_pitch_lod = imageInfo->slicePitch;
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
height = imageInfo->arraySize;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D: height = depth = 1; break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = imageInfo->height;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->arraySize;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->depth;
|
||||
break;
|
||||
default:
|
||||
log_error("ERROR Invalid imageInfo->type = %d\n", imageInfo->type);
|
||||
height = 0;
|
||||
depth = 0;
|
||||
return nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t origin[4] = { 0, 0, 0, 0 };
|
||||
size_t region[3] = { imageInfo->width, height, depth };
|
||||
|
||||
for (size_t lod = 0; (create_mipmaps && (lod < imageInfo->num_mip_levels))
|
||||
|| (!create_mipmaps && (lod < 1));
|
||||
lod++)
|
||||
{
|
||||
// Map the appropriate miplevel to copy the specified data.
|
||||
if (create_mipmaps)
|
||||
{
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
origin[0] = origin[1] = origin[2] = 0;
|
||||
origin[3] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
origin[0] = origin[1] = origin[3] = 0;
|
||||
origin[2] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
origin[0] = origin[2] = origin[3] = 0;
|
||||
origin[1] = lod;
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust image dimensions as per miplevel
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
depth = (imageInfo->depth >> lod)
|
||||
? (imageInfo->depth >> lod)
|
||||
: 1;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = (imageInfo->height >> lod)
|
||||
? (imageInfo->height >> lod)
|
||||
: 1;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
width = (imageInfo->width >> lod)
|
||||
? (imageInfo->width >> lod)
|
||||
: 1;
|
||||
}
|
||||
row_pitch_lod = width * get_pixel_size(imageInfo->format);
|
||||
slice_pitch_lod = row_pitch_lod * height;
|
||||
region[0] = width;
|
||||
region[1] = height;
|
||||
region[2] = depth;
|
||||
}
|
||||
|
||||
char *mapped = static_cast<char *>(clEnqueueMapImage(
|
||||
queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow,
|
||||
&mappedSlice, 0, nullptr, nullptr, error));
|
||||
if (*error != CL_SUCCESS || !mapped)
|
||||
{
|
||||
log_error("ERROR: Unable to map image for writing: %s\n",
|
||||
IGetErrorString(*error));
|
||||
return nullptr;
|
||||
}
|
||||
size_t mappedSlicePad = mappedSlice - (mappedRow * height);
|
||||
|
||||
// For 1Darray, the height variable actually contains the arraysize,
|
||||
// so it can't be used for calculating the slice padding.
|
||||
if (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY)
|
||||
mappedSlicePad = mappedSlice - (mappedRow * 1);
|
||||
|
||||
// Copy the image.
|
||||
size_t scanlineSize = row_pitch_lod;
|
||||
size_t sliceSize = slice_pitch_lod - scanlineSize * height;
|
||||
size_t imageSize = scanlineSize * height * depth;
|
||||
size_t data_lod_offset = 0;
|
||||
if (create_mipmaps)
|
||||
{
|
||||
data_lod_offset = compute_mip_level_offset(imageInfo, lod);
|
||||
}
|
||||
|
||||
char *src = static_cast<char *>(data) + data_lod_offset;
|
||||
char *dst = mapped;
|
||||
|
||||
if ((mappedRow == scanlineSize)
|
||||
&& (mappedSlicePad == 0
|
||||
|| (imageInfo->depth == 0 && imageInfo->arraySize == 0)))
|
||||
{
|
||||
// Copy the whole image.
|
||||
memcpy(dst, src, imageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Else copy one scan line at a time.
|
||||
size_t dstPitch2D = 0;
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D: dstPitch2D = mappedRow; break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
dstPitch2D = mappedSlice;
|
||||
break;
|
||||
}
|
||||
for (size_t z = 0; z < depth; z++)
|
||||
{
|
||||
for (size_t y = 0; y < height; y++)
|
||||
{
|
||||
memcpy(dst, src, scanlineSize);
|
||||
dst += dstPitch2D;
|
||||
src += scanlineSize;
|
||||
}
|
||||
|
||||
// mappedSlicePad is incorrect for 2D images here, but we will
|
||||
// exit the z loop before this is a problem.
|
||||
dst += mappedSlicePad;
|
||||
src += sliceSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Unmap the image.
|
||||
*error =
|
||||
clEnqueueUnmapMemObject(queue, img, mapped, 0, nullptr, nullptr);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error("ERROR: Unable to unmap image after writing: %s\n",
|
||||
IGetErrorString(*error));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
@@ -50,4 +50,9 @@ int get_format_list(cl_context context, cl_mem_object_type imageType,
|
||||
cl_mem_flags flags);
|
||||
size_t random_in_ranges(size_t minimum, size_t rangeA, size_t rangeB, MTdata d);
|
||||
|
||||
clMemWrapper create_image(cl_context context, cl_command_queue queue,
|
||||
BufferOwningPtr<char> &data,
|
||||
image_descriptor *imageInfo, bool enable_pitch,
|
||||
bool create_mipmaps, int *error);
|
||||
|
||||
#endif // IMAGES_COMMON_H
|
||||
|
||||
@@ -214,12 +214,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_double *s;
|
||||
cl_double *s2;
|
||||
|
||||
bool reciprocal = strcmp(name, "reciprocal") == 0;
|
||||
const double reciprocalArrayX[] = { 1.0 };
|
||||
const double *specialValuesX =
|
||||
reciprocal ? reciprocalArrayX : specialValues;
|
||||
size_t specialValuesCountX = reciprocal ? 1 : specialValuesCount;
|
||||
|
||||
Force64BitFPUPrecision();
|
||||
|
||||
cl_event e[VECTOR_SIZE_COUNT];
|
||||
@@ -248,7 +242,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements;
|
||||
cl_ulong *p2 = (cl_ulong *)gIn2 + thread_id * buffer_elements;
|
||||
cl_uint idx = 0;
|
||||
int totalSpecialValueCount = specialValuesCountX * specialValuesCount;
|
||||
int totalSpecialValueCount = specialValuesCount * specialValuesCount;
|
||||
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
|
||||
|
||||
// Test edge cases
|
||||
@@ -258,15 +252,14 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_double *fp2 = (cl_double *)p2;
|
||||
uint32_t x, y;
|
||||
|
||||
x = (job_id * buffer_elements) % specialValuesCountX;
|
||||
x = (job_id * buffer_elements) % specialValuesCount;
|
||||
y = (job_id * buffer_elements) / specialValuesCount;
|
||||
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
fp[idx] = specialValuesX[x];
|
||||
fp[idx] = specialValues[x];
|
||||
fp2[idx] = specialValues[y];
|
||||
++x;
|
||||
if (x >= specialValuesCountX)
|
||||
if (++x >= specialValuesCount)
|
||||
{
|
||||
x = 0;
|
||||
y++;
|
||||
@@ -278,8 +271,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
// Init any remaining values
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
p[idx] =
|
||||
reciprocal ? ((cl_ulong *)specialValuesX)[0] : genrand_int64(d);
|
||||
p[idx] = genrand_int64(d);
|
||||
p2[idx] = genrand_int64(d);
|
||||
}
|
||||
|
||||
@@ -372,13 +364,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
r = (cl_double *)gOut_Ref + thread_id * buffer_elements;
|
||||
s = (cl_double *)gIn + thread_id * buffer_elements;
|
||||
s2 = (cl_double *)gIn2 + thread_id * buffer_elements;
|
||||
|
||||
if (reciprocal)
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (float)func.f_f(s2[j]);
|
||||
else
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (cl_double)func.f_ff(s[j], s2[j]);
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (cl_double)func.f_ff(s[j], s2[j]);
|
||||
|
||||
// Read the data back -- no need to wait for the first N-1 buffers but wait
|
||||
// for the last buffer. This is an in order queue.
|
||||
@@ -408,9 +395,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if (t[j] != q[j])
|
||||
{
|
||||
cl_double test = ((cl_double *)q)[j];
|
||||
long double correct =
|
||||
reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]);
|
||||
|
||||
long double correct = func.f_ff(s[j], s2[j]);
|
||||
float err = Bruteforce_Ulp_Error_Double(test, correct);
|
||||
int fail = !(fabsf(err) <= ulps);
|
||||
|
||||
@@ -483,11 +468,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
else if (IsDoubleSubnormal(s2[j]))
|
||||
{
|
||||
long double correct2 =
|
||||
reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0);
|
||||
long double correct3 =
|
||||
reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0);
|
||||
|
||||
long double correct2 = func.f_ff(s[j], 0.0);
|
||||
long double correct3 = func.f_ff(s[j], -0.0);
|
||||
float err2 =
|
||||
Bruteforce_Ulp_Error_Double(test, correct2);
|
||||
float err3 =
|
||||
|
||||
@@ -208,11 +208,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_float *s2 = 0;
|
||||
RoundingMode oldRoundMode;
|
||||
|
||||
bool reciprocal = strcmp(name, "reciprocal") == 0;
|
||||
const float reciprocalArrayX[] = { 1.f };
|
||||
const float *specialValuesX = reciprocal ? reciprocalArrayX : specialValues;
|
||||
size_t specialValuesCountX = reciprocal ? 1 : specialValuesCount;
|
||||
|
||||
if (relaxedMode)
|
||||
{
|
||||
func = job->f->rfunc;
|
||||
@@ -244,7 +239,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
|
||||
cl_uint *p2 = (cl_uint *)gIn2 + thread_id * buffer_elements;
|
||||
cl_uint idx = 0;
|
||||
int totalSpecialValueCount = specialValuesCountX * specialValuesCount;
|
||||
int totalSpecialValueCount = specialValuesCount * specialValuesCount;
|
||||
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
|
||||
|
||||
if (job_id <= (cl_uint)lastSpecialJobIndex)
|
||||
@@ -252,15 +247,15 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
// Insert special values
|
||||
uint32_t x, y;
|
||||
|
||||
x = (job_id * buffer_elements) % specialValuesCountX;
|
||||
x = (job_id * buffer_elements) % specialValuesCount;
|
||||
y = (job_id * buffer_elements) / specialValuesCount;
|
||||
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
p[idx] = ((cl_uint *)specialValuesX)[x];
|
||||
p[idx] = ((cl_uint *)specialValues)[x];
|
||||
p2[idx] = ((cl_uint *)specialValues)[y];
|
||||
++x;
|
||||
if (x >= specialValuesCountX)
|
||||
if (x >= specialValuesCount)
|
||||
{
|
||||
x = 0;
|
||||
y++;
|
||||
@@ -274,19 +269,13 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if (pj < 0x20800000 || pj > 0x5e800000) p[idx] = 0x7fc00000;
|
||||
if (p2j < 0x20800000 || p2j > 0x5e800000) p2[idx] = 0x7fc00000;
|
||||
}
|
||||
else if (relaxedMode && reciprocal)
|
||||
{
|
||||
cl_uint p2j = p2[idx] & 0x7fffffff;
|
||||
// Replace values outside [2^-126, 2^126] with QNaN
|
||||
if (p2j < 0x00807d99 || p2j > 0x7e800000) p2[idx] = 0x7fc00000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init any remaining values
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
p[idx] = reciprocal ? ((cl_uint *)specialValuesX)[0] : genrand_int32(d);
|
||||
p[idx] = genrand_int32(d);
|
||||
p2[idx] = genrand_int32(d);
|
||||
|
||||
if (relaxedMode && strcmp(name, "divide") == 0)
|
||||
@@ -297,12 +286,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if (pj < 0x20800000 || pj > 0x5e800000) p[idx] = 0x7fc00000;
|
||||
if (p2j < 0x20800000 || p2j > 0x5e800000) p2[idx] = 0x7fc00000;
|
||||
}
|
||||
else if (relaxedMode && reciprocal)
|
||||
{
|
||||
cl_uint p2j = p2[idx] & 0x7fffffff;
|
||||
// Replace values outside [2^-126, 2^126] with QNaN
|
||||
if (p2j < 0x00807d99 || p2j > 0x7e800000) p2[idx] = 0x7fc00000;
|
||||
}
|
||||
}
|
||||
|
||||
if ((error = clEnqueueWriteBuffer(tinfo->tQueue, tinfo->inBuf, CL_FALSE, 0,
|
||||
@@ -408,31 +391,18 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
s2 = (float *)gIn2 + thread_id * buffer_elements;
|
||||
if (gInfNanSupport)
|
||||
{
|
||||
if (reciprocal)
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (float)func.f_f(s2[j]);
|
||||
else
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (float)func.f_ff(s[j], s2[j]);
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
r[j] = (float)func.f_ff(s[j], s2[j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reciprocal)
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
r[j] = (float)func.f_f(s2[j]);
|
||||
overflow[j] =
|
||||
FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW));
|
||||
}
|
||||
else
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
r[j] = (float)func.f_ff(s[j], s2[j]);
|
||||
overflow[j] =
|
||||
FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW));
|
||||
}
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
r[j] = (float)func.f_ff(s[j], s2[j]);
|
||||
overflow[j] =
|
||||
FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW));
|
||||
}
|
||||
}
|
||||
|
||||
if (gIsInRTZMode) (void)set_round(oldRoundMode, kfloat);
|
||||
@@ -467,8 +437,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if (t[j] != q[j])
|
||||
{
|
||||
float test = ((float *)q)[j];
|
||||
double correct =
|
||||
reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]);
|
||||
double correct = func.f_ff(s[j], s2[j]);
|
||||
|
||||
// Per section 10 paragraph 6, accept any result if an input or
|
||||
// output is a infinity or NaN or overflow
|
||||
@@ -505,7 +474,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
|
||||
// retry per section 6.5.3.3
|
||||
if (!reciprocal && IsFloatSubnormal(s[j]))
|
||||
if (IsFloatSubnormal(s[j]))
|
||||
{
|
||||
double correct2, correct3;
|
||||
float err2, err3;
|
||||
@@ -611,10 +580,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
|
||||
if (!gInfNanSupport) feclearexcept(FE_OVERFLOW);
|
||||
|
||||
correct2 =
|
||||
reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0);
|
||||
correct3 =
|
||||
reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0);
|
||||
correct2 = func.f_ff(s[j], 0.0);
|
||||
correct3 = func.f_ff(s[j], -0.0);
|
||||
|
||||
// Per section 10 paragraph 6, accept any result if an
|
||||
// input or output is a infinity or NaN or overflow
|
||||
@@ -647,6 +614,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fabsf(err) > tinfo->maxError)
|
||||
{
|
||||
tinfo->maxError = fabsf(err);
|
||||
|
||||
@@ -120,12 +120,6 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
std::vector<float> s(0), s2(0);
|
||||
RoundingMode oldRoundMode;
|
||||
|
||||
bool reciprocal = strcmp(name, "reciprocal") == 0;
|
||||
const cl_half reciprocalArrayHalfX[] = { 0x3c00 };
|
||||
const cl_half *specialValuesHalfX =
|
||||
reciprocal ? reciprocalArrayHalfX : specialValuesHalf;
|
||||
size_t specialValuesHalfCountX = reciprocal ? 1 : specialValuesHalfCount;
|
||||
|
||||
cl_event e[VECTOR_SIZE_COUNT];
|
||||
cl_half *out[VECTOR_SIZE_COUNT];
|
||||
|
||||
@@ -154,7 +148,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_half *p2 = (cl_half *)gIn2 + thread_id * buffer_elements;
|
||||
cl_uint idx = 0;
|
||||
int totalSpecialValueCount =
|
||||
specialValuesHalfCountX * specialValuesHalfCount;
|
||||
specialValuesHalfCount * specialValuesHalfCount;
|
||||
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
|
||||
|
||||
if (job_id <= (cl_uint)lastSpecialJobIndex)
|
||||
@@ -162,15 +156,14 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
// Insert special values
|
||||
uint32_t x, y;
|
||||
|
||||
x = (job_id * buffer_elements) % specialValuesHalfCountX;
|
||||
x = (job_id * buffer_elements) % specialValuesHalfCount;
|
||||
y = (job_id * buffer_elements) / specialValuesHalfCount;
|
||||
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
p[idx] = specialValuesHalfX[x];
|
||||
p[idx] = specialValuesHalf[x];
|
||||
p2[idx] = specialValuesHalf[y];
|
||||
++x;
|
||||
if (x >= specialValuesHalfCountX)
|
||||
if (++x >= specialValuesHalfCount)
|
||||
{
|
||||
x = 0;
|
||||
y++;
|
||||
@@ -182,8 +175,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
// Init any remaining values
|
||||
for (; idx < buffer_elements; idx++)
|
||||
{
|
||||
p[idx] = reciprocal ? ((cl_half *)specialValuesHalfX)[0]
|
||||
: (cl_half)genrand_int32(d);
|
||||
p[idx] = (cl_half)genrand_int32(d);
|
||||
p2[idx] = (cl_half)genrand_int32(d);
|
||||
}
|
||||
if ((error = clEnqueueWriteBuffer(tinfo->tQueue, tinfo->inBuf, CL_FALSE, 0,
|
||||
@@ -280,23 +272,11 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
s.resize(buffer_elements);
|
||||
s2.resize(buffer_elements);
|
||||
|
||||
if (reciprocal)
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
s[j] = HTF(p[j]);
|
||||
s2[j] = HTF(p2[j]);
|
||||
r[j] = HFF(func.f_f(s2[j]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
s[j] = HTF(p[j]);
|
||||
s2[j] = HTF(p2[j]);
|
||||
r[j] = HFF(func.f_ff(s[j], s2[j]));
|
||||
}
|
||||
s[j] = HTF(p[j]);
|
||||
s2[j] = HTF(p2[j]);
|
||||
r[j] = HFF(func.f_ff(s[j], s2[j]));
|
||||
}
|
||||
|
||||
if (ftz) RestoreFPState(&oldMode);
|
||||
@@ -329,8 +309,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if (r[j] != q[j])
|
||||
{
|
||||
float test = HTF(q[j]);
|
||||
float correct =
|
||||
reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]);
|
||||
float correct = func.f_ff(s[j], s2[j]);
|
||||
|
||||
// Per section 10 paragraph 6, accept any result if an input or
|
||||
// output is a infinity or NaN or overflow
|
||||
@@ -456,10 +435,9 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
double correct2, correct3;
|
||||
float err2, err3;
|
||||
|
||||
correct2 =
|
||||
reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0);
|
||||
correct3 =
|
||||
reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0);
|
||||
correct2 = func.f_ff(s[j], 0.0);
|
||||
correct3 = func.f_ff(s[j], -0.0);
|
||||
|
||||
|
||||
// Per section 10 paragraph 6, accept any result if an
|
||||
// input or output is a infinity or NaN or overflow
|
||||
|
||||
@@ -427,9 +427,8 @@ const Func functionList[] = {
|
||||
// basic operations
|
||||
OPERATOR_ENTRY(add, "+", 0.0f, 0.0f, 0.0f, 0.0f, FTZ_OFF, binaryOperatorF),
|
||||
OPERATOR_ENTRY(subtract, "-", 0.0f, 0.0f, 0.0f, 0.0f, FTZ_OFF, binaryOperatorF),
|
||||
//ENTRY(reciprocal, 1.0f, 1.0f, FTZ_OFF, unaryF),
|
||||
{ "reciprocal",
|
||||
"/",
|
||||
"reciprocal",
|
||||
{ (void*)reference_reciprocal },
|
||||
{ (void*)reference_reciprocall },
|
||||
{ (void*)reference_relaxed_reciprocal },
|
||||
@@ -442,7 +441,7 @@ const Func functionList[] = {
|
||||
INFINITY,
|
||||
FTZ_OFF,
|
||||
RELAXED_ON,
|
||||
binaryOperatorF },
|
||||
unaryF},
|
||||
{ "divide",
|
||||
"/",
|
||||
{ (void*)reference_divide },
|
||||
|
||||
@@ -1641,6 +1641,7 @@ double reference_expm1(double x)
|
||||
double reference_fmax(double x, double y)
|
||||
{
|
||||
if (isnan(y)) return x;
|
||||
if (isnan(x)) return y;
|
||||
|
||||
return x >= y ? x : y;
|
||||
}
|
||||
@@ -1648,6 +1649,7 @@ double reference_fmax(double x, double y)
|
||||
double reference_fmin(double x, double y)
|
||||
{
|
||||
if (isnan(y)) return x;
|
||||
if (isnan(x)) return y;
|
||||
|
||||
return x <= y ? x : y;
|
||||
}
|
||||
@@ -2732,6 +2734,34 @@ static double round_to_nearest_even_double(cl_ulong hi, cl_ulong lo,
|
||||
return u.d;
|
||||
}
|
||||
|
||||
static double round_toward_zero_double(cl_ulong hi, cl_ulong lo, int exponent)
|
||||
{
|
||||
union {
|
||||
cl_ulong u;
|
||||
cl_double d;
|
||||
} u;
|
||||
|
||||
// edges
|
||||
if (exponent > 1023) return CL_DBL_MAX;
|
||||
if (exponent <= -1074) return 0.0;
|
||||
|
||||
// Figure out which bits go where
|
||||
int shift = 11;
|
||||
if (exponent < -1022)
|
||||
{
|
||||
shift -= 1022 + exponent; // subnormal: shift is not 52
|
||||
exponent = -1023; // set exponent to 0
|
||||
}
|
||||
else
|
||||
hi &= 0x7fffffffffffffffULL; // normal: leading bit is implicit. Remove
|
||||
// it.
|
||||
|
||||
// Assemble the double (round toward zero)
|
||||
u.u = (hi >> shift) | ((cl_ulong)(exponent + 1023) << 52);
|
||||
|
||||
return u.d;
|
||||
}
|
||||
|
||||
// Shift right. Bits lost on the right will be OR'd together and OR'd with the
|
||||
// LSB
|
||||
static inline void shift_right_sticky_128(cl_ulong *hi, cl_ulong *lo, int shift)
|
||||
@@ -2964,7 +2994,14 @@ long double reference_fmal(long double x, long double y, long double z)
|
||||
}
|
||||
|
||||
// round
|
||||
ua.d = round_to_nearest_even_double(hi, lo, exponent);
|
||||
if (gIsInRTZMode)
|
||||
{
|
||||
ua.d = round_toward_zero_double(hi, lo, exponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
ua.d = round_to_nearest_even_double(hi, lo, exponent);
|
||||
}
|
||||
|
||||
// Set the sign
|
||||
ua.u |= sign;
|
||||
@@ -3611,6 +3648,7 @@ long double reference_expm1l(long double x)
|
||||
long double reference_fmaxl(long double x, long double y)
|
||||
{
|
||||
if (isnan(y)) return x;
|
||||
if (isnan(x)) return y;
|
||||
|
||||
return x >= y ? x : y;
|
||||
}
|
||||
@@ -3618,6 +3656,7 @@ long double reference_fmaxl(long double x, long double y)
|
||||
long double reference_fminl(long double x, long double y)
|
||||
{
|
||||
if (isnan(y)) return x;
|
||||
if (isnan(x)) return y;
|
||||
|
||||
return x <= y ? x : y;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,12 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
BuildKernelInfo &info = *(BuildKernelInfo *)p;
|
||||
auto generator = [](const std::string &kernel_name, const char *builtin,
|
||||
cl_uint vector_size_index) {
|
||||
return GetUnaryKernel(kernel_name, builtin, ParameterType::Double,
|
||||
const char *builtinCall = builtin;
|
||||
if (strcmp(builtin, "reciprocal") == 0)
|
||||
{
|
||||
builtinCall = "((RETTYPE)(1.0))/";
|
||||
}
|
||||
return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Double,
|
||||
ParameterType::Double, vector_size_index);
|
||||
};
|
||||
return BuildKernels(info, job_id, generator);
|
||||
|
||||
@@ -28,7 +28,12 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
BuildKernelInfo &info = *(BuildKernelInfo *)p;
|
||||
auto generator = [](const std::string &kernel_name, const char *builtin,
|
||||
cl_uint vector_size_index) {
|
||||
return GetUnaryKernel(kernel_name, builtin, ParameterType::Float,
|
||||
const char *builtinCall = builtin;
|
||||
if (strcmp(builtin, "reciprocal") == 0)
|
||||
{
|
||||
builtinCall = "((RETTYPE)(1.0f))/";
|
||||
}
|
||||
return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Float,
|
||||
ParameterType::Float, vector_size_index);
|
||||
};
|
||||
return BuildKernels(info, job_id, generator);
|
||||
|
||||
@@ -28,7 +28,12 @@ cl_int BuildKernel_HalfFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
BuildKernelInfo &info = *(BuildKernelInfo *)p;
|
||||
auto generator = [](const std::string &kernel_name, const char *builtin,
|
||||
cl_uint vector_size_index) {
|
||||
return GetUnaryKernel(kernel_name, builtin, ParameterType::Half,
|
||||
const char *builtinCall = builtin;
|
||||
if (strcmp(builtin, "reciprocal") == 0)
|
||||
{
|
||||
builtinCall = "((RETTYPE)(1.0h))/";
|
||||
}
|
||||
return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Half,
|
||||
ParameterType::Half, vector_size_index);
|
||||
};
|
||||
return BuildKernels(info, job_id, generator);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include "harness/testHarness.h"
|
||||
#include "procs.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -48,67 +47,9 @@ test_status InitCL(cl_device_id device) {
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST(pipe_readwrite_int),
|
||||
ADD_TEST(pipe_readwrite_uint),
|
||||
ADD_TEST(pipe_readwrite_long),
|
||||
ADD_TEST(pipe_readwrite_ulong),
|
||||
ADD_TEST(pipe_readwrite_short),
|
||||
ADD_TEST(pipe_readwrite_ushort),
|
||||
ADD_TEST(pipe_readwrite_float),
|
||||
ADD_TEST(pipe_readwrite_half),
|
||||
ADD_TEST(pipe_readwrite_char),
|
||||
ADD_TEST(pipe_readwrite_uchar),
|
||||
ADD_TEST(pipe_readwrite_double),
|
||||
ADD_TEST(pipe_readwrite_struct),
|
||||
ADD_TEST(pipe_workgroup_readwrite_int),
|
||||
ADD_TEST(pipe_workgroup_readwrite_uint),
|
||||
ADD_TEST(pipe_workgroup_readwrite_long),
|
||||
ADD_TEST(pipe_workgroup_readwrite_ulong),
|
||||
ADD_TEST(pipe_workgroup_readwrite_short),
|
||||
ADD_TEST(pipe_workgroup_readwrite_ushort),
|
||||
ADD_TEST(pipe_workgroup_readwrite_float),
|
||||
ADD_TEST(pipe_workgroup_readwrite_half),
|
||||
ADD_TEST(pipe_workgroup_readwrite_char),
|
||||
ADD_TEST(pipe_workgroup_readwrite_uchar),
|
||||
ADD_TEST(pipe_workgroup_readwrite_double),
|
||||
ADD_TEST(pipe_workgroup_readwrite_struct),
|
||||
ADD_TEST(pipe_subgroup_readwrite_int),
|
||||
ADD_TEST(pipe_subgroup_readwrite_uint),
|
||||
ADD_TEST(pipe_subgroup_readwrite_long),
|
||||
ADD_TEST(pipe_subgroup_readwrite_ulong),
|
||||
ADD_TEST(pipe_subgroup_readwrite_short),
|
||||
ADD_TEST(pipe_subgroup_readwrite_ushort),
|
||||
ADD_TEST(pipe_subgroup_readwrite_float),
|
||||
ADD_TEST(pipe_subgroup_readwrite_half),
|
||||
ADD_TEST(pipe_subgroup_readwrite_char),
|
||||
ADD_TEST(pipe_subgroup_readwrite_uchar),
|
||||
ADD_TEST(pipe_subgroup_readwrite_double),
|
||||
ADD_TEST(pipe_subgroup_readwrite_struct),
|
||||
ADD_TEST(pipe_convenience_readwrite_int),
|
||||
ADD_TEST(pipe_convenience_readwrite_uint),
|
||||
ADD_TEST(pipe_convenience_readwrite_long),
|
||||
ADD_TEST(pipe_convenience_readwrite_ulong),
|
||||
ADD_TEST(pipe_convenience_readwrite_short),
|
||||
ADD_TEST(pipe_convenience_readwrite_ushort),
|
||||
ADD_TEST(pipe_convenience_readwrite_float),
|
||||
ADD_TEST(pipe_convenience_readwrite_half),
|
||||
ADD_TEST(pipe_convenience_readwrite_char),
|
||||
ADD_TEST(pipe_convenience_readwrite_uchar),
|
||||
ADD_TEST(pipe_convenience_readwrite_double),
|
||||
ADD_TEST(pipe_convenience_readwrite_struct),
|
||||
ADD_TEST(pipe_info),
|
||||
ADD_TEST(pipe_max_args),
|
||||
ADD_TEST(pipe_max_packet_size),
|
||||
ADD_TEST(pipe_max_active_reservations),
|
||||
ADD_TEST(pipe_query_functions),
|
||||
ADD_TEST(pipe_readwrite_errors),
|
||||
ADD_TEST(pipe_subgroups_divergence),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE(test_list);
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
return runTestHarnessWithCheck(argc, argv, test_num, test_list, false,
|
||||
0, InitCL);
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return runTestHarnessWithCheck(
|
||||
argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, 0, InitCL);
|
||||
}
|
||||
|
||||
@@ -1,92 +0,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.
|
||||
//
|
||||
#ifndef __PROCS_H__
|
||||
#define __PROCS_H__
|
||||
|
||||
#include "harness/kernelHelpers.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/mt19937.h"
|
||||
#include "harness/conversions.h"
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
extern int test_pipe_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_pipe_workgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_workgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_pipe_subgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_subgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_pipe_convenience_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_convenience_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||
extern int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_pipe_readwrite_errors(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
|
||||
#endif // #ifndef __PROCS_H__
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/parseParameters.h"
|
||||
|
||||
const char* pipe_kernel_code = {
|
||||
"__kernel void pipe_kernel(__write_only pipe int out_pipe)\n"
|
||||
"{}\n" };
|
||||
|
||||
int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
REGISTER_TEST(pipe_info)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
cl_int err;
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
#define STRING_LENGTH 1024
|
||||
|
||||
@@ -150,7 +151,7 @@ static int verify_result_int(void *ptr1, void *ptr2, int n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_max_args)
|
||||
{
|
||||
|
||||
clMemWrapper pipes[1024];
|
||||
@@ -177,7 +178,7 @@ int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
|
||||
size_t min_alignment = get_min_alignment(context);
|
||||
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS,
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS,
|
||||
sizeof(max_pipe_args), (void *)&max_pipe_args, NULL);
|
||||
if (err)
|
||||
{
|
||||
@@ -263,7 +264,7 @@ int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_que
|
||||
}
|
||||
|
||||
|
||||
int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_max_packet_size)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
clMemWrapper buffers[2];
|
||||
@@ -290,7 +291,7 @@ int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_comm
|
||||
|
||||
std::stringstream source;
|
||||
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
|
||||
sizeof(max_pipe_packet_size),
|
||||
(void *)&max_pipe_packet_size, NULL);
|
||||
test_error_ret(err, " clCreatePipe failed", -1);
|
||||
@@ -402,7 +403,7 @@ int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_comm
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_max_active_reservations)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
clMemWrapper buffers[2];
|
||||
@@ -437,12 +438,12 @@ int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context,
|
||||
|
||||
global_work_size[0] = 1;
|
||||
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
|
||||
sizeof(max_active_reservations),
|
||||
(void *)&max_active_reservations, NULL);
|
||||
test_error_ret(err, " clGetDeviceInfo failed", -1);
|
||||
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE,
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE,
|
||||
sizeof(max_global_size), (void *)&max_global_size,
|
||||
NULL);
|
||||
test_error_ret(err, " clGetDeviceInfo failed", -1);
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
#define TEST_PRIME_INT ((1<<16)+1)
|
||||
|
||||
@@ -77,7 +78,7 @@ static int verify_result(void *ptr1, void *ptr2, int n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_query_functions)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
clMemWrapper buffers[4];
|
||||
@@ -252,4 +253,3 @@ int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_comm
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
const char* pipe_readwrite_errors_kernel_code = {
|
||||
"__kernel void test_pipe_write_error(__global int *src, __write_only pipe int out_pipe, __global int *status)\n"
|
||||
@@ -62,7 +63,7 @@ const char* pipe_readwrite_errors_kernel_code = {
|
||||
};
|
||||
|
||||
|
||||
int test_pipe_readwrite_errors(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_readwrite_errors)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
clMemWrapper buffers[3];
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
#define TEST_INT_VALUE 100
|
||||
|
||||
const char* pipe_subgroups_kernel_code = {
|
||||
@@ -86,7 +88,7 @@ static int verify_result(void *ptr1, void *ptr2, int n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(pipe_subgroups_divergence)
|
||||
{
|
||||
clMemWrapper pipe;
|
||||
clMemWrapper buffers[3];
|
||||
@@ -112,7 +114,7 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl
|
||||
|
||||
global_work_size[0] = (cl_uint)num_elements;
|
||||
|
||||
if (!is_extension_available(deviceID, "cl_khr_subgroups"))
|
||||
if (!is_extension_available(device, "cl_khr_subgroups"))
|
||||
{
|
||||
log_info("cl_khr_subgroups is not supported on this platform. Skipping "
|
||||
"test.\n");
|
||||
@@ -165,7 +167,7 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl
|
||||
test_error_ret(err, " Unable to get work group size to use", -1);
|
||||
|
||||
cl_platform_id platform;
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform),
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
|
||||
&platform, NULL);
|
||||
test_error_ret(err, " clGetDeviceInfo failed", -1);
|
||||
|
||||
@@ -173,7 +175,10 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl
|
||||
(clGetKernelSubGroupInfoKHR_fn)clGetExtensionFunctionAddressForPlatform(
|
||||
platform, "clGetKernelSubGroupInfoKHR");
|
||||
|
||||
err = clGetKernelSubGroupInfoKHR(kernel[0], deviceID, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, sizeof(local_work_size[0]), &local_work_size[0], sizeof(subgroup_count), &subgroup_count, NULL);
|
||||
err = clGetKernelSubGroupInfoKHR(
|
||||
kernel[0], device, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR,
|
||||
sizeof(local_work_size[0]), &local_work_size[0], sizeof(subgroup_count),
|
||||
&subgroup_count, NULL);
|
||||
test_error_ret(err, " clGetKernelSubGroupInfoKHR failed", -1);
|
||||
if(subgroup_count <= 1)
|
||||
{
|
||||
|
||||
@@ -247,7 +247,7 @@ cl_program makeMixedFormatPrintfProgram(cl_kernel* kernel_ptr,
|
||||
};
|
||||
|
||||
std::array<std::vector<std::string>, 2> formats = {
|
||||
{ { "%f", "%e", "%g", "%a", "%F", "%E", "%G", "%A" },
|
||||
{ { "%f", "%e", "%g", "%.13a", "%F", "%E", "%G", "%.13A" },
|
||||
{ "%d", "%i", "%u", "%x", "%o", "%X" } }
|
||||
};
|
||||
std::vector<char> data_before(2 + genrand_int32(gMTdata) % 8);
|
||||
@@ -929,123 +929,77 @@ int doTest(cl_command_queue queue, cl_context context,
|
||||
|
||||
}
|
||||
|
||||
int test_int(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(int) { return doTest(gQueue, gContext, TYPE_INT, device); }
|
||||
|
||||
REGISTER_TEST(long) { return doTest(gQueue, gContext, TYPE_LONG, device); }
|
||||
|
||||
REGISTER_TEST(half) { return doTest(gQueue, gContext, TYPE_HALF, device); }
|
||||
|
||||
REGISTER_TEST(half_limits)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_HALF_LIMITS, device);
|
||||
}
|
||||
|
||||
int test_long(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(float) { return doTest(gQueue, gContext, TYPE_FLOAT, device); }
|
||||
|
||||
REGISTER_TEST(float_limits)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_LONG, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, device);
|
||||
}
|
||||
|
||||
int test_half(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements)
|
||||
REGISTER_TEST(double) { return doTest(gQueue, gContext, TYPE_DOUBLE, device); }
|
||||
|
||||
REGISTER_TEST(double_limits)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HALF, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_DOUBLE_LIMITS, device);
|
||||
}
|
||||
|
||||
int test_half_limits(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(octal) { return doTest(gQueue, gContext, TYPE_OCTAL, device); }
|
||||
|
||||
REGISTER_TEST(unsigned)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HALF_LIMITS, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_UNSIGNED, device);
|
||||
}
|
||||
|
||||
int test_float(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(hexadecimal)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, device);
|
||||
}
|
||||
|
||||
int test_float_limits(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(char) { return doTest(gQueue, gContext, TYPE_CHAR, device); }
|
||||
|
||||
REGISTER_TEST(string) { return doTest(gQueue, gContext, TYPE_STRING, device); }
|
||||
|
||||
REGISTER_TEST(format_string)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_FORMAT_STRING, device);
|
||||
}
|
||||
|
||||
int test_double(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(vector) { return doTest(gQueue, gContext, TYPE_VECTOR, device); }
|
||||
|
||||
REGISTER_TEST(address_space)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_DOUBLE, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, device);
|
||||
}
|
||||
|
||||
int test_double_limits(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(mixed_format_random)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_DOUBLE_LIMITS, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, device);
|
||||
}
|
||||
|
||||
int test_octal(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(length_specifier)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_OCTAL, deviceID);
|
||||
return doTest(gQueue, gContext, TYPE_LENGTH_SPECIFIER, device);
|
||||
}
|
||||
|
||||
int test_unsigned(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_UNSIGNED, deviceID);
|
||||
}
|
||||
|
||||
int test_hexadecimal(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, deviceID);
|
||||
}
|
||||
|
||||
int test_char(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_CHAR, deviceID);
|
||||
}
|
||||
|
||||
int test_string(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_STRING, deviceID);
|
||||
}
|
||||
|
||||
int test_format_string(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FORMAT_STRING, deviceID);
|
||||
}
|
||||
|
||||
int test_vector(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, deviceID);
|
||||
}
|
||||
|
||||
int test_address_space(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, deviceID);
|
||||
}
|
||||
|
||||
int test_mixed_format_random(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, deviceID);
|
||||
}
|
||||
|
||||
int test_length_specifier(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_LENGTH_SPECIFIER, deviceID);
|
||||
}
|
||||
|
||||
int test_buffer_size(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_size)
|
||||
{
|
||||
size_t printf_buff_size = 0;
|
||||
const size_t printf_buff_size_req = !gIsEmbedded ? (1024 * 1024UL) : 1024UL;
|
||||
const size_t config_size = sizeof(printf_buff_size);
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
err = clGetDeviceInfo(deviceID, CL_DEVICE_PRINTF_BUFFER_SIZE, config_size,
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_PRINTF_BUFFER_SIZE, config_size,
|
||||
&printf_buff_size, NULL);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
@@ -1062,30 +1016,6 @@ int test_buffer_size(cl_device_id deviceID, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST(int),
|
||||
ADD_TEST(long),
|
||||
ADD_TEST(half),
|
||||
ADD_TEST(half_limits),
|
||||
ADD_TEST(float),
|
||||
ADD_TEST(float_limits),
|
||||
ADD_TEST(double),
|
||||
ADD_TEST(double_limits),
|
||||
ADD_TEST(octal),
|
||||
ADD_TEST(unsigned),
|
||||
ADD_TEST(hexadecimal),
|
||||
ADD_TEST(char),
|
||||
ADD_TEST(string),
|
||||
ADD_TEST(format_string),
|
||||
ADD_TEST(vector),
|
||||
ADD_TEST(address_space),
|
||||
ADD_TEST(buffer_size),
|
||||
ADD_TEST(mixed_format_random),
|
||||
ADD_TEST(length_specifier),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
|
||||
//-----------------------------------------
|
||||
// printUsage
|
||||
//-----------------------------------------
|
||||
@@ -1094,9 +1024,9 @@ static void printUsage(void)
|
||||
log_info("test_printf: <optional: testnames> \n");
|
||||
log_info("\tdefault is to run the full test on the default device\n");
|
||||
log_info("\n");
|
||||
for (int i = 0; i < test_num; i++)
|
||||
for (size_t i = 0; i < test_registry::getInstance().num_tests(); i++)
|
||||
{
|
||||
log_info("\t%s\n", test_list[i].name);
|
||||
log_info("\t%s\n", test_registry::getInstance().definitions()[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,7 +1097,9 @@ int main(int argc, const char* argv[])
|
||||
|
||||
gMTdata = MTdataHolder(gRandomSeed);
|
||||
|
||||
int err = runTestHarnessWithCheck( argCount, argList, test_num, test_list, true, 0, InitCL );
|
||||
int err = runTestHarnessWithCheck(
|
||||
argCount, argList, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), true, 0, InitCL);
|
||||
|
||||
if(gQueue)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
//
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@@ -97,6 +98,7 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue
|
||||
cl_ulong queueStart, submitStart, writeStart, writeEnd;
|
||||
size_t threads[3];
|
||||
size_t localThreads[3];
|
||||
size_t maxWorkgroupSize;
|
||||
int err = 0;
|
||||
|
||||
// set thread dimensions
|
||||
@@ -104,16 +106,27 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue
|
||||
threads[1] = h;
|
||||
threads[2] = d;
|
||||
|
||||
err = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof( cl_uint ), (size_t*)localThreads, NULL );
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
|
||||
3 * sizeof(size_t), (size_t *)localThreads, NULL);
|
||||
if (err)
|
||||
{
|
||||
localThreads[0] = 256; localThreads[1] = 1; localThreads[2] = 1;
|
||||
err = 0;
|
||||
log_error("clGetDeviceInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES) failed\n");
|
||||
return -1;
|
||||
}
|
||||
if( localThreads[0] > threads[0] )
|
||||
localThreads[0] = threads[0];
|
||||
if( localThreads[1] > threads[1] )
|
||||
localThreads[1] = threads[1];
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t),
|
||||
&maxWorkgroupSize, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error("clGetDeviceInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE) failed\n");
|
||||
return -1;
|
||||
}
|
||||
localThreads[0] =
|
||||
std::min({ localThreads[0], threads[0], maxWorkgroupSize });
|
||||
localThreads[1] = std::min(
|
||||
{ localThreads[1], threads[1], maxWorkgroupSize / localThreads[0] });
|
||||
localThreads[2] =
|
||||
std::min({ localThreads[2], threads[2],
|
||||
maxWorkgroupSize / (localThreads[0] * localThreads[1]) });
|
||||
|
||||
cl_sampler sampler = clCreateSampler( context, CL_FALSE, CL_ADDRESS_CLAMP_TO_EDGE, CL_FILTER_NEAREST, &err );
|
||||
if( err ){
|
||||
@@ -131,9 +144,9 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue
|
||||
}
|
||||
|
||||
// allocate an array memory object to load the filter weights
|
||||
size_t outptr_size = sizeof(cl_uchar) * w * h * d * nChannels;
|
||||
memobjs[1] =
|
||||
clCreateBuffer(context, CL_MEM_READ_WRITE,
|
||||
sizeof(cl_uchar) * w * h * d * nChannels, NULL, &err);
|
||||
clCreateBuffer(context, CL_MEM_READ_WRITE, outptr_size, NULL, &err);
|
||||
if( memobjs[1] == (cl_mem)0 ){
|
||||
log_error( " unable to create array using clCreateBuffer\n" );
|
||||
clReleaseMemObject( memobjs[0] );
|
||||
@@ -237,9 +250,8 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue
|
||||
}
|
||||
|
||||
// read output image
|
||||
err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0,
|
||||
sizeof(cl_uchar) * w * h * d * nChannels, outptr,
|
||||
0, NULL, NULL);
|
||||
err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0, outptr_size,
|
||||
outptr, 0, NULL, NULL);
|
||||
if( err != CL_SUCCESS ){
|
||||
print_error( err, "clReadImage failed\n" );
|
||||
clReleaseKernel( kernel[0] );
|
||||
|
||||
@@ -14,15 +14,9 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "procs.h"
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "testBase.h"
|
||||
|
||||
#if DENSE_PACK_VECS
|
||||
const int g_vector_aligns[] = {0, 1, 2, 3, 4,
|
||||
@@ -44,32 +38,9 @@ const int g_vector_allocs[] = {0, 1, 2, 4, 4,
|
||||
16, 16, 16, 16};
|
||||
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST( relational_any ),
|
||||
ADD_TEST( relational_all ),
|
||||
ADD_TEST( relational_bitselect ),
|
||||
ADD_TEST( relational_select_signed ),
|
||||
ADD_TEST( relational_select_unsigned ),
|
||||
|
||||
ADD_TEST( relational_isequal ),
|
||||
ADD_TEST( relational_isnotequal ),
|
||||
ADD_TEST( relational_isgreater ),
|
||||
ADD_TEST( relational_isgreaterequal ),
|
||||
ADD_TEST( relational_isless ),
|
||||
ADD_TEST( relational_islessequal ),
|
||||
ADD_TEST( relational_islessgreater ),
|
||||
|
||||
ADD_TEST( shuffle_copy ),
|
||||
ADD_TEST( shuffle_function_call ),
|
||||
ADD_TEST( shuffle_array_cast ),
|
||||
ADD_TEST( shuffle_built_in ),
|
||||
ADD_TEST( shuffle_built_in_dual_input ),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return runTestHarness(argc, argv, test_num, test_list, false, 0);
|
||||
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +0,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 "harness/errorHelpers.h"
|
||||
#include "harness/kernelHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/conversions.h"
|
||||
#include "harness/mt19937.h"
|
||||
|
||||
// The number of errors to print out for each test in the shuffle tests
|
||||
#define MAX_ERRORS_TO_PRINT 1
|
||||
|
||||
extern const int g_vector_aligns[];
|
||||
extern const int g_vector_allocs[];
|
||||
|
||||
#define DENSE_PACK_VECS 1
|
||||
|
||||
extern int create_program_and_kernel(const char *source, const char *kernel_name, cl_program *program_ret, cl_kernel *kernel_ret);
|
||||
|
||||
extern int test_relational_any(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_bitselect(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_select_signed(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_select_unsigned(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_relational_isequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_isnotequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_isgreater(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_isgreaterequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_isless(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_islessequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_relational_islessgreater(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_shuffles(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffles_16(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffles_dual(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffle_copy(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffle_function_call(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffle_array_cast(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffle_built_in(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
extern int test_shuffle_built_in_dual_input(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -17,15 +17,21 @@
|
||||
#define _testBase_h
|
||||
|
||||
#include "harness/compat.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
#include "harness/conversions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procs.h"
|
||||
// The number of errors to print out for each test in the shuffle tests
|
||||
#define MAX_ERRORS_TO_PRINT 1
|
||||
|
||||
extern const int g_vector_aligns[];
|
||||
extern const int g_vector_allocs[];
|
||||
|
||||
#define DENSE_PACK_VECS 1
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -368,8 +368,9 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize,
|
||||
{
|
||||
if (gInfNanSupport == 0)
|
||||
{
|
||||
if (isnan(inDataA[i * vecSize + j])
|
||||
|| isnan(inDataB[i * vecSize + j]))
|
||||
float a = inDataA[i * vecSize + j];
|
||||
float b = inDataB[i * vecSize + j];
|
||||
if (isnan(a) || isnan(b))
|
||||
fail = 0;
|
||||
else
|
||||
fail = 1;
|
||||
@@ -595,48 +596,42 @@ cl_int IsLessGreaterFPTest::SetUp(int elements)
|
||||
return RelationalsFPTest::SetUp(elements);
|
||||
}
|
||||
|
||||
int test_relational_isequal(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_isequal)
|
||||
{
|
||||
return MakeAndRunTest<IsEqualFPTest>(device, context, queue, numElements);
|
||||
return MakeAndRunTest<IsEqualFPTest>(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_relational_isnotequal(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_isnotequal)
|
||||
{
|
||||
return MakeAndRunTest<IsNotEqualFPTest>(device, context, queue,
|
||||
numElements);
|
||||
num_elements);
|
||||
}
|
||||
|
||||
int test_relational_isgreater(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_isgreater)
|
||||
{
|
||||
return MakeAndRunTest<IsGreaterFPTest>(device, context, queue, numElements);
|
||||
return MakeAndRunTest<IsGreaterFPTest>(device, context, queue,
|
||||
num_elements);
|
||||
}
|
||||
|
||||
int test_relational_isgreaterequal(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_isgreaterequal)
|
||||
{
|
||||
return MakeAndRunTest<IsGreaterEqualFPTest>(device, context, queue,
|
||||
numElements);
|
||||
num_elements);
|
||||
}
|
||||
|
||||
int test_relational_isless(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_isless)
|
||||
{
|
||||
return MakeAndRunTest<IsLessFPTest>(device, context, queue, numElements);
|
||||
return MakeAndRunTest<IsLessFPTest>(device, context, queue, num_elements);
|
||||
}
|
||||
|
||||
int test_relational_islessequal(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_islessequal)
|
||||
{
|
||||
return MakeAndRunTest<IsLessEqualFPTest>(device, context, queue,
|
||||
numElements);
|
||||
num_elements);
|
||||
}
|
||||
|
||||
int test_relational_islessgreater(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements)
|
||||
REGISTER_TEST(relational_islessgreater)
|
||||
{
|
||||
return MakeAndRunTest<IsLessGreaterFPTest>(device, context, queue,
|
||||
numElements);
|
||||
num_elements);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ int anyVerifyFn( ExplicitType vecType, unsigned int vecSize, void *inData )
|
||||
}
|
||||
}
|
||||
|
||||
int test_relational_any(cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
REGISTER_TEST(relational_any)
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kShort, kInt, kLong };
|
||||
unsigned int vecSizes[] = { 1, 2, 3, 4, 8, 16, 0 };
|
||||
@@ -268,7 +268,7 @@ int allVerifyFn( ExplicitType vecType, unsigned int vecSize, void *inData )
|
||||
}
|
||||
}
|
||||
|
||||
int test_relational_all(cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
REGISTER_TEST(relational_all)
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kShort, kInt, kLong };
|
||||
unsigned int vecSizes[] = { 1, 2, 3, 4, 8, 16, 0 };
|
||||
@@ -526,7 +526,7 @@ void bitselect_verify_fn( ExplicitType vecType, ExplicitType testVecType, unsign
|
||||
}
|
||||
}
|
||||
|
||||
int test_relational_bitselect(cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
REGISTER_TEST(relational_bitselect)
|
||||
{
|
||||
constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort,
|
||||
kInt, kUInt, kLong, kULong,
|
||||
@@ -626,7 +626,7 @@ void select_signed_verify_fn( ExplicitType vecType, ExplicitType testVecType, un
|
||||
memcpy( outData, ( yep ) ? inDataB : inDataA, get_explicit_type_size( vecType ) );
|
||||
}
|
||||
|
||||
int test_relational_select_signed(cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
REGISTER_TEST(relational_select_signed)
|
||||
{
|
||||
constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort,
|
||||
kInt, kUInt, kLong, kULong,
|
||||
@@ -732,7 +732,7 @@ void select_unsigned_verify_fn( ExplicitType vecType, ExplicitType testVecType,
|
||||
memcpy( outData, ( yep ) ? inDataB : inDataA, get_explicit_type_size( vecType ) );
|
||||
}
|
||||
|
||||
int test_relational_select_unsigned(cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
REGISTER_TEST(relational_select_unsigned)
|
||||
{
|
||||
constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort,
|
||||
kInt, kUInt, kLong, kULong,
|
||||
|
||||
@@ -926,33 +926,32 @@ int test_shuffle_random(cl_device_id device, cl_context context, cl_command_queu
|
||||
return totalError;
|
||||
}
|
||||
|
||||
int test_shuffle_copy(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
|
||||
REGISTER_TEST(shuffle_copy)
|
||||
{
|
||||
RandomSeed seed(gRandomSeed);
|
||||
return test_shuffle_random( device, context, queue, kNormalMode, seed );
|
||||
}
|
||||
|
||||
int test_shuffle_function_call(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
|
||||
REGISTER_TEST(shuffle_function_call)
|
||||
{
|
||||
RandomSeed seed(gRandomSeed);
|
||||
return test_shuffle_random( device, context, queue, kFunctionCallMode, seed );
|
||||
}
|
||||
|
||||
int test_shuffle_array_cast(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
|
||||
REGISTER_TEST(shuffle_array_cast)
|
||||
{
|
||||
RandomSeed seed(gRandomSeed);
|
||||
return test_shuffle_random( device, context, queue, kArrayAccessMode, seed );
|
||||
}
|
||||
|
||||
int test_shuffle_built_in(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
|
||||
REGISTER_TEST(shuffle_built_in)
|
||||
{
|
||||
RandomSeed seed(gRandomSeed);
|
||||
return test_shuffle_random( device, context, queue, kBuiltInFnMode, seed );
|
||||
}
|
||||
|
||||
int test_shuffle_built_in_dual_input(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
|
||||
REGISTER_TEST(shuffle_built_in_dual_input)
|
||||
{
|
||||
RandomSeed seed(gRandomSeed);
|
||||
return test_shuffle_random( device, context, queue, kBuiltInDualInputFnMode, seed );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <cinttypes>
|
||||
#include "test_select.h"
|
||||
#include "CL/cl_half.h"
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -830,10 +831,12 @@ size_t check_half(const void *const test, const void *const correct,
|
||||
|
||||
if (memcmp(t, c, count * sizeof(c[0])) != 0)
|
||||
{
|
||||
for (i = 0; i < count; i++) /* Allow nans to be binary different */
|
||||
if ((t[i] != c[i])
|
||||
&& !(isnan(((cl_half *)correct)[i])
|
||||
&& isnan(((cl_half *)test)[i])))
|
||||
// Allow nans to be binary different
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
float fcorrect = cl_half_to_float(c[i]);
|
||||
float ftest = cl_half_to_float(t[i]);
|
||||
if ((t[i] != c[i]) && !(isnan(fcorrect) && isnan(ftest)))
|
||||
{
|
||||
log_error("\n(check_half) Error for vector size %zu found at "
|
||||
"0x%8.8zx (of 0x%8.8zx): "
|
||||
@@ -841,6 +844,7 @@ size_t check_half(const void *const test, const void *const correct,
|
||||
vector_size, i, count, c[i], t[i]);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -855,9 +859,12 @@ size_t check_float(const void *const test, const void *const correct,
|
||||
|
||||
if (memcmp(t, c, count * sizeof(c[0])) != 0)
|
||||
{
|
||||
for (i = 0; i < count; i++) /* Allow nans to be binary different */
|
||||
if ((t[i] != c[i])
|
||||
&& !(isnan(((float *)correct)[i]) && isnan(((float *)test)[i])))
|
||||
// Allow nans to be binary different
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
float fcorrect = ((float *)correct)[i];
|
||||
float ftest = ((float *)test)[i];
|
||||
if ((t[i] != c[i]) && !(isnan(fcorrect) && isnan(ftest)))
|
||||
{
|
||||
log_error("\n(check_float) Error for vector size %zu found at "
|
||||
"0x%8.8zx (of 0x%8.8zx): "
|
||||
@@ -865,6 +872,7 @@ size_t check_float(const void *const test, const void *const correct,
|
||||
vector_size, i, count, c[i], t[i]);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -30,6 +30,7 @@ set(${MODULE_NAME}_SOURCES
|
||||
test_op_vector_times_scalar.cpp
|
||||
test_spirv_14.cpp
|
||||
test_spirv_15.cpp
|
||||
test_spirv_16.cpp
|
||||
)
|
||||
|
||||
set(TEST_HARNESS_SOURCES
|
||||
|
||||
@@ -172,7 +172,12 @@ int get_program_with_il(clProgramWrapper &prog, const cl_device_id deviceID,
|
||||
}
|
||||
|
||||
err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL);
|
||||
SPIRV_CHECK_ERROR(err, "Failed to build program");
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
cl_int outputErr = OutputBuildLog(prog, deviceID);
|
||||
SPIRV_CHECK_ERROR(outputErr, "OutputBuildLog failed");
|
||||
return err;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -411,6 +411,12 @@ set(spirv_sources
|
||||
spv1.5/basic.spvasm64
|
||||
spv1.6/basic.spvasm32
|
||||
spv1.6/basic.spvasm64
|
||||
spv1.6/image_operand_nontemporal.spvasm32
|
||||
spv1.6/image_operand_nontemporal.spvasm64
|
||||
spv1.6/uniformdecoration_uniformid.spvasm32
|
||||
spv1.6/uniformdecoration_uniformid.spvasm64
|
||||
spv1.6/uniformdecoration_uniform.spvasm32
|
||||
spv1.6/uniformdecoration_uniform.spvasm64
|
||||
undef_char_simple.spvasm32
|
||||
undef_char_simple.spvasm64
|
||||
undef_double_simple.spvasm32
|
||||
@@ -500,3 +506,10 @@ add_custom_command(
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(spirv_new_binaries DEPENDS ${assembled_spirv_binaries})
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(DIRECTORY
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../spirv_bin
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}/$<CONFIG>)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
; Schema: 0
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability Float16
|
||||
OpCapability Float16Buffer
|
||||
%1 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
; Schema: 0
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability Float16
|
||||
OpCapability Float16Buffer
|
||||
%1 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability ImageBasic
|
||||
OpCapability LiteralSampler
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %kernel "read_write_image_nontemporal"
|
||||
%uint = OpTypeInt 32 0
|
||||
%void = OpTypeVoid
|
||||
%read_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly
|
||||
%write_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly
|
||||
%sampler_t = OpTypeSampler
|
||||
%kernel_sig = OpTypeFunction %void %read_image2d_t %write_image2d_t
|
||||
%sampledimage_t = OpTypeSampledImage %read_image2d_t
|
||||
%v2uint = OpTypeVector %uint 2
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%sampler = OpConstantSampler %sampler_t None 0 Nearest
|
||||
%coord_0_0 = OpConstantNull %v2uint
|
||||
%float_0 = OpConstant %float 0
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%src = OpFunctionParameter %read_image2d_t
|
||||
%dst = OpFunctionParameter %write_image2d_t
|
||||
%entry = OpLabel
|
||||
%si = OpSampledImage %sampledimage_t %src %sampler
|
||||
%data = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod|Nontemporal %float_0
|
||||
OpImageWrite %dst %coord_0_0 %data Nontemporal
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,30 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability ImageBasic
|
||||
OpCapability LiteralSampler
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %kernel "read_write_image_nontemporal"
|
||||
%uint = OpTypeInt 32 0
|
||||
%void = OpTypeVoid
|
||||
%read_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly
|
||||
%write_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly
|
||||
%sampler_t = OpTypeSampler
|
||||
%kernel_sig = OpTypeFunction %void %read_image2d_t %write_image2d_t
|
||||
%sampledimage_t = OpTypeSampledImage %read_image2d_t
|
||||
%v2uint = OpTypeVector %uint 2
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%sampler = OpConstantSampler %sampler_t None 0 Nearest
|
||||
%coord_0_0 = OpConstantNull %v2uint
|
||||
%float_0 = OpConstant %float 0
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%src = OpFunctionParameter %read_image2d_t
|
||||
%dst = OpFunctionParameter %write_image2d_t
|
||||
%entry = OpLabel
|
||||
%si = OpSampledImage %sampledimage_t %src %sampler
|
||||
%data = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod|Nontemporal %float_0
|
||||
OpImageWrite %dst %coord_0_0 %data Nontemporal
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,36 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability UniformDecoration
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid
|
||||
OpDecorate %gid BuiltIn GlobalInvocationId
|
||||
OpDecorate %gid Constant
|
||||
; Decoration on a constant
|
||||
OpDecorate %uint_0 Uniform
|
||||
; Decoration on a function parameter
|
||||
OpDecorate %value Uniform
|
||||
OpDecorate %base Uniform
|
||||
; Decoration on a variable
|
||||
OpDecorate %newvalue Uniform
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%ptr_gid = OpTypePointer Input %v3uint
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%gptr_uint = OpTypePointer CrossWorkgroup %uint
|
||||
%kernel_sig = OpTypeFunction %void %gptr_uint %uint
|
||||
%gid = OpVariable %ptr_gid Input
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%base = OpFunctionParameter %gptr_uint
|
||||
%value = OpFunctionParameter %uint
|
||||
%entry = OpLabel
|
||||
%gidv3 = OpLoad %v3uint %gid Aligned 32
|
||||
%gid0 = OpCompositeExtract %uint %gidv3 0
|
||||
%ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0
|
||||
%newvalue = OpIAdd %uint %value %uint_1
|
||||
OpStore %ptr %newvalue Aligned 4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,38 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability Int64
|
||||
OpCapability UniformDecoration
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid
|
||||
OpDecorate %gid BuiltIn GlobalInvocationId
|
||||
OpDecorate %gid Constant
|
||||
; Decoration on a constant
|
||||
OpDecorate %uint_0 Uniform
|
||||
; Decoration on a function parameter
|
||||
OpDecorate %value Uniform
|
||||
OpDecorate %base Uniform
|
||||
; Decoration on a variable
|
||||
OpDecorate %newvalue Uniform
|
||||
%uint = OpTypeInt 32 0
|
||||
%ulong = OpTypeInt 64 0
|
||||
%v3ulong = OpTypeVector %ulong 3
|
||||
%ptr_gid = OpTypePointer Input %v3ulong
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%gptr_uint = OpTypePointer CrossWorkgroup %uint
|
||||
%kernel_sig = OpTypeFunction %void %gptr_uint %uint
|
||||
%gid = OpVariable %ptr_gid Input
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%base = OpFunctionParameter %gptr_uint
|
||||
%value = OpFunctionParameter %uint
|
||||
%entry = OpLabel
|
||||
%gidv3 = OpLoad %v3ulong %gid Aligned 32
|
||||
%gid0 = OpCompositeExtract %ulong %gidv3 0
|
||||
%ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0
|
||||
%newvalue = OpIAdd %uint %value %uint_1
|
||||
OpStore %ptr %newvalue Aligned 4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,40 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability UniformDecoration
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid
|
||||
OpDecorate %gid BuiltIn GlobalInvocationId
|
||||
OpDecorate %gid Constant
|
||||
; Decoration on a constant
|
||||
OpDecorateId %uint_0 UniformId %scope_CrossDevice
|
||||
; Decoration on a function parameter
|
||||
OpDecorateId %value UniformId %scope_Device
|
||||
OpDecorateId %base UniformId %scope_Workgroup
|
||||
; Decoration on a variable
|
||||
OpDecorateId %newvalue UniformId %scope_Subgroup
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%ptr_gid = OpTypePointer Input %v3uint
|
||||
%scope_CrossDevice = OpConstant %uint 0
|
||||
%scope_Device = OpConstant %uint 1
|
||||
%scope_Workgroup = OpConstant %uint 2
|
||||
%scope_Subgroup = OpConstant %uint 3
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%gptr_uint = OpTypePointer CrossWorkgroup %uint
|
||||
%kernel_sig = OpTypeFunction %void %gptr_uint %uint
|
||||
%gid = OpVariable %ptr_gid Input
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%base = OpFunctionParameter %gptr_uint
|
||||
%value = OpFunctionParameter %uint
|
||||
%entry = OpLabel
|
||||
%gidv3 = OpLoad %v3uint %gid Aligned 32
|
||||
%gid0 = OpCompositeExtract %uint %gidv3 0
|
||||
%ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0
|
||||
%newvalue = OpIAdd %uint %value %uint_1
|
||||
OpStore %ptr %newvalue Aligned 4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.6
|
||||
OpCapability Addresses
|
||||
OpCapability Kernel
|
||||
OpCapability Int64
|
||||
OpCapability UniformDecoration
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid
|
||||
OpDecorate %gid BuiltIn GlobalInvocationId
|
||||
OpDecorate %gid Constant
|
||||
; Decoration on a constant
|
||||
OpDecorateId %uint_0 UniformId %scope_CrossDevice
|
||||
; Decoration on a function parameter
|
||||
OpDecorateId %value UniformId %scope_Device
|
||||
OpDecorateId %base UniformId %scope_Workgroup
|
||||
; Decoration on a variable
|
||||
OpDecorateId %newvalue UniformId %scope_Subgroup
|
||||
%uint = OpTypeInt 32 0
|
||||
%ulong = OpTypeInt 64 0
|
||||
%v3ulong = OpTypeVector %ulong 3
|
||||
%ptr_gid = OpTypePointer Input %v3ulong
|
||||
%scope_CrossDevice = OpConstant %uint 0
|
||||
%scope_Device = OpConstant %uint 1
|
||||
%scope_Workgroup = OpConstant %uint 2
|
||||
%scope_Subgroup = OpConstant %uint 3
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%gptr_uint = OpTypePointer CrossWorkgroup %uint
|
||||
%kernel_sig = OpTypeFunction %void %gptr_uint %uint
|
||||
%gid = OpVariable %ptr_gid Input
|
||||
%kernel = OpFunction %void None %kernel_sig
|
||||
%base = OpFunctionParameter %gptr_uint
|
||||
%value = OpFunctionParameter %uint
|
||||
%entry = OpLabel
|
||||
%gidv3 = OpLoad %v3ulong %gid Aligned 32
|
||||
%gid0 = OpCompositeExtract %ulong %gidv3 0
|
||||
%ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0
|
||||
%newvalue = OpIAdd %uint %value %uint_1
|
||||
OpStore %ptr %newvalue Aligned 4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
#include <CL/cl_half.h>
|
||||
|
||||
@@ -216,29 +217,37 @@ static inline Ti generate_saturated_rhs_input(RandomSeed &seed)
|
||||
}
|
||||
|
||||
template <typename Ti, typename Tl, typename To>
|
||||
static inline To compute_saturated_output(Ti lhs, Ti rhs,
|
||||
cl_half_rounding_mode half_rounding)
|
||||
static inline
|
||||
typename std::enable_if<std::is_same<Ti, cl_half>::value, To>::type
|
||||
compute_saturated_output(Ti lhs, Ti rhs,
|
||||
cl_half_rounding_mode half_rounding)
|
||||
{
|
||||
constexpr auto loVal = std::numeric_limits<To>::min();
|
||||
constexpr auto hiVal = std::numeric_limits<To>::max();
|
||||
|
||||
if (std::is_same<Ti, cl_half>::value)
|
||||
cl_float f = cl_half_to_float(lhs) * cl_half_to_float(rhs);
|
||||
|
||||
// Quantize to fp16:
|
||||
f = cl_half_to_float(cl_half_from_float(f, half_rounding));
|
||||
|
||||
To val = static_cast<To>(std::min<float>(std::max<float>(f, loVal), hiVal));
|
||||
if (isnan(cl_half_to_float(rhs)))
|
||||
{
|
||||
cl_float f = cl_half_to_float(lhs) * cl_half_to_float(rhs);
|
||||
|
||||
// Quantize to fp16:
|
||||
f = cl_half_to_float(cl_half_from_float(f, half_rounding));
|
||||
|
||||
To val = (To)std::min<float>(std::max<float>(f, loVal), hiVal);
|
||||
if (isnan(cl_half_to_float(rhs)))
|
||||
{
|
||||
val = 0;
|
||||
}
|
||||
return val;
|
||||
val = 0;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
Tl ival = (Tl)(lhs * rhs);
|
||||
To val = (To)std::min<Ti>(std::max<Ti>(ival, loVal), hiVal);
|
||||
template <typename Ti, typename Tl, typename To>
|
||||
static inline
|
||||
typename std::enable_if<!std::is_same<Ti, cl_half>::value, To>::type
|
||||
compute_saturated_output(Ti lhs, Ti rhs, cl_half_rounding_mode)
|
||||
{
|
||||
constexpr auto loVal = std::numeric_limits<To>::min();
|
||||
constexpr auto hiVal = std::numeric_limits<To>::max();
|
||||
|
||||
Tl ival = static_cast<Tl>(lhs * rhs);
|
||||
To val = static_cast<To>(std::min<Tl>(std::max<Tl>(ival, loVal), hiVal));
|
||||
|
||||
if (isnan(rhs))
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#define streamDup2(fd1, fd2) dup2(fd1, fd2)
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -232,8 +234,9 @@ lX = 4
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
return printf_operands_helper(device, "printf_operands_scalar_int64",
|
||||
"printf_operands_scalar_int64", expected, 4L);
|
||||
return printf_operands_helper<int64_t>(
|
||||
device, "printf_operands_scalar_int64", "printf_operands_scalar_int64",
|
||||
expected, 4L);
|
||||
}
|
||||
|
||||
REGISTER_TEST(extinst_printf_operands_scalar_fp64)
|
||||
|
||||
160
test_conformance/spirv_new/test_spirv_16.cpp
Normal file
160
test_conformance/spirv_new/test_spirv_16.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// Copyright (c) 2025 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"
|
||||
#include "spirvInfo.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
REGISTER_TEST(spirv16_image_operand_nontemporal)
|
||||
{
|
||||
if (!is_spirv_version_supported(device, "SPIR-V_1.6"))
|
||||
{
|
||||
log_info("SPIR-V 1.6 not supported; skipping tests.\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
clProgramWrapper prog;
|
||||
error = get_program_with_il(prog, device, context,
|
||||
"spv1.6/image_operand_nontemporal");
|
||||
SPIRV_CHECK_ERROR(error, "Failed to compile spv program");
|
||||
|
||||
clKernelWrapper kernel =
|
||||
clCreateKernel(prog, "read_write_image_nontemporal", &error);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to create spv kernel");
|
||||
|
||||
cl_image_format image_format = {
|
||||
CL_RGBA,
|
||||
CL_FLOAT,
|
||||
};
|
||||
|
||||
std::vector<cl_float> imgData({ 1.0f, 2.0f, -1.0f, 128.0f });
|
||||
clMemWrapper src =
|
||||
clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
&image_format, 1, 1, 0, imgData.data(), &error);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to create src image");
|
||||
|
||||
std::vector<cl_float> h_dst({ 0, 0, 0, 0 });
|
||||
clMemWrapper dst =
|
||||
clCreateImage2D(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
|
||||
&image_format, 1, 1, 0, h_dst.data(), &error);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to create dst image");
|
||||
|
||||
error |= clSetKernelArg(kernel, 0, sizeof(src), &src);
|
||||
error |= clSetKernelArg(kernel, 1, sizeof(dst), &dst);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to set kernel args");
|
||||
|
||||
size_t global = 1;
|
||||
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0,
|
||||
NULL, NULL);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel");
|
||||
|
||||
const size_t origin[] = { 0, 0, 0 };
|
||||
const size_t region[] = { 1, 1, 1 };
|
||||
error = clEnqueueReadImage(queue, dst, CL_TRUE, origin, region, 0, 0,
|
||||
h_dst.data(), 0, NULL, NULL);
|
||||
SPIRV_CHECK_ERROR(error, "Unable to read destination image");
|
||||
|
||||
if (h_dst != imgData)
|
||||
{
|
||||
log_error("Mismatch! Got: %f, %f, %f, %f, Wanted: %f, %f, %f, %f\n",
|
||||
h_dst[0], h_dst[1], h_dst[2], h_dst[3], imgData[0],
|
||||
imgData[1], imgData[2], imgData[3]);
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
static int test_uniformdecoration_helper(cl_device_id device,
|
||||
cl_context context,
|
||||
cl_command_queue queue,
|
||||
bool test_uniformid)
|
||||
{
|
||||
constexpr size_t global_size = 16;
|
||||
const cl_uint value = 42;
|
||||
const cl_uint check = value + 1;
|
||||
|
||||
const char* filename = test_uniformid ? "spv1.6/uniformdecoration_uniformid"
|
||||
: "spv1.6/uniformdecoration_uniform";
|
||||
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
clProgramWrapper prog;
|
||||
error = get_program_with_il(prog, device, context, filename);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to compile spv program");
|
||||
|
||||
clKernelWrapper kernel =
|
||||
clCreateKernel(prog, "test_uniformdecoration", &error);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to create spv kernel");
|
||||
|
||||
std::vector<cl_uint> h_dst(global_size);
|
||||
clMemWrapper dst =
|
||||
clCreateBuffer(context, CL_MEM_READ_WRITE,
|
||||
h_dst.size() * sizeof(cl_uint), nullptr, &error);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to create dst buffer");
|
||||
|
||||
error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst);
|
||||
error |= clSetKernelArg(kernel, 1, sizeof(value), &value);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to set kernel args");
|
||||
|
||||
error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &global_size,
|
||||
nullptr, 0, nullptr, nullptr);
|
||||
SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel");
|
||||
|
||||
error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0,
|
||||
h_dst.size() * sizeof(cl_uint), h_dst.data(), 0,
|
||||
nullptr, nullptr);
|
||||
SPIRV_CHECK_ERROR(error, "Unable to read dst buffer");
|
||||
|
||||
for (size_t i = 0; i < global_size; i++)
|
||||
{
|
||||
if (h_dst[i] != check)
|
||||
{
|
||||
log_error("Result mismatch at index %zu! Got %u, wanted %u.\n", i,
|
||||
h_dst[i], check);
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
REGISTER_TEST(spirv16_uniformdecoration_uniform)
|
||||
{
|
||||
if (!is_spirv_version_supported(device, "SPIR-V_1.6"))
|
||||
{
|
||||
log_info("SPIR-V 1.6 not supported; skipping tests.\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
return test_uniformdecoration_helper(device, context, queue, false);
|
||||
}
|
||||
|
||||
REGISTER_TEST(spirv16_uniformdecoration_uniformid)
|
||||
{
|
||||
if (!is_spirv_version_supported(device, "SPIR-V_1.6"))
|
||||
{
|
||||
log_info("SPIR-V 1.6 not supported; skipping tests.\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
return test_uniformdecoration_helper(device, context, queue, true);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user