2020#include " emulate.h"
2121
2222static constexpr cl_version version_cl_khr_command_buffer =
23- CL_MAKE_VERSION (0 , 9 , 4 );
23+ CL_MAKE_VERSION (0 , 9 , 5 );
2424static constexpr cl_version version_cl_khr_command_buffer_mutable_dispatch =
25- CL_MAKE_VERSION (0 , 9 , 1 );
25+ CL_MAKE_VERSION (0 , 9 , 3 );
2626
2727SLayerContext& getLayerContext (void )
2828{
@@ -106,11 +106,9 @@ typedef struct _cl_mutable_command_khr
106106 ptr );
107107 }
108108 break ;
109- // These are only valid for clCommandNDRangeKernel, but the spec says
110- // they should return size = 0 rather than an error.
111- case CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR:
109+ case CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR:
112110 {
113- auto ptr = (cl_ndrange_kernel_command_properties_khr *)param_value;
111+ auto ptr = (cl_command_properties_khr *)param_value;
114112 return writeVectorToMemory (
115113 param_value_size,
116114 {}, // No properties are currently supported.
@@ -811,7 +809,7 @@ struct SVMMemFill : Command
811809struct NDRangeKernel : Command
812810{
813811 static std::unique_ptr<NDRangeKernel> create (
814- const cl_ndrange_kernel_command_properties_khr * properties,
812+ const cl_command_properties_khr * properties,
815813 cl_command_buffer_khr cmdbuf,
816814 cl_command_queue queue,
817815 cl_kernel kernel,
@@ -836,9 +834,10 @@ struct NDRangeKernel : Command
836834 {
837835 switch ( param_name )
838836 {
839- case CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR:
837+ // TODO: eventually this should move to the base Command class.
838+ case CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR:
840839 {
841- auto ptr = (cl_ndrange_kernel_command_properties_khr *)param_value;
840+ auto ptr = (cl_command_properties_khr *)param_value;
842841 return writeVectorToMemory (
843842 param_value_size,
844843 properties,
@@ -1101,7 +1100,7 @@ struct NDRangeKernel : Command
11011100 cl_mutable_dispatch_asserts_khr mutableAsserts = 0 ;
11021101 size_t numWorkGroups = 0 ;
11031102#endif // defined(cl_khr_command_buffer_mutable_dispatch)
1104- std::vector<cl_command_buffer_properties_khr > properties;
1103+ std::vector<cl_command_properties_khr > properties;
11051104 std::vector<size_t > global_work_offset;
11061105 std::vector<size_t > global_work_size;
11071106 std::vector<size_t > local_work_size;
@@ -1510,7 +1509,10 @@ typedef struct _cl_command_buffer_khr
15101509 }
15111510
15121511#if defined(cl_khr_command_buffer_mutable_dispatch)
1513- cl_int mutate ( const cl_mutable_base_config_khr* mutable_config )
1512+ cl_int mutate (
1513+ cl_uint numUpdates,
1514+ const cl_command_buffer_update_type_khr* updateTypes,
1515+ const void ** updateConfigs )
15141516 {
15151517 if ( State != CL_COMMAND_BUFFER_STATE_EXECUTABLE_KHR )
15161518 {
@@ -1521,48 +1523,32 @@ typedef struct _cl_command_buffer_khr
15211523 return CL_INVALID_OPERATION;
15221524 }
15231525
1524- if ( mutable_config == nullptr )
1525- {
1526- return CL_INVALID_VALUE;
1527- }
1528- if ( mutable_config->type != CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR )
1529- {
1530- return CL_INVALID_VALUE;
1531- }
1532- if ( mutable_config->next == nullptr && mutable_config->mutable_dispatch_list == nullptr )
1533- {
1534- return CL_INVALID_VALUE;
1535- }
1536- if ( ( mutable_config->num_mutable_dispatch > 0 && mutable_config->mutable_dispatch_list == nullptr ) ||
1537- ( mutable_config->num_mutable_dispatch == 0 && mutable_config->mutable_dispatch_list != nullptr ) )
1526+ if ( ( numUpdates > 0 && updateTypes == nullptr ) ||
1527+ ( numUpdates == 0 && updateTypes != nullptr ) )
15381528 {
15391529 return CL_INVALID_VALUE;
15401530 }
1541- // No "next" extensions are currently supported.
1542- if ( mutable_config-> next != nullptr )
1531+ if ( ( numUpdates > 0 && updateConfigs == nullptr ) ||
1532+ ( numUpdates == 0 && updateConfigs != nullptr ) )
15431533 {
15441534 return CL_INVALID_VALUE;
15451535 }
15461536
1547- for ( cl_uint i = 0 ; i < mutable_config-> num_mutable_dispatch ; i++ )
1537+ for ( cl_uint i = 0 ; i < numUpdates ; i++ )
15481538 {
1549- const cl_mutable_dispatch_config_khr* dispatchConfig =
1550- &mutable_config->mutable_dispatch_list [i];
1551- if ( !Command::isValid (dispatchConfig->command ) ||
1552- dispatchConfig->command ->getCmdBuf () != this )
1553- {
1554- return CL_INVALID_MUTABLE_COMMAND_KHR;
1555- }
1556- if ( dispatchConfig->type == CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR )
1539+ if ( updateTypes[i] == CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR &&
1540+ updateConfigs[i] != nullptr )
15571541 {
1558- if ( dispatchConfig->command ->getType () != CL_COMMAND_NDRANGE_KERNEL )
1542+ auto config = (const cl_mutable_dispatch_config_khr*)updateConfigs[i];
1543+ if ( !Command::isValid (config->command ) ||
1544+ config->command ->getCmdBuf () != this ||
1545+ config->command ->getType () != CL_COMMAND_NDRANGE_KERNEL )
15591546 {
15601547 return CL_INVALID_MUTABLE_COMMAND_KHR;
15611548 }
1562-
1563- if ( cl_int errorCode = ((NDRangeKernel*)dispatchConfig->command )->mutate (
1549+ if ( cl_int errorCode = ((NDRangeKernel*)config->command )->mutate (
15641550 MutableDispatchAsserts,
1565- dispatchConfig ) )
1551+ config ) )
15661552 {
15671553 return errorCode;
15681554 }
@@ -1624,7 +1610,7 @@ _cl_mutable_command_khr::_cl_mutable_command_khr(
16241610 Queue(queue ? queue : cmdbuf->getQueue ()) {}
16251611
16261612std::unique_ptr<NDRangeKernel> NDRangeKernel::create (
1627- const cl_ndrange_kernel_command_properties_khr * properties,
1613+ const cl_command_properties_khr * properties,
16281614 cl_command_buffer_khr cmdbuf,
16291615 cl_command_queue queue,
16301616 cl_kernel kernel,
@@ -1644,7 +1630,7 @@ std::unique_ptr<NDRangeKernel> NDRangeKernel::create(
16441630
16451631 if ( properties )
16461632 {
1647- const cl_ndrange_kernel_command_properties_khr * check = properties;
1633+ const cl_command_properties_khr * check = properties;
16481634 bool found_CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR = false ;
16491635 bool found_CL_MUTABLE_DISPATCH_ASSERTS_KHR = false ;
16501636 while ( errorCode == CL_SUCCESS && check[0 ] != 0 )
@@ -1890,6 +1876,7 @@ cl_int CL_API_CALL clEnqueueCommandBufferKHR_EMU(
18901876cl_int CL_API_CALL clCommandBarrierWithWaitListKHR_EMU (
18911877 cl_command_buffer_khr cmdbuf,
18921878 cl_command_queue command_queue,
1879+ const cl_command_properties_khr* properties,
18931880 cl_uint num_sync_points_in_wait_list,
18941881 const cl_sync_point_khr* sync_point_wait_list,
18951882 cl_sync_point_khr* sync_point,
@@ -1906,6 +1893,10 @@ cl_int CL_API_CALL clCommandBarrierWithWaitListKHR_EMU(
19061893 {
19071894 return errorCode;
19081895 }
1896+ if ( properties != nullptr && properties[0 ] != 0 )
1897+ {
1898+ return CL_INVALID_PROPERTY;
1899+ }
19091900 if ( mutable_handle != nullptr )
19101901 {
19111902 return CL_INVALID_VALUE;
@@ -1926,6 +1917,7 @@ cl_int CL_API_CALL clCommandBarrierWithWaitListKHR_EMU(
19261917cl_int CL_API_CALL clCommandCopyBufferKHR_EMU (
19271918 cl_command_buffer_khr cmdbuf,
19281919 cl_command_queue command_queue,
1920+ const cl_command_properties_khr* properties,
19291921 cl_mem src_buffer,
19301922 cl_mem dst_buffer,
19311923 size_t src_offset,
@@ -1947,6 +1939,10 @@ cl_int CL_API_CALL clCommandCopyBufferKHR_EMU(
19471939 {
19481940 return errorCode;
19491941 }
1942+ if ( properties != nullptr && properties[0 ] != 0 )
1943+ {
1944+ return CL_INVALID_PROPERTY;
1945+ }
19501946 if ( mutable_handle != nullptr )
19511947 {
19521948 return CL_INVALID_VALUE;
@@ -1974,6 +1970,7 @@ cl_int CL_API_CALL clCommandCopyBufferKHR_EMU(
19741970cl_int CL_API_CALL clCommandCopyBufferRectKHR_EMU (
19751971 cl_command_buffer_khr cmdbuf,
19761972 cl_command_queue command_queue,
1973+ const cl_command_properties_khr* properties,
19771974 cl_mem src_buffer,
19781975 cl_mem dst_buffer,
19791976 const size_t * src_origin,
@@ -1999,6 +1996,10 @@ cl_int CL_API_CALL clCommandCopyBufferRectKHR_EMU(
19991996 {
20001997 return errorCode;
20011998 }
1999+ if ( properties != nullptr && properties[0 ] != 0 )
2000+ {
2001+ return CL_INVALID_PROPERTY;
2002+ }
20022003 if ( mutable_handle != nullptr )
20032004 {
20042005 return CL_INVALID_VALUE;
@@ -2030,6 +2031,7 @@ cl_int CL_API_CALL clCommandCopyBufferRectKHR_EMU(
20302031cl_int CL_API_CALL clCommandCopyBufferToImageKHR_EMU (
20312032 cl_command_buffer_khr cmdbuf,
20322033 cl_command_queue command_queue,
2034+ const cl_command_properties_khr* properties,
20332035 cl_mem src_buffer,
20342036 cl_mem dst_image,
20352037 size_t src_offset,
@@ -2051,6 +2053,10 @@ cl_int CL_API_CALL clCommandCopyBufferToImageKHR_EMU(
20512053 {
20522054 return errorCode;
20532055 }
2056+ if ( properties != nullptr && properties[0 ] != 0 )
2057+ {
2058+ return CL_INVALID_PROPERTY;
2059+ }
20542060 if ( mutable_handle != nullptr )
20552061 {
20562062 return CL_INVALID_VALUE;
@@ -2078,6 +2084,7 @@ cl_int CL_API_CALL clCommandCopyBufferToImageKHR_EMU(
20782084cl_int CL_API_CALL clCommandCopyImageKHR_EMU (
20792085 cl_command_buffer_khr cmdbuf,
20802086 cl_command_queue command_queue,
2087+ const cl_command_properties_khr* properties,
20812088 cl_mem src_image,
20822089 cl_mem dst_image,
20832090 const size_t * src_origin,
@@ -2099,6 +2106,10 @@ cl_int CL_API_CALL clCommandCopyImageKHR_EMU(
20992106 {
21002107 return errorCode;
21012108 }
2109+ if ( properties != nullptr && properties[0 ] != 0 )
2110+ {
2111+ return CL_INVALID_PROPERTY;
2112+ }
21022113 if ( mutable_handle != nullptr )
21032114 {
21042115 return CL_INVALID_VALUE;
@@ -2126,6 +2137,7 @@ cl_int CL_API_CALL clCommandCopyImageKHR_EMU(
21262137cl_int CL_API_CALL clCommandCopyImageToBufferKHR_EMU (
21272138 cl_command_buffer_khr cmdbuf,
21282139 cl_command_queue command_queue,
2140+ const cl_command_properties_khr* properties,
21292141 cl_mem src_image,
21302142 cl_mem dst_buffer,
21312143 const size_t * src_origin,
@@ -2147,6 +2159,10 @@ cl_int CL_API_CALL clCommandCopyImageToBufferKHR_EMU(
21472159 {
21482160 return errorCode;
21492161 }
2162+ if ( properties != nullptr && properties[0 ] != 0 )
2163+ {
2164+ return CL_INVALID_PROPERTY;
2165+ }
21502166 if ( mutable_handle != nullptr )
21512167 {
21522168 return CL_INVALID_VALUE;
@@ -2174,6 +2190,7 @@ cl_int CL_API_CALL clCommandCopyImageToBufferKHR_EMU(
21742190cl_int CL_API_CALL clCommandFillBufferKHR_EMU (
21752191 cl_command_buffer_khr cmdbuf,
21762192 cl_command_queue command_queue,
2193+ const cl_command_properties_khr* properties,
21772194 cl_mem buffer,
21782195 const void * pattern,
21792196 size_t pattern_size,
@@ -2195,6 +2212,10 @@ cl_int CL_API_CALL clCommandFillBufferKHR_EMU(
21952212 {
21962213 return errorCode;
21972214 }
2215+ if ( properties != nullptr && properties[0 ] != 0 )
2216+ {
2217+ return CL_INVALID_PROPERTY;
2218+ }
21982219 if ( mutable_handle != nullptr )
21992220 {
22002221 return CL_INVALID_VALUE;
@@ -2222,6 +2243,7 @@ cl_int CL_API_CALL clCommandFillBufferKHR_EMU(
22222243cl_int CL_API_CALL clCommandFillImageKHR_EMU (
22232244 cl_command_buffer_khr cmdbuf,
22242245 cl_command_queue command_queue,
2246+ const cl_command_properties_khr* properties,
22252247 cl_mem image,
22262248 const void * fill_color,
22272249 const size_t * origin,
@@ -2242,6 +2264,10 @@ cl_int CL_API_CALL clCommandFillImageKHR_EMU(
22422264 {
22432265 return errorCode;
22442266 }
2267+ if ( properties != nullptr && properties[0 ] != 0 )
2268+ {
2269+ return CL_INVALID_PROPERTY;
2270+ }
22452271 if ( mutable_handle != nullptr )
22462272 {
22472273 return CL_INVALID_VALUE;
@@ -2268,6 +2294,7 @@ cl_int CL_API_CALL clCommandFillImageKHR_EMU(
22682294cl_int CL_API_CALL clCommandSVMMemcpyKHR_EMU (
22692295 cl_command_buffer_khr cmdbuf,
22702296 cl_command_queue command_queue,
2297+ const cl_command_properties_khr* properties,
22712298 void * dst_ptr,
22722299 const void * src_ptr,
22732300 size_t size,
@@ -2287,6 +2314,10 @@ cl_int CL_API_CALL clCommandSVMMemcpyKHR_EMU(
22872314 {
22882315 return errorCode;
22892316 }
2317+ if ( properties != nullptr && properties[0 ] != 0 )
2318+ {
2319+ return CL_INVALID_PROPERTY;
2320+ }
22902321 if ( mutable_handle != nullptr )
22912322 {
22922323 return CL_INVALID_VALUE;
@@ -2312,6 +2343,7 @@ cl_int CL_API_CALL clCommandSVMMemcpyKHR_EMU(
23122343cl_int CL_API_CALL clCommandSVMMemFillKHR_EMU (
23132344 cl_command_buffer_khr cmdbuf,
23142345 cl_command_queue command_queue,
2346+ const cl_command_properties_khr* properties,
23152347 void * dst_ptr,
23162348 const void * pattern,
23172349 size_t pattern_size,
@@ -2332,6 +2364,10 @@ cl_int CL_API_CALL clCommandSVMMemFillKHR_EMU(
23322364 {
23332365 return errorCode;
23342366 }
2367+ if ( properties != nullptr && properties[0 ] != 0 )
2368+ {
2369+ return CL_INVALID_PROPERTY;
2370+ }
23352371 if ( mutable_handle != nullptr )
23362372 {
23372373 return CL_INVALID_VALUE;
@@ -2358,7 +2394,7 @@ cl_int CL_API_CALL clCommandSVMMemFillKHR_EMU(
23582394cl_int CL_API_CALL clCommandNDRangeKernelKHR_EMU (
23592395 cl_command_buffer_khr cmdbuf,
23602396 cl_command_queue command_queue,
2361- const cl_ndrange_kernel_command_properties_khr * properties,
2397+ const cl_command_properties_khr * properties,
23622398 cl_kernel kernel,
23632399 cl_uint work_dim,
23642400 const size_t * global_work_offset,
@@ -2464,14 +2500,18 @@ cl_command_buffer_khr CL_API_CALL clRemapCommandBufferKHR_EMU(
24642500// cl_khr_command_buffer_mutable_dispatch
24652501cl_int CL_API_CALL clUpdateMutableCommandsKHR_EMU (
24662502 cl_command_buffer_khr cmdbuf,
2467- const cl_mutable_base_config_khr* mutable_config)
2503+ cl_uint num_configs,
2504+ const cl_command_buffer_update_type_khr* config_types,
2505+ const void ** configs )
24682506{
24692507 if ( !CommandBuffer::isValid (cmdbuf) )
24702508 {
24712509 return CL_INVALID_COMMAND_BUFFER_KHR;
24722510 }
24732511 if ( cl_int errorCode = cmdbuf->mutate (
2474- mutable_config ) )
2512+ num_configs,
2513+ config_types,
2514+ configs ) )
24752515 {
24762516 return errorCode;
24772517 }
0 commit comments