mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Migrate device_partition suite to the new test registration framework (#2301)
Contributes to #2181
This commit is contained in:
@@ -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);
|
||||
@@ -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 (test_device_partition_type_support(device, partitionProp[i][0],
|
||||
partitionProp[i][1])
|
||||
!= 0)
|
||||
{
|
||||
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",
|
||||
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);
|
||||
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]), deviceID);
|
||||
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]),
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user