Skip to content

Commit

Permalink
[NFC] Change the name of the default device provided by the new regis…
Browse files Browse the repository at this point in the history
…tration framework

The code base uses a mix of 'device' and 'deviceID'. I suggest
we standardise on 'device' which is shorter and slightly more prevalent.

Contributes to KhronosGroup#2181

Signed-off-by: Kevin Petit <[email protected]>
  • Loading branch information
kpet committed Dec 12, 2024
1 parent 56d383b commit 7b39f66
Show file tree
Hide file tree
Showing 42 changed files with 174 additions and 162 deletions.
4 changes: 2 additions & 2 deletions test_common/harness/testHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ template <typename T> T *register_test(const char *name, Version version)
}

#define REGISTER_TEST_VERSION(name, version) \
extern int test_##name(cl_device_id deviceID, cl_context context, \
extern int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements); \
class test_##name##_class : public test { \
private: \
Expand All @@ -145,7 +145,7 @@ template <typename T> T *register_test(const char *name, Version version)
}; \
test_##name##_class *var_##name = \
register_test<test_##name##_class>(#name, version); \
int test_##name(cl_device_id deviceID, cl_context context, \
int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements)

#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
Expand Down
7 changes: 3 additions & 4 deletions test_conformance/SVM/test_allocate_shared_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer)
clCommandQueueWrapper queues[MAXQ];

cl_device_svm_capabilities caps;
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");

// under construction...
err =
create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return -1;

Expand Down
7 changes: 3 additions & 4 deletions test_conformance/SVM/test_allocate_shared_buffer_negative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer_negative)
clCommandQueueWrapper queues[MAXQ];

cl_device_svm_capabilities caps;
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");

// under construction...
err =
create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return err;

Expand Down
2 changes: 1 addition & 1 deletion test_conformance/SVM/test_byte_granularity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ REGISTER_TEST(svm_byte_granularity)
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;

err = create_cl_objects(deviceID, &byte_manipulation_kernels[0],
err = create_cl_objects(device, &byte_manipulation_kernels[0],
&contextWrapper, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/SVM/test_cross_buffer_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ REGISTER_TEST(svm_cross_buffer_pointers_coarse_grain)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

error = create_cl_objects(deviceID, &SVMCrossBufferPointers_test_kernel[0],
error = create_cl_objects(device, &SVMCrossBufferPointers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/SVM/test_enqueue_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ REGISTER_TEST(svm_enqueue_api)
cl_int error = CL_SUCCESS;
RandomSeed seed(0);

error = create_cl_objects(deviceID, NULL, &contextWrapper, NULL, &queues[0],
error = create_cl_objects(device, NULL, &contextWrapper, NULL, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return TEST_FAIL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ REGISTER_TEST(svm_fine_grain_memory_consistency)
char *source[] = { hash_table_kernel };

err = create_cl_objects(
deviceID, (const char **)source, &contextWrapper, &program, &queues[0],
device, (const char **)source, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS,
required_extensions);
context = contextWrapper;
Expand Down
7 changes: 3 additions & 4 deletions test_conformance/SVM/test_fine_grain_sync_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ REGISTER_TEST(svm_fine_grain_sync_buffers)
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

err = create_cl_objects(deviceID, &find_targets_kernel[0], &contextWrapper,
&program, &queues[0], &num_devices,
CL_DEVICE_SVM_FINE_GRAIN_BUFFER
| CL_DEVICE_SVM_ATOMICS);
err = create_cl_objects(
device, &find_targets_kernel[0], &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
context = contextWrapper;
if (err == 1)
return 0; // no devices capable of requested SVM level, so don't execute
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/SVM/test_migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ REGISTER_TEST(svm_migrate)
clProgramWrapper program;
cl_int error;

error = create_cl_objects(deviceID, &sources[0], &contextWrapper, &program,
error = create_cl_objects(device, &sources[0], &contextWrapper, &program,
&queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
Expand Down Expand Up @@ -202,7 +202,7 @@ REGISTER_TEST(svm_migrate)

// Check the event command type for clEnqueueSVMMigrateMem (OpenCL 3.0 and
// newer)
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
if (version >= Version(3, 0))
{
cl_command_type commandType;
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/SVM/test_pointer_passing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ REGISTER_TEST(svm_pointer_passing)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

error = create_cl_objects(deviceID, &SVMPointerPassing_test_kernel[0],
error = create_cl_objects(device, &SVMPointerPassing_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
Expand Down
7 changes: 5 additions & 2 deletions test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ REGISTER_TEST(svm_set_kernel_exec_info_svm_ptrs)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

//error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &c, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
// error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
// &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
&c, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(error < 0) return -1; // fail test.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ int shared_address_space_coarse_grain(cl_device_id deviceID, cl_context context2

REGISTER_TEST(svm_shared_address_space_coarse_grain_old_api)
{
return shared_address_space_coarse_grain(deviceID, context, queue,
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_FALSE);
}

REGISTER_TEST(svm_shared_address_space_coarse_grain_new_api)
{
return shared_address_space_coarse_grain(deviceID, context, queue,
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_TRUE);
}
6 changes: 3 additions & 3 deletions test_conformance/SVM/test_shared_address_space_fine_grain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

error = create_cl_objects(
deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper,
&program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain_buffers)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

error = create_cl_objects(
deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper,
&program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/SVM/test_shared_sub_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ REGISTER_TEST(svm_shared_sub_buffers)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];

error = create_cl_objects(deviceID, &shared_sub_buffers_test_kernel[0],
error = create_cl_objects(device, &shared_sub_buffers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
Expand Down
17 changes: 10 additions & 7 deletions test_conformance/device_timer/test_device_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ REGISTER_TEST(device_and_host_timers)
cl_ulong observedDiff;
cl_ulong allowedDiff;

result = clGetDeviceAndHostTimer(deviceID, &deviceStartTime, &hostStartTime);
result = clGetDeviceAndHostTimer(device, &deviceStartTime, &hostStartTime);
if (result != CL_SUCCESS) {
log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
goto End;
}

result = clGetHostTimer(deviceID, &hostOnlyStartTime);
result = clGetHostTimer(device, &hostOnlyStartTime);
if (result != CL_SUCCESS) {
log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
Expand All @@ -52,14 +52,14 @@ REGISTER_TEST(device_and_host_timers)
// Wait for a while to allow the timers to increment substantially.
sleep(5);

result = clGetDeviceAndHostTimer(deviceID, &deviceEndTime, &hostEndTime);
result = clGetDeviceAndHostTimer(device, &deviceEndTime, &hostEndTime);
if (result != CL_SUCCESS) {
log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
goto End;
}

result = clGetHostTimer(deviceID, &hostOnlyEndTime);
result = clGetHostTimer(device, &hostOnlyEndTime);
if (result != CL_SUCCESS) {
log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
Expand Down Expand Up @@ -133,13 +133,16 @@ REGISTER_TEST(timer_resolution_queries)
cl_ulong deviceTimerResolution = 0;
cl_ulong hostTimerResolution = 0;

result = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
result = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
if (result != CL_SUCCESS) {
log_error("clGetDeviceInfo(CL_DEVICE_PLATFORM) failed with error %s.\n", IGetErrorString(result));
errors++;
}

result = clGetDeviceInfo(deviceID, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(deviceTimerResolution), &deviceTimerResolution, NULL);

result = clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION,
sizeof(deviceTimerResolution),
&deviceTimerResolution, NULL);
if (result != CL_SUCCESS) {
log_error("clGetDeviceInfo(CL_DEVICE_PROFILING_TIMER_RESOLUTION) failed with error %s.\n", IGetErrorString(result));
errors++;
Expand Down
8 changes: 4 additions & 4 deletions test_conformance/spirv_new/test_basic_versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ REGISTER_TEST(basic_versions)
});

size_t sz = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
error = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
test_error(error, "Unable to query device IL versions size");

std::string ilVersions;
ilVersions.resize(sz);
error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, sz, &ilVersions[0],
NULL);
error =
clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, sz, &ilVersions[0], NULL);
test_error(error, "Unable to query device IL versions string");

for (auto& testCase : mapILtoSubdir)
Expand Down Expand Up @@ -88,7 +88,7 @@ REGISTER_TEST(basic_versions)
std::string filename = testCase.second + "/basic";

clProgramWrapper prog;
error = get_program_with_il(prog, deviceID, context, filename.c_str());
error = get_program_with_il(prog, device, context, filename.c_str());
test_error(error, "Unable to build SPIR-V program");

clKernelWrapper kernel = clCreateKernel(prog, "test_basic", &error);
Expand Down
16 changes: 8 additions & 8 deletions test_conformance/spirv_new/test_cl_khr_expect_assume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,29 @@ static int test_expect_type(cl_device_id device, cl_context context,

REGISTER_TEST(op_expect)
{
if (!is_extension_available(deviceID, "cl_khr_expect_assume"))
if (!is_extension_available(device, "cl_khr_expect_assume"))
{
log_info("cl_khr_expect_assume is not supported; skipping test.\n");
return TEST_SKIPPED_ITSELF;
}

int result = TEST_PASS;

result |= test_expect_type<cl_char>(deviceID, context, queue);
result |= test_expect_type<cl_short>(deviceID, context, queue);
result |= test_expect_type<cl_int>(deviceID, context, queue);
result |= test_expect_type<cl_char>(device, context, queue);
result |= test_expect_type<cl_short>(device, context, queue);
result |= test_expect_type<cl_int>(device, context, queue);
if (gHasLong)
{
result |= test_expect_type<cl_long>(deviceID, context, queue);
result |= test_expect_type<cl_long>(device, context, queue);
}
result |= test_expect_type<cl_bool>(deviceID, context, queue);
result |= test_expect_type<cl_bool>(device, context, queue);

return result;
}

REGISTER_TEST(op_assume)
{
if (!is_extension_available(deviceID, "cl_khr_expect_assume"))
if (!is_extension_available(device, "cl_khr_expect_assume"))
{
log_info("cl_khr_expect_assume is not supported; skipping test.\n");
return TEST_SKIPPED_ITSELF;
Expand All @@ -154,7 +154,7 @@ REGISTER_TEST(op_assume)
test_error(error, "Unable to create destination buffer");

clProgramWrapper prog;
error = get_program_with_il(prog, deviceID, context, "assume");
error = get_program_with_il(prog, device, context, "assume");
test_error(error, "Unable to build SPIR-V program");

clKernelWrapper kernel = clCreateKernel(prog, "test_assume", &error);
Expand Down
16 changes: 8 additions & 8 deletions test_conformance/spirv_new/test_decorate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,24 @@ int test_decorate_full(cl_device_id deviceID,

REGISTER_TEST(decorate_restrict)
{
return test_decorate_full(deviceID, context, queue, "decorate_restrict");
return test_decorate_full(device, context, queue, "decorate_restrict");
}

REGISTER_TEST(decorate_aliased)
{
return test_decorate_full(deviceID, context, queue, "decorate_aliased");
return test_decorate_full(device, context, queue, "decorate_aliased");
}

REGISTER_TEST(decorate_alignment)
{
//TODO: Check for results ? How to ensure buffers are aligned
clProgramWrapper prog;
return get_program_with_il(prog, deviceID, context, "decorate_alignment");
return get_program_with_il(prog, device, context, "decorate_alignment");
}

REGISTER_TEST(decorate_constant)
{
return test_decorate_full(deviceID, context, queue, "decorate_constant");
return test_decorate_full(device, context, queue, "decorate_constant");
}

REGISTER_TEST(decorate_cpacked)
Expand All @@ -145,7 +145,7 @@ REGISTER_TEST(decorate_cpacked)

std::vector<packed_t> packed(num);
clProgramWrapper prog;
cl_int err = get_program_with_il(prog, deviceID, context, "decorate_cpacked");
cl_int err = get_program_with_il(prog, device, context, "decorate_cpacked");

clKernelWrapper kernel = clCreateKernel(prog, "decorate_cpacked", &err);
SPIRV_CHECK_ERROR(err, "Failed to create spv kernel");
Expand Down Expand Up @@ -388,8 +388,8 @@ int test_saturate_full(cl_device_id deviceID,
typedef cl_##Tl cl_Tl; \
typedef cl_##To cl_To; \
const char *name = "decorate_saturated_conversion_" #Ti "_to_" #To; \
return test_saturate_full<cl_Ti, cl_Tl, cl_To>( \
deviceID, context, queue, name, #Ti #Tl #To); \
return test_saturate_full<cl_Ti, cl_Tl, cl_To>(device, context, queue, \
name, #Ti #Tl #To); \
}

TEST_SATURATED_CONVERSION(half, short, char)
Expand Down Expand Up @@ -547,7 +547,7 @@ static inline Ti generate_fprounding_input(RandomSeed &seed)
out[i] = func<clTi, clTo>(in[i]); \
} \
const char *name = "decorate_rounding_" #name "_" #Ti "_" #To; \
return test_fp_rounding(deviceID, context, queue, name, in, out); \
return test_fp_rounding(device, context, queue, name, in, out); \
}

TEST_SPIRV_FP_ROUNDING_DECORATE(rte, round_to_even, half, short);
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/spirv_new/test_get_program_il.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ REGISTER_TEST(get_program_il)

/* If a program has been created with clCreateProgramWithIL, CL_PROGRAM_IL
* should return the program IL it was created with and it's size */
if (gCoreILProgram || is_extension_available(deviceID, "cl_khr_il_program"))
if (gCoreILProgram || is_extension_available(device, "cl_khr_il_program"))
{
clProgramWrapper il_program;
std::string spvStr = "op_function_none";
Expand All @@ -51,7 +51,7 @@ REGISTER_TEST(get_program_il)
/* Create program with IL */
unsigned char *spirv_buffer = &spirv_binary[0];

error = get_program_with_il(il_program, deviceID, context, spvName);
error = get_program_with_il(il_program, device, context, spvName);

SPIRV_CHECK_ERROR(error, "Unable to create program with IL.");
if (il_program == NULL)
Expand Down
Loading

0 comments on commit 7b39f66

Please sign in to comment.