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

CMD-Buf supported queue properties #126

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions include/CL/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_
#if defined(cl_khr_command_buffer)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_queue_properties)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR, cl_command_queue_properties)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
Expand Down
31 changes: 27 additions & 4 deletions layers/10_cmdbufemu/emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2732,22 +2732,45 @@ bool clGetDeviceInfo_override(
caps |= CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR;
}

auto ptr = (cl_device_command_buffer_capabilities_khr*)param_value;
cl_int errorCode = writeParamToMemory(
param_value_size,
caps,
param_value_size_ret,
ptr );

if( errcode_ret )
{
errcode_ret[0] = errorCode;
}
return true;
}
break;
case CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR:
{
cl_command_queue_properties cqProps = 0;
g_pNextDispatch->clGetDeviceInfo(
device,
CL_DEVICE_QUEUE_PROPERTIES,
sizeof(cqProps),
&cqProps,
nullptr );
if( cqProps & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE )

cl_command_queue_properties cbProps = 0;
if(cqProps & CL_QUEUE_PROFILING_ENABLE)
{
caps |= CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR;
cbProps |= CL_QUEUE_PROFILING_ENABLE;
}

auto ptr = (cl_device_command_buffer_capabilities_khr*)param_value;
if(cqProps & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
{
cbProps |= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
}

auto ptr = (cl_command_queue_properties*)param_value;
cl_int errorCode = writeParamToMemory(
param_value_size,
caps,
cbProps,
param_value_size_ret,
ptr );

Expand Down
18 changes: 13 additions & 5 deletions samples/12_commandbuffers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,17 @@ static void PrintCommandBufferCapabilities(
if (caps & CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR\n");

cl_device_command_buffer_capabilities_khr extra = caps & ~(
CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR |
CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR );
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR );
if (extra) {
printf("\t\t(Unknown capability: %016" PRIx64 ")\n", extra);
}
}

static void PrintCommandBufferRequiredQueueProperties(
static void PrintCommandBufferQueueProperties(
cl_command_queue_properties props )
{
if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) printf("\t\tCL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
Expand Down Expand Up @@ -137,7 +135,17 @@ int main(
&requiredProps,
NULL );
printf("\tCommand Buffer Required Queue Properties:\n");
PrintCommandBufferRequiredQueueProperties(requiredProps);
PrintCommandBufferQueueProperties(requiredProps);

cl_command_queue_properties supportedProps = 0;
clGetDeviceInfo(
devices[deviceIndex](),
CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR,
sizeof(supportedProps),
&supportedProps,
NULL );
printf("\tCommand Buffer Supported Queue Properties:\n");
PrintCommandBufferQueueProperties(supportedProps);

cl::Context context{devices[deviceIndex]};
cl::CommandQueue commandQueue{context, devices[deviceIndex]};
Expand Down
12 changes: 7 additions & 5 deletions samples/12_commandbufferspp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ static void PrintCommandBufferCapabilities(
if (caps & CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR\n");

cl_device_command_buffer_capabilities_khr extra = caps & ~(
CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR |
CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR );
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR );
if (extra) {
printf("\t\t(Unknown capability: %016" PRIx64 ")\n", extra);
}
}

static void PrintCommandBufferRequiredQueueProperties(
static void PrintCommandBufferQueueProperties(
cl_command_queue_properties props )
{
if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) printf("\t\tCL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
Expand Down Expand Up @@ -119,9 +117,13 @@ int main(
devices[deviceIndex].getInfo<CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR>());

printf("\tCommand Buffer Required Queue Properties:\n");
PrintCommandBufferRequiredQueueProperties(
PrintCommandBufferQueueProperties(
devices[deviceIndex].getInfo<CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR>());

printf("\tCommand Buffer Supported Queue Properties:\n");
PrintCommandBufferQueueProperties(
devices[deviceIndex].getInfo<CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR>());

cl::Context context{devices[deviceIndex]};
cl::CommandQueue commandQueue{context, devices[deviceIndex]};

Expand Down
18 changes: 13 additions & 5 deletions samples/13_mutablecommandbuffers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ static void PrintCommandBufferCapabilities(
if (caps & CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR\n");
if (caps & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR ) printf("\t\tCL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR\n");

cl_device_command_buffer_capabilities_khr extra = caps & ~(
CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR |
CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR |
CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR );
CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR );
if (extra) {
printf("\t\t(Unknown capability: %016" PRIx64 ")\n", extra);
}
}

static void PrintCommandBufferRequiredQueueProperties(
static void PrintCommandBufferQueueProperties(
cl_command_queue_properties props )
{
if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) printf("\t\tCL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
Expand Down Expand Up @@ -162,7 +160,17 @@ int main(
&requiredProps,
NULL );
printf("\tCommand Buffer Required Queue Properties:\n");
PrintCommandBufferRequiredQueueProperties(requiredProps);
PrintCommandBufferQueueProperties(requiredProps);

cl_command_queue_properties supportedProps = 0;
clGetDeviceInfo(
devices[deviceIndex](),
CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR,
sizeof(supportedProps),
&supportedProps,
NULL );
printf("\tCommand Buffer Supported Queue Properties:\n");
PrintCommandBufferQueueProperties(supportedProps);

cl_mutable_dispatch_fields_khr mutableCaps = 0;
clGetDeviceInfo(
Expand Down
6 changes: 3 additions & 3 deletions samples/14_ooqcommandbuffers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ int main(
return -1;
}

cl_device_command_buffer_capabilities_khr cmdbufcaps =
devices[deviceIndex].getInfo<CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR>();
if (cmdbufcaps & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR) {
cl_command_queue_properties cmdbufqueueprops =
devices[deviceIndex].getInfo<CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR>();
if (cmdbufqueueprops & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) {
printf("Device supports out-of-order command buffers.\n");
} else {
printf("Device does not support out-of-order command buffers, exiting.\n");
Expand Down