Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhnv committed Aug 16, 2024
1 parent 843ba0d commit f151be9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 44 deletions.
6 changes: 4 additions & 2 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,11 @@ std::string get_platform_info_string(cl_platform_id platform,
return std::string(info.data(), size - 1);
}

bool is_platform_extension_available(cl_platform_id platform, const char* extensionName)
bool is_platform_extension_available(cl_platform_id platform,
const char *extensionName)
{
std::string extString = get_platform_info_string(platform, CL_PLATFORM_EXTENSIONS);
std::string extString =
get_platform_info_string(platform, CL_PLATFORM_EXTENSIONS);
return extString.find(extensionName) != std::string::npos;
}

Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/testHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extern cl_platform_id getPlatformFromDevice(cl_device_id deviceID);
extern std::string get_platform_info_string(cl_platform_id platform,
cl_platform_info param_name);
extern bool is_platform_extension_available(cl_platform_id platform,
const char* extensionName);
const char *extensionName);

#if !defined(__APPLE__)
void memset_pattern4(void *, const void *, size_t);
Expand Down
7 changes: 4 additions & 3 deletions test_conformance/vulkan/test_vulkan_api_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ int test_consistency_external_semaphore(cl_device_id deviceID,

// Pass invalid object to release call
errNum = clReleaseSemaphoreKHRptr(NULL);
test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR,
"clReleaseSemaphoreKHRptr fails with "
"CL_INVALID_SEMAPHORE_KHR when NULL semaphore object is passed");
test_failure_error(
errNum, CL_INVALID_SEMAPHORE_KHR,
"clReleaseSemaphoreKHRptr fails with "
"CL_INVALID_SEMAPHORE_KHR when NULL semaphore object is passed");

// Release both semaphore objects
errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore);
Expand Down
85 changes: 47 additions & 38 deletions test_conformance/vulkan/test_vulkan_platform_device_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,19 @@ int test_platform_info(cl_device_id deviceID, cl_context _context,
cl_command_queue _queue, int num_elements)
{
cl_uint i;
cl_platform_id platform;
cl_platform_id platform = getPlatformFromDevice(deviceID);
cl_int errNum;
cl_uint *handle_type;
size_t handle_type_size = 0;
cl_uint num_handles = 0;
cl_bool external_mem_extn_available = false;
cl_bool external_sema_extn_available = false;
cl_bool supports_atleast_one_sema_query = false;

platform = getPlatformFromDevice(deviceID);

external_mem_extn_available =
cl_bool external_mem_extn_available =
is_platform_extension_available(platform, "cl_khr_external_semaphore");
external_sema_extn_available =
cl_bool external_sema_extn_available =
is_platform_extension_available(platform, "cl_khr_external_memory");
supports_atleast_one_sema_query = false;
cl_bool supports_atleast_one_sema_query = false;

if (!external_mem_extn_available && !external_sema_extn_available) {
if (!external_mem_extn_available && !external_sema_extn_available)
{
log_info("Platform does not support 'cl_khr_external_semaphore' "
"and 'cl_khr_external_memory'. Skipping the test.\n");
return TEST_SKIPPED_ITSELF;
Expand All @@ -80,35 +75,39 @@ int test_platform_info(cl_device_id deviceID, cl_context _context,
log_info("Platform (id %lu) info:\n", (unsigned long)platform);

for (i = 0;
i < sizeof(platform_info_table) / sizeof(platform_info_table[0]);
i++)
i < sizeof(platform_info_table) / sizeof(platform_info_table[0]); i++)
{
errNum =
clGetPlatformInfo(platform, platform_info_table[i].info, 0,
NULL, &handle_type_size);
errNum = clGetPlatformInfo(platform, platform_info_table[i].info, 0,
NULL, &handle_type_size);
test_error(errNum, "clGetPlatformInfo failed");

if (handle_type_size == 0) {
if (platform_info_table[i].info == CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
&& external_mem_extn_available) {
test_fail("External memory import handle types should be reported if "
"cl_khr_external_memory is available.\n");
if (handle_type_size == 0)
{
if (platform_info_table[i].info
== CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
&& external_mem_extn_available)
{
test_fail(
"External memory import handle types should be reported if "
"cl_khr_external_memory is available.\n");
}
log_info("%s not supported. Skipping the query.\n",
platform_info_table[i].name);
platform_info_table[i].name);
continue;
}

if ((platform_info_table[i].info == CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) ||
(platform_info_table[i].info == CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) {
if ((platform_info_table[i].info
== CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR)
|| (platform_info_table[i].info
== CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR))
{
supports_atleast_one_sema_query = true;
}

num_handles = handle_type_size / sizeof(cl_uint);
handle_type = (cl_uint *)malloc(handle_type_size);
errNum =
clGetPlatformInfo(platform, platform_info_table[i].info,
handle_type_size, handle_type, NULL);
errNum = clGetPlatformInfo(platform, platform_info_table[i].info,
handle_type_size, handle_type, NULL);
test_error(errNum, "clGetPlatformInfo failed");

log_info("%s: \n", platform_info_table[i].name);
Expand All @@ -122,7 +121,8 @@ int test_platform_info(cl_device_id deviceID, cl_context _context,
}
}

if (external_sema_extn_available && !supports_atleast_one_sema_query) {
if (external_sema_extn_available && !supports_atleast_one_sema_query)
{
log_info("External semaphore import/export or both should be supported "
"if cl_khr_external_semaphore is available.\n");
return TEST_FAIL;
Expand All @@ -145,7 +145,8 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
is_extension_available(deviceID, "cl_khr_external_semaphore");
cl_bool supports_atleast_one_sema_query = false;

if (!external_mem_extn_available && !external_sema_extn_available) {
if (!external_mem_extn_available && !external_sema_extn_available)
{
log_info("Device does not support 'cl_khr_external_semaphore' "
"and 'cl_khr_external_memory'. Skipping the test.\n");
return TEST_SKIPPED_ITSELF;
Expand All @@ -158,19 +159,26 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
&handle_type_size);
test_error(errNum, "clGetDeviceInfo failed");

if (handle_type_size == 0) {
if (device_info_table[j].info == CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
&& external_mem_extn_available) {
test_fail("External memory import handle types should be reported if "
"cl_khr_external_memory is available.\n");
if (handle_type_size == 0)
{
if (device_info_table[j].info
== CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
&& external_mem_extn_available)
{
test_fail(
"External memory import handle types should be reported if "
"cl_khr_external_memory is available.\n");
}
log_info("%s not supported. Skipping the query.\n",
device_info_table[j].name);
device_info_table[j].name);
continue;
}

if ((device_info_table[j].info == CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) ||
(device_info_table[j].info == CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) {
if ((device_info_table[j].info
== CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR)
|| (device_info_table[j].info
== CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR))
{
supports_atleast_one_sema_query = true;
}

Expand All @@ -192,7 +200,8 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
}
}

if (external_sema_extn_available && !supports_atleast_one_sema_query) {
if (external_sema_extn_available && !supports_atleast_one_sema_query)
{
log_info("External semaphore import/export or both should be supported "
"if cl_khr_external_semaphore is available.\n");
return TEST_FAIL;
Expand Down

0 comments on commit f151be9

Please sign in to comment.