OpenCL™规范 5.1. 命令队列

OpenCL入门(三)——Hello Word 这是OpenCL的第一个程序,所谓的helloword!本程序实现的是向量加法。首先从主要的主机API开始介绍。 1.创建平台结构 2.创建设备结构 3.创建上下文 4.创建程序 5.编译程序 6.创建命令队列 7.创建内核 8创建缓存对象 9.设置内核参数 10.执行内核 11.读取内核结果 阅读详情

5.1. Command-Queues

5.1. 命令队列

OpenCL objects such as memory, program and kernel objects are created using a context. Operations on these objects are performed using a command-queue. The command-queue can be used to queue a set of operations (referred to as commands) in order. Having multiple command-queues allows applications to queue multiple independent commands without requiring synchronization. Note that this should work as long as these objects are not being shared. Sharing of objects across multiple command-queues will require the application to perform appropriate synchronization. This is described in Shared OpenCL Objects

​OpenCL对象(如内存、程序和内核对象)是使用上下文创建的。对这些对象的操作是使用命令队列执行的。命令队列可用于按顺序对一组操作(称为命令)进行排队。具有多个命令队列允许应用程序对多个独立的命令进行排队,而不需要同步。请注意,只要这些对象不被共享,这就应该有效。跨多个命令队列共享对象将要求应用程序执行适当的同步。这在Shared OpenCL Objects中有描述

To create a host or device command-queue on a specific device, call the function

要在特定设备上创建主机或设备命令队列,请调用函数

cl_command_queue clCreateCommandQueueWithProperties(
    cl_context context,
    cl_device_id device,
    const cl_queue_properties* properties,
    cl_int* errcode_ret);

clCreateCommandQueueWithProperties is missing before version 2.0. Also see extension cl_khr_create_command_queue.

版本2.0之前缺少clCreateCommandQueueWithProperties。另请参阅扩展cl_khr_create_command_queue。

  • context must be a valid OpenCL context.

  • 上下文必须是有效的OpenCL上下文。

  • device must be a device or sub-device associated with context. It can either be in the list of devices and sub-devices specified when context is created using clCreateContext or be a root device with the same device type as specified when context is created using clCreateContextFromType.

  • ​设备必须是与上下文关联的设备或子设备。它可以在使用clCreateContext创建上下文时指定的设备和子设备列表中,也可以是与使用clCreateContextFromType创建上下文时相同设备类型的根设备。

  • properties specifies a list of properties for the command-queue and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. The list of supported properties is described in the table below. If a supported property and its value is not specified in properties, its default value will be used. properties can be NULL in which case the default values for supported command-queue properties will be used.

  • ​properties指定命令队列的属性列表及其相应的值。每个属性名称后面紧跟着相应的所需值。列表以0终止。下表中介绍了支持的属性列表。如果未在属性中指定受支持的属性及其值,则将使用其默认值。属性可以为NULL,在这种情况下,将使用支持的命令队列属性的默认值。

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

  • errcode_ret将返回相应的错误代码。如果errcode_ret为NULL,则不会返回任何错误代码。

Table 9. List of supported queue creation properties by clCreateCommandQueueWithProperties

​
表9 clCreateCommandQueueWithProperties支持的队列创建属性列表

Queue Property

队列属性

Property Value

属性值

Description

描述

CL_QUEUE_PROPERTIES

cl_command_queue_properties

This is a bitfield and can be set to a combination of the following values:

这是一个位字段,可以设置为以下值的组合:

CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE - Determines whether the commands queued in the command-queue are executed in-order or out-of-order. If set, the commands in the command-queue are executed out-of-order. Otherwise, commands are executed in-order.

CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE-确定命令队列中排队的命令是有序执行还是无序执行。如果设置,则命令队列中的命令将无序执行。否则,将有序执行命令。

CL_QUEUE_PROFILING_ENABLE - Enable or disable profiling of commands in the command-queue. If set, the profiling of commands is enabled. Otherwise profiling of commands is disabled.

CL_QUEUE_PROFILING_ENABLE-启用或禁用对命令队列中命令的分析。如果设置了,将启用命令的分析。否则,将禁用对命令的分析。

CL_QUEUE_ON_DEVICE - Indicates that this is a device queue. If CL_QUEUE_ON_DEVICE is set, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE [14] must also be set. missing before version 2.0.

CL_QUEUE_ON_DEVICE-表示这是一个设备队列。如果设置了CL_QUEUE_ON_DEVICE,则还必须设置CL_QUEUE _OUT_OF_ORDER_EXEC_MODE_ENABLE[14]。2.0版本之前丢失。

CL_QUEUE_ON_DEVICE_DEFAULT [15] - indicates that this is the default device queue. This can only be used with CL_QUEUE_ON_DEVICE. missing before version 2.0.

CL_QUEUE_ON_DEVICE_DEFAULT[15]-表示这是默认的设备队列。这只能与CL_QUEUE_ON_DEVICE一起使用。2.0版本之前丢失。

If CL_QUEUE_PROPERTIES is not specified an in-order host command-queue is created for the specified device

如果未指定CL_QUEUE_PROPERTIES,则会为指定的设备创建一个有序排列的主机命令队列

CL_QUEUE_SIZE

missing before version 2.0.

cl_uint

Specifies the size of the device queue in bytes.

指定设备队列的大小(以字节为单位)。

This can only be specified if CL_QUEUE_ON_DEVICE is set in CL_QUEUE_PROPERTIES. This must be a value ≤ CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE.

只有在CL_QUEUE_PROPERTIES中设置了CL_QUEUE _ON_DEVICE时,才能指定此选项。该值必须≤CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE。
​

For best performance, this should be ≤ CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE.

为获得最佳性能,此值应≤CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE。
​

If CL_QUEUE_SIZE is not specified, the device queue is created with CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE as the size of the queue.

​如果未指定CL_QUEUE_SIZE,则会使用CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE作为队列大小创建设备队列。

clCreateCommandQueueWithProperties returns a valid non-zero command-queue and errcode_ret is set to CL_SUCCESS if the command-queue is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:

clCreateCommandQueueWithProperties返回有效的非零命令队列,如果命令队列创建成功,则errcode_ret设置为CL_SUCCESS。否则,它将返回一个NULL值,并在errcode_ret中返回以下错误值之一:

  • CL_INVALID_CONTEXT if context is not a valid context.

  • CL_INVALID_CONTEXT(如果上下文不是有效上下文)。

  • CL_INVALID_DEVICE if device is not a valid device or is not associated with context.

  • CL_INVALID_DEVICE(如果设备不是有效设备或与上下文无关)。

  • CL_INVALID_VALUE if values specified in properties are not valid.

  • CL_INVALID_VALUE(如果属性中指定的值无效)。

  • CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not supported by the device.

  • CL_INVALID_QUEUE_PROPERTIES(如果属性中指定的值有效但设备不支持)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To create a host command-queue on a specific device, call the function

要在特定设备上创建主机命令队列,请调用函数

cl_command_queue clCreateCommandQueue(
    cl_context context,
    cl_device_id device,
    cl_command_queue_properties properties,
    cl_int* errcode_ret);

clCreateCommandQueue is deprecated by version 2.0.

clCreateCommandQueue已被2.0版本否决。

  • context must be a valid OpenCL context.

  • 上下文必须是有效的OpenCL上下文。

  • device must be a device or sub-device associated with context. It can either be in the list of devices and sub-devices specified when context is created using clCreateContext or be a root device with the same device type as specified when context is created using clCreateContextFromType.

  • 设备必须是与上下文关联的设备或子设备。它可以在使用clCreateContext创建上下文时指定的设备和子设备列表中,也可以是与使用clCreateContextFromType创建上下文时相同设备类型的根设备。

  • properties specifies a list of properties for the command-queue. This is a bit-field and the supported properties are described in the table below. Only command-queue properties specified in this table can be used, otherwise the value specified in properties is considered to be not valid. properties can be 0 in which case the default values for supported command-queue properties will be used.

  • ​properties指定命令队列的属性列表。这是一个位字段,支持的属性在下表中进行了描述。只能使用此表中指定的命令队列属性,否则属性中指定的值将被视为无效。属性可以是0,在这种情况下,将使用支持的命令队列属性的默认值。

Table 10. List of supported cl_command_queue_property values by clCreateCommandQueue

​表10 clCreateCommandQueue支持的cl_command_queue_property值的列表

Command-Queue Properties

命令队列属性

Description

描述

CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE

Determines whether the commands queued in the command-queue are executed in-order or out-of-order. If set, the commands in the command-queue are executed out-of-order. Otherwise, commands are executed in-order.

确定命令队列中排队的命令是有序执行还是无序执行。如果设置,则命令队列中的命令将无序执行。否则,将有序执行命令。

CL_QUEUE_PROFILING_ENABLE

Enable or disable profiling of commands in the command-queue. If set, the profiling of commands is enabled. Otherwise profiling of commands is disabled.

启用或禁用对命令队列中的命令的分析。如果设置了,将启用命令的分析。否则,将禁用对命令的分析。

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

  • errcode_ret将返回相应的错误代码。如果errcode_ret为NULL,则不会返回任何错误代码。

clCreateCommandQueue returns a valid non-zero command-queue and errcode_ret is set to CL_SUCCESS if the command-queue is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:

clCreateCommandQueue返回有效的非零命令队列,如果命令队列创建成功,则errcode_ret设置为CL_SUCCESS。否则,它将返回一个NULL值,并在errcode_ret中返回以下错误值之一:

  • CL_INVALID_CONTEXT if context is not a valid context.

  • CL_INVALID_CONTEXT(如果上下文不是有效上下文)。

  • CL_INVALID_DEVICE if device is not a valid device or is not associated with context.

  • CL_INVALID_DEVICE(如果设备不是有效设备或与上下文无关)。

  • CL_INVALID_VALUE if values specified in properties are not valid.

  • CL_INVALID_VALUE(如果属性中指定的值无效)。

  • CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not supported by the device.

  • CL_INVALID_QUEUE_PROPERTIES(如果属性中指定的值有效但设备不支持)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To replace the default command-queue on a device, call the function

要替换设备上的默认命令队列,请调用函数

cl_int clSetDefaultDeviceCommandQueue(
    cl_context context,
    cl_device_id device,
    cl_command_queue command_queue);

clSetDefaultDeviceCommandQueue is missing before version 2.1.

版本2.1之前缺少clSetDefaultDeviceCommandQueue。

  • context is the OpenCL context used to create command_queue.

  • context是用于创建command_queue的OpenCL上下文。

  • device is a valid OpenCL device associated with context.

  • 设备是与上下文相关联的有效OpenCL设备。

  • command_queue specifies a command-queue object which replaces the default device command-queue

  • command_queue指定替换默认设备命令队列的命令队列对象

clSetDefaultDeviceCommandQueue may be used to replace a default device command-queue created with clCreateCommandQueueWithProperties and the CL_QUEUE_ON_DEVICE_DEFAULT flag.

clSetDefaultDeviceCommandQueue可用于替换使用clCreateCommandQueueWithProperties和CL_QUEUE_ON_DEVICE_DEFAULT标志创建的默认设备命令队列。

clSetDefaultDeviceCommandQueue returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clSetDefaultDeviceCommandQueue将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_CONTEXT if context is not a valid context.

  • CL_INVALID_CONTEXT(如果上下文不是有效上下文)。

  • CL_INVALID_DEVICE if device is not a valid device or is not associated with context.

  • CL_INVALID_DEVICE(如果设备不是有效设备或与上下文无关)。

  • CL_INVALID_OPERATION if device does not support a replaceable default on-device queue.

  • CL_INVALID_OPERATION(如果设备不支持设备队列上的可替换默认值)。

  • CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue for device.

  • CL_INVALID_COMMAND_QUEUE(如果命令队列不是设备的有效命令队列)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To retain a command-queue, call the function

要保留命令队列,请调用函数

cl_int clRetainCommandQueue(
    cl_command_queue command_queue);
  • command_queue specifies the command-queue to be retained.

  • command_queue指定要保留的命令队列。

The command_queue reference count is incremented.

command_queue引用计数递增。

clCreateCommandQueueWithProperties and clCreateCommandQueue perform an implicit retain. This is very helpful for 3rd party libraries, which typically get a command-queue passed to them by the application. However, it is possible that the application may delete the command-queue without informing the library. Allowing functions to attach to (i.e. retain) and release a command-queue solves the problem of a command-queue being used by a library no longer being valid.

clCreateCommandQueueWithProperties和clCreateCommandQueue执行隐式保留。这对第三方库非常有帮助,因为第三方程序库通常会获得应用程序传递给它们的命令队列。但是,应用程序可能会在不通知库的情况下删除命令队列。允许函数附加(即保留)和释放命令队列解决了库使用的命令队列不再有效的问题。

clRetainCommandQueue returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clRetainCommandQueue将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.

  • CL_INVALID_COMMAND_QUEUE(如果命令队列不是有效的命令队列)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To release a command-queue, call the function

要释放命令队列,请调用函数

cl_int clReleaseCommandQueue(
    cl_command_queue command_queue);
  • command_queue specifies the command-queue to be released.

  • command_queue指定要释放的命令队列。

The command_queue reference count is decremented.

command_queue引用计数递减。

After the command_queue reference count becomes zero and all commands queued to command_queue have finished (eg. kernel-instances, memory object updates etc.), the command-queue is deleted.

在command_queue引用计数变为零并且排队到command_queue的所有命令都已完成(例如内核实例、内存对象更新等)后,命令队列将被删除。

clReleaseCommandQueue performs an implicit flush to issue any previously queued OpenCL commands in command_queue. Using this function to release a reference that was not obtained by creating the object or by calling clRetainCommandQueue causes undefined behavior.

clReleaseCommandQueue执行隐式刷新,以发出command_queue中任何先前排队的OpenCL命令。使用此函数释放不是通过创建对象或调用clRetainCommandQueue获得的引用会导致未定义的行为。

clReleaseCommandQueue returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clReleaseCommandQueue将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.

  • CL_INVALID_COMMAND_QUEUE(如果命令队列不是有效的命令队列)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To query information about a command-queue, call the function

要查询有关命令队列的信息,请调用函数

cl_int clGetCommandQueueInfo(
    cl_command_queue command_queue,
    cl_command_queue_info param_name,
    size_t param_value_size,
    void* param_value,
    size_t* param_value_size_ret);
  • command_queue specifies the command-queue being queried.

  • command_queue指定要查询的命令队列。

  • param_name specifies the information to query.

  • param_name指定要查询的信息。

  • param_value is a pointer to memory where the appropriate result being queried is returned. If param_value is NULL, it is ignored.

  • param_value是一个指向内存的指针,在内存中返回所查询的适当结果。如果param_value为NULL,则忽略它。

  • param_value_size is used to specify the size in bytes of memory pointed to by param_value. This size must be ≥ size of return type as described in the Command-Queue Parameter table. If param_value is NULL, it is ignored.

  • ​param_value_size用于指定param_value指向的内存大小(以字节为单位)。此大小必须≥命令队列参数表中所述的返回类型的大小。如果param_value为NULL,则忽略它。

  • param_value_size_ret returns the actual size in bytes of data being queried by param_name. If param_value_size_ret is NULL, it is ignored.

  • param_value_size_ret返回param_name查询的数据的实际大小(以字节为单位)。如果param_value_size_ret为NULL,则忽略它。

The list of supported param_name values and the information returned in param_value by clGetCommandQueueInfo is described in the Command-Queue Parameter table.

​命令队列参数表中介绍了支持的param_name值列表以及clGetCommandQueueInfo在param_value中返回的信息。

Table 11. List of supported param_names by clGetCommandQueueInfo

​表11 clGetCommandQueueInfo支持的参数名称列表

Queue Info

队列信息

Return Type

返回类型

Description

描述

CL_QUEUE_CONTEXT

cl_context

Return the context specified when the command-queue is created.

返回创建命令队列时指定的上下文。

CL_QUEUE_DEVICE

cl_device_id

Return the device specified when the command-queue is created.

返回创建命令队列时指定的设备。

CL_QUEUE_REFERENCE_COUNT [16]

cl_uint

Return the command-queue reference count.

返回命令队列引用计数。

CL_QUEUE_PROPERTIES

cl_command_queue_properties

Return the currently specified properties for the command-queue. These properties are specified by the value associated with the CL_QUEUE_PROPERTIES passed in properties argument in clCreateCommandQueueWithProperties, or the value of the properties argument in clCreateCommandQueue.

​
返回命令队列的当前指定属性。这些属性由clCreateCommandQueueWithProperties中传递的属性参数中与CL_QUEUE_PROPERTIES相关联的值或clCreateCommandQueue中属性参数的值指定。

CL_QUEUE_PROPERTIES_ARRAY

missing before version 3.0.

cl_queue_properties[]

Return the properties argument specified in clCreateCommandQueueWithProperties.

返回clCreateCommandQueueWithProperties中指定的属性参数。
​

If the properties argument specified in clCreateCommandQueueWithProperties used to create command_queue was not NULL, the implementation must return the values specified in the properties argument in the same order and without including additional properties.

如果用于创建command_queue的clCreateCommandQueueWithProperties中指定的属性参数不为NULL,则实现必须以相同的顺序返回属性参数中指定的值,并且不包括其他属性。
​

If command_queue was created using clCreateCommandQueue, or if the properties argument specified in clCreateCommandQueueWithProperties was NULL, the implementation must return param_value_size_ret equal to 0, indicating that there are no properties to be returned.

​如果command_queue是使用clCreateCommandQueue创建的,或者如果clCreateCommandQueueWithProperties中指定的属性参数为NULL,则该实现必须返回等于0的param_value_size_ret,这表示没有要返回的属性。

CL_QUEUE_SIZE

missing before version 2.0.

cl_uint

Return the size of the device command-queue. To be considered valid for this query, command_queue must be a device command-queue.

返回设备命令队列的大小。若要对此查询有效,command_queue必须是设备命令队列。

CL_QUEUE_DEVICE_DEFAULT

missing before version 2.1.

cl_command_queue

Return the current default command-queue for the underlying device.

返回基础设备的当前默认命令队列。

clGetCommandQueueInfo returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clGetCommandQueueInfo将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue, or if command_queue is not a valid command-queue for param_name.

  • 如果命令队列不是有效的命令队列,或者命令队列不是param_name的有效命令队列,则CL_INVALID_COMMAND_QUEUE。

  • CL_INVALID_VALUE if param_name is not one of the supported values or if size in bytes specified by param_value_size is < size of return type as specified in the Command-Queue Parameter table, and param_value is not a NULL value.

  • 如果param_name不是支持的值之一,或者param_value_size指定的字节大小小于命令队列参数表中指定的返回类型的大小,并且param_value不是NULL值,则CL_INVALID_VALUE。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

To enable or disable the properties of a command-queue, call the function

要启用或禁用命令队列的属性,请调用函数

cl_int clSetCommandQueueProperty(
    cl_command_queue command_queue,
    cl_command_queue_properties properties,
    cl_bool enable,
    cl_command_queue_properties* old_properties);

clSetCommandQueueProperty is deprecated by version 1.1.

clSetCommandQueueProperty已被版本1.1废弃。

  • command_queue specifies the command-queue being modified.

  • command_queue指定要修改的命令队列。

  • properties specifies the new list of properties for the command-queue. This is a bit-field and the supported properties are described in the Command-Queue Properties table for clCreateCommandQueue. Only command-queue properties specified in this table can be used, otherwise the value specified in properties is considered to be not valid.

  • ​properties指定命令队列的新属性列表。这是一个位字段,clCreateCommandQueue的命令队列属性表中描述了支持的属性。只能使用此表中指定的命令队列属性,否则属性中指定的值将被视为无效。

  • enable determines whether the values specified by properties are enabled (if enable is CL_TRUE) or disabled (if enable is CL_FALSE) for the command-queue.

  • ​enable确定命令队列的属性指定的值是启用的(如果enable为CL_TRUE)还是禁用的(如果enable为CL_FALSE)。

  • old_properties returns the command-queue properties before they were changed by clSetCommandQueueProperty. If old_properties is NULL, it is ignored.

  • ​old_properties返回clSetCommandQueueProperty更改命令队列属性之前的命令队列属性。如果old_properties为NULL,则会忽略它。

clSetCommandQueueProperty may unconditionally return an error if no devices in the context associated with command_queue support modifying the properties of a command-queue. Support for modifying the properties of a command-queue is required only for OpenCL 1.0 devices.

如果与command_queue关联的上下文中没有设备支持修改命令队列的属性,则clSetCommandQueueProperty可能无条件返回错误。只有OpenCL 1.0设备才需要支持修改命令队列的属性。

clSetCommandQueueProperty returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clSetCommandQueueProperty将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.

  • CL_INVALID_COMMAND_QUEUE(如果命令队列不是有效的命令队列)。

  • CL_INVALID_OPERATION if no devices in the context associated with command_queue support modifying the properties of a command-queue.

  • CL_INVALID_OPERATION如果与command_queue关联的上下文中没有设备支持修改命令队列的属性。

  • CL_INVALID_VALUE if values specified in properties are not valid.

  • CL_INVALID_VALUE(如果属性中指定的值无效)。

  • CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not supported by the device.

  • CL_INVALID_QUEUE_PROPERTIES(如果属性中指定的值有效但设备不支持)。

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

性能优化-OpenCL运行时API介绍 本文首先给出 OpenCL 运行时 API 的整体编程流程图,然后针对每一步介绍使用的运行时 API,讲解 API 参数,并给出编程运行实例。总结运行时 API 使用的注意事项。最后展示基于 OpenCL 的图像转置代码。在 865 平台下,对于 4096x4096 的 8 位图像加速比达到 10 倍以上。 阅读详情

相关推荐

从零开始搭建属于自己的语音识别API服务器(ASRT开源项目)

材料准备 云服务器 (本人使用的的是阿里云服务器 Ubuntu(Linux操作系统)) 环境搭建 1. Python 3.7 话不多说直接上代码 sudo su yum -y install git yum -y install gcc yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-deve

zhi_qian的博客 5651

OPENCL2.0错题集(别再被声明为否决了)

OPENCL2.0错题集(别再被声明为否决了)前情概要clCreateCommandQueue指令clCreateImage2D指令fopen()函数 --> fopen_s()函数 (打开Kernel文件用)参考链接 前情概要 AMD APP SDK 3.0 支持K社的opencl 1.x和2.0标准,目前大部分A卡都支持OPENCL 2.0 。单弃用了OPENCL1.2中的许多指令集,针...

tech_otaku0512的博客 1642

西门子S7-1200的PID应用(恒温热水器)

物料清单:1200PLC一台,模拟量输入模块SM1231(PLC自带的输入通道不支持4-20mA电流输入)一个,PT100一个,温度变送器,热得快,固态继电器。 第一步,硬件接线; 第二步,新建1200工程,添加PLC和模拟量输入模块,修改模块的模拟量输入类型为4-20mA,模拟量模块的IO地址为96-103(8个字); 第三步,新建循环组织块OB30,循环时间选择默认点1...

weixin_30835649的博客 6557

OpenCL编程步骤(二):创建命令队列

1、创建命令队列 OpenCL对象,比如内存对象,程序对象和内核对象都是用上下文创建的。对这些对象的操控都是通过命令队列来实现的。用命令队列可以把一系列操作按序排队。如果有多个命令队列,应用可以将多个相互独立的命令分别排队而无须同步。然而这仅在没有共享任何对象时才成立。如果要在多个命令队列间共享对象,就要求应用事实相应的同步。 cl_command_queue clCreateComm

Ven_J的博客 6307

Unity中实现FairyGUI弹窗背景模糊的3种方法对比(附完整代码)

本文详细对比了Unity中实现FairyGUI弹窗背景模糊的3种方法,包括FairyGUI原生滤镜方案、多摄像机混合渲染方案和渲染纹理动态混合方案。每种方法均附有完整代码示例,帮助开发者根据项目需求选择最佳方案,实现镜头虚化模糊效果,提升游戏UI的视觉沉浸感。

ff678的博客 234

kali破解wifi之airmon-ng 工具利用

......

qq_42378173的博客 1万+

Windows Opencl clCreateCommandQueue()函数

Windows Opencl clCreateCommandQueue()函数详细解析 OpenCL对象(如内存、程序和内核对象)是使用上下文创建的。对这些对象的操作是使用命令队列执行的。命令队列可用于按顺序对一组操作(称为命令)进行排队。拥有多个命令队列允许应用程序将多个独立命令排队,而不需要同步。请注意,只要这些对象没有被共享,这个方法就应该有效。跨多个命令队列共享对象需要应用程序执行适当的同步。 函数原型 cl_command_queue clCreateCommandQueue(cl_context

qq_42877866的博客 1578

KNX智能家居工程设计应用

KNX,是一个起源于欧洲的总线标准,主要应用于家居和楼宇中,对末端电气设备进行总线式的控制,比如照明、空调、地暖、电动窗帘和遮阳设备等等。根据2017年英国著名咨询公司BSRIA的数据报告显示,在中国的智能家居和灯光控制市场,KNX产品的市场份额为各类产品中排名第一,占据了42%的市场份额,远远领先于其他的标准协议。设备中一个继电器表示一路输出,某些功能可能需要用到多个输出,比如1个窗帘AC输出需要占用两路继电器输出,一个继电器用于控制正转,一个用于控制反转,而普通开关输出则需要占用一路继电器输出即可。

hhhh5555666的博客 937

OpenCL™规范官方指南文档目录

OpenCL™规范-CSDN博客

aggs1990的专栏 1668

Unity分包下载实战:AssetBundle+CDN+热更新全链路指南

分包下载是移动应用资源管理的核心技术,本质是将大体积安装包拆解为按需加载的独立资源单元,以解决用户安装意愿低、首屏启动慢、热更新不可控等关键问题。其底层依赖资源打包机制(如Unity AssetBundle)、全球分发网络(CDN)与安全热更新策略三者协同。AssetBundle提供资源隔离与依赖管理能力,CDN保障低延迟高可用下载,而热更新策略则决定版本控制、灰度发布与异常恢复的工程鲁棒性。该方案广泛应用于中重度游戏、大型工具类App及需要频繁内容迭代的商业项目,直接提升次日留存、过审成功率与用户在线时长

weixin_29762151的博客 364

人工智能智能体研究综述:从理论架构到前沿应用

AI Agent,即人工智能智能体,是指能够在特定环境中自主感知、推理、决策并执行行动以实现特定目标的智能系统[1]。自主性反应性主动性(Pro-activeness)和社会性fill:#333;important;important;fill:none;color:#333;color:#333;important;fill:none;fill:#333;height:1em;AI Agent核心特征自主性 Autonomy反应性 Reactivity主动性 Pro-activeness。

nmdbbzcl的博客 909

OpenCL™规范 5.17. 命令缓冲区

命令缓冲区是使用命令队列的有序列表创建的,默认情况下,命令会记录到这些队列中并在其上执行。这些命令队列可以在命令缓冲区排队时用不同的命令队列替换,前提是替换列表中的每个元素的替换命令队列与创建命令缓冲区时使用的命令队列兼容。兼容的命令队列被定义为在相同的OpenCL上下文中,针对同一设备具有相同属性的命令队列。命令缓冲区对象应增加附加OpenCL对象的引用计数,如记录到命令缓冲区的命令中引用的队列、缓冲区、图像和内核。命令缓冲区对象不会更新记录在命令缓冲区中的内核上设置为参数的对象的引用计数。

aggs1990的专栏 161

Android 系统状态栏中实现高斯模糊背景

至此,我们已经完成了在 Android 系统的 SystemUI 中实现高斯模糊背景的过程。通过以上的布局和代码修改,我们可以在状态栏中看到具有高斯模糊效果的背景。同时,为了在不同版本的 Android 系统上适配高斯模糊效果,可能需要进行一些额外的代码调整和兼容性处理。希望本文能够帮助你理解如何在 Android 系统的 SystemUI 中实现高斯模糊背景,并通过提供的源代码进行相应的开发和调试。首先,我们需要在 SystemUI 的布局文件中添加一个用于展示高斯模糊背景的视图。属性来开启模糊效果。

CyberSparkZ的博客 873

OpenCL™规范 5.17.1. 命令缓冲区和多个设备

​如果支持cl_khr_command_buffer_multi_device扩展,如果供应商提供设备间cl_sync_point_khr同步支持,则命令缓冲区可以包含记录到不同设备队列的命令。此功能通过CL_DEVICE_COMMAND_BUFFER_SYNC_DEVICES_KHR报告,该功能通知用户哪些设备可以在设备侧本地相互同步,或者通过CL_COMMAND_BUFFER_PLATFORM_UNIVERSAL_SYNC_KHR报告。但是,使用此功能,所有队列命令都必须记录为针对同一设备。

aggs1990的专栏 154

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

OpenCL™规范 5.17.5. 将命令记录到命令缓冲区

如果sync_point_wait_list不为NULL,则sync_point_wait_list指向的同步点列表必须有效,num_sync_points_in_wait_list必须大于0。与sync_point_wait_list中的同步点关联的命令缓冲区必须与command_buffer相同。如果sync_point_wait_list不为NULL,则sync_point_wait_list指向的同步点列表必须有效,num_sync_points_in_wait_list必须大于0。

aggs1990的专栏 236

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

OpenCL™规范 3.3.7.5. 主机端和设备端命令

7.如果主机API调用将命令队列屏障命令C与C应该等待的事件的空列表一起排队,则在命令队列全局同步-与C一起的C之前排队的所有命令的事件。当使用来自从主机排队的不同内核实例的原子操作时,访问单个cl_mem对象中的共享位置或不相交位置,使得原子操作中的一个或多个是写入实现定义的,并且除了在同步点之外,不能保证正确的行为。当使用来自由父内核和该内核排队的任何数量的子内核组成的不同内核实例的原子操作时,根据本节前面描述的内存排序规则,可以保证对单个cl_mem对象中的共享位置或不相交位置的访问。

aggs1990的专栏 265

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

部署到 Adreno™ GPU

​Adreno™ 是由高通开发并用于许多 SoC 的图形处理单元(GPU)半导体 IP 核系列。Adreno™ GPU 可以加速复杂几何图形的渲染,在提供高性能图形和丰富的用户体验的同时拥有很低的功耗。TVM 使用 TVM 的原生 OpenCL 后端 和 OpenCLML 后端以支持加速 Adreno™ GPU 上的深度学习。TVM 的原生 OpenCL 后端通过结合纹理内存使用和 Adreno™ 友好布局来改进 Adreno™。

HyperAI超神经 1355

OpenCL™规范 5.17.4. 命令缓冲区排队

如果command_buffer不是使用CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR标志创建的,并且处于挂起状态,则为CL_INVALID_OPERATION。如果event_wait_list为NULL,则。如果与command_buffer关联的上下文和event_wait_list中的事件不相同,则返回CL_INVALID_CONTEXT。CL_OUT_OF_RESOURCES,如果由于执行command_buffer所需的资源不足,导致无法在命令队列上对。

aggs1990的专栏 178

OpenCL™规范 5.15. 内存对象和内核的分析操作

如果支持cl_khr_command_buffer_multi_device扩展,并且如果没有可靠的设备计时器源可用于通知主机端,或者并行运行时调度使得无法识别第一个/最后一个命令,则实现可能会分别为CL_PROFILING_COMMAND_START和CL_PROFILING_COMMAND_END报告CL_PROFILING_COMMAND_SUBMIT和CL_PROFILING_COMMAND_COMPLETE。是用户事件对象,则CL_PROFILING_INFO_NOT_AVAILABLE。

aggs1990的专栏 200

OpenCL™规范 5.11. 事件对象

如果命令的执行终止,则与此终止命令关联的命令队列和关联的上下文(以及此上下文中的所有其他命令队列)可能不再可用。使用此上下文(以及与此上下文关联的命令队列)的OpenCL API调用的行为现在被认为是实现定义的。为了使排队命令的执行状态从CL_SUBMITTED更改为CL_RUNNING,此命令正在等待的所有事件必须已成功完成,即它们的执行状态必须为CL_COMPLETE。将命令排入命令队列的API调用将创建一个新的。​如果命令的执行状态为CL_COMPLETE或为负整数值,则认为该命令已完成。

aggs1990的专栏 188

OpenCL™规范 5.14. 内核和内存对象命令的无序执行

​应用程序可以通过设置命令队列的CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE属性,将排队到命令队列的命令配置为无序执行。这可以在创建命令队列时指定。​同样,在clEnqueueNDRangeKernel、clEnqueueTask或clEnqueue NativeKernel命令之后排队的读取、写入、复制或映射内存对象的命令不能保证等待计划执行的内核完成(如果设置了CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE属性)。

aggs1990的专栏 231

OpenCL™规范 5.10. 执行内核

如果event_wait_list为NULL,则num_events_in_wait_lit必须为0。如果event_wait_list不为NULL,则event_wait-list指向的事件列表必须有效,num_events_in_wait_lister必须大于0。如果子缓冲区对象被指定为作为缓冲区对象的参数的值,并且创建子缓冲区时指定的偏移量与与队列关联的设备的CL_DEVICE_MEM_BASE_ADDR_ALIGN值不一致,则为CL_MISALIGNED_SUB_BFER_OFFSET。

aggs1990的专栏 296

OpenCL™规范 5.16. 冲洗并完成

​command_queue中所有先前排队的OpenCL命令都会发送到与command_queue关联的设备。​要将引用命令队列中排队的命令的事件对象用作其他命令队列中的命令等待的事件对象,应用程序必须调用clFlush或任何执行命令队列隐式冲洗的阻塞命令,其中引用这些事件对象的命令被排队。CL_OUT_OF_HOST_MEMORY,如果无法在主机上分配OpenCL实现所需的资源。CL_OUT_OF_HOST_MEMORY,如果无法在主机上分配OpenCL实现所需的资源。不是有效的主机命令队列)。

aggs1990的专栏 180

OpenCL™规范 5.2.3. 填充缓冲区对象

event_wait_list和num_events_in_wait_list指定在执行此特定命令之前需要完成的事件。如果event_wait_list不为NULL,则event_wail_list指向的事件列表必须有效,并且num_events_in_wait_list必须大于0。CL_MISALIGNED_SUB_BUFFER_OFFSET,如果缓冲区是子缓冲区对象,并且创建子缓冲区时指定的偏移量未与与队列关联的设备的CL_DEVICE_MEM_BASE_ADDR_ALIGN值对齐。

aggs1990的专栏 317

OpenCL™规范 5.OpenCL运行时

在本节中,我们将描述API调用,这些调用管理OpenCL对象,如命令队列、内存对象、程序对象、程序中内核函数的内核对象,以及允许将命令排入命令队列的调用,如执行内核、读写内存对象。

aggs1990的专栏 213

OpenCL™规范 5.17.6. 重新映射命令缓冲区

​如果支持cl_khr_command_buffer_multi_device扩展,则报告CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR功能的平台支持生成命令缓冲区的深度副本,其命令重新映射到可能与创建命令缓冲区所用的队列不兼容的命令队列列表中。​除了此功能外,报告CL_COMMAND_BUFFER_PLATFORM_AUTOMATIC_REMAP_KHR的平台允许用户创建一个重新映射的命令缓冲区,其中队列到命令的映射由OpenCL运行时以其确定为最佳的方式确定。

aggs1990的专栏 209
上一篇: OpenCL™规范 5.OpenCL运行时
下一篇: OpenCL™规范 5.2. 缓冲区对象
꧁白杨树下꧂
博客等级 码龄15年 1019粉丝 209原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值