Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new query for cl_khr_semaphore test to verify device handle list #1942

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <system_error>
#include <thread>
#include <chrono>
#include <vector>

#define FLUSH_DELAY_S 5

Expand Down Expand Up @@ -82,7 +83,7 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -115,7 +116,7 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID,
&wait_event);
test_error(err, "Could not wait semaphore");

// Finish queue_1 and queue_2
// Finish queue_1 and queue_2
err = clFinish(queue_1);
test_error(err, "Could not finish queue");

Expand All @@ -133,15 +134,15 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID,
return TEST_PASS;
}

// Confirm that a signal followed by a wait will complete successfully
// Confirm that a signal followed by a wait will complete successfully
int test_semaphores_simple_1(cl_device_id deviceID, cl_context context,
cl_command_queue defaultQueue, int num_elements)
{
cl_int err;

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -203,7 +204,7 @@ int test_semaphores_simple_2(cl_device_id deviceID, cl_context context,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -295,7 +296,7 @@ int test_semaphores_reuse(cl_device_id deviceID, cl_context context,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -438,7 +439,7 @@ int test_semaphores_multi_signal(cl_device_id deviceID, cl_context context,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -514,7 +515,7 @@ int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand Down Expand Up @@ -586,11 +587,11 @@ int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context,
int test_semaphores_queries(cl_device_id deviceID, cl_context context,
cl_command_queue defaultQueue, int num_elements)
{
cl_int err;
cl_int err = CL_SUCCESS;

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}
Expand All @@ -605,6 +606,10 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context,
cl_semaphore_properties_khr sema_props[] = {
static_cast<cl_semaphore_properties_khr>(CL_SEMAPHORE_TYPE_KHR),
static_cast<cl_semaphore_properties_khr>(CL_SEMAPHORE_TYPE_BINARY_KHR),
static_cast<cl_semaphore_properties_khr>(
CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR),
(cl_semaphore_properties_khr)deviceID,
CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR,
0
};
cl_semaphore_khr sema =
Expand All @@ -623,6 +628,11 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context,
// value
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1);

// Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the
// same device id the semaphore was created with
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id,
deviceID);

err = clRetainSemaphoreKHR(sema);
test_error(err, "Could not retain semaphore");
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 2);
Expand All @@ -634,7 +644,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context,
// Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same
// properties the semaphore was created with
SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR,
cl_semaphore_properties_khr, 3, sema_props);
cl_semaphore_properties_khr, 6, sema_props);

// Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled
// state
Expand All @@ -656,15 +666,15 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context,

if (!is_extension_available(deviceID, "cl_khr_semaphore"))
{
log_info("cl_khr_semaphore is not supported on this platoform. "
log_info("cl_khr_semaphore is not supported on this platform. "
"Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}

if (!is_extension_available(deviceID, "cl_khr_external_semaphore_sync_fd"))
{
log_info("cl_khr_external_semaphore_sync_fd is not supported on this "
"platoform. Skipping test.\n");
"platform. Skipping test.\n");
return TEST_SKIPPED_ITSELF;
}

Expand Down Expand Up @@ -745,4 +755,4 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context,
err = clReleaseSemaphoreKHR(sema_2);
test_error(err, "Could not release semaphore");
return TEST_PASS;
}
}
Loading