OpenCL™规范 5.9.2. 设置内核参数

在LinuxMint 22.1(Ubuntu24.04)上安装使用同花顺远航版 Linux用户成功在LinuxMint22.1系统上通过Wine9.0运行同花顺远航版,解决了长期困扰的股票行情软件问题。此前Linux原生版同花顺功能简陋且停止更新,Wine版通达信存在显示问题。作者作为自由软件支持者,通过调整Wine配置文件解决了高分屏显示异常问题,实现了远航版的正常使用。期待同花顺能重启Linux原生版开发,支持更多处理器架构,完善国产软件生态。该方案为Linux股票软件用户提供了实用参考。 阅读详情
5.9.2. Setting Kernel Arguments
5.9.2. 设置内核参数

To execute a kernel, the kernel arguments must be set.

要执行内核,必须设置内核参数。

To set the argument value for a specific argument of a kernel, call the function

要为内核的特定参数设置参数值,请调用以下函数

// Provided by CL_VERSION_1_0
cl_int clSetKernelArg(
    cl_kernel kernel,
    cl_uint arg_index,
    size_t arg_size,
    const void* arg_value);
  • kernel is a valid kernel object.

  • kernel是一个有效的内核对象。

  • arg_index is the argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel (see below).

  • arg_index是参数索引。指向内核的参数由从最左侧参数的0到n-1的索引引用,其中n是内核声明的参数总数(见下文)。

  • arg_size specifies the size of the argument value. If the argument is a memory object, the arg_size value must be equal to sizeof(cl_mem). For arguments declared with the local qualifier, the size specified will be the size in bytes of the buffer that must be allocated for the local argument. If the argument is of type sampler_t, the arg_size value must be equal to sizeof(cl_sampler). If the argument is of type queue_t, the arg_size value must be equal to sizeof(cl_command_queue). For all other arguments, the size will be the size of argument type.

  • arg_size指定参数值的大小。如果参数是内存对象,则arg_size值必须等于sizeof(cl_mem)。对于使用本地限定符声明的参数,指定的大小将是必须为本地参数分配的缓冲区的字节大小。如果参数的类型为sampler_t,则arg_size值必须等于sizeof(cl_sampler)。如果参数的类型为queue_t,则arg_size值必须等于sizeof(cl_command_queue)。对于所有其他参数,大小将是参数类型的大小。

  • arg_value is a pointer to data that should be used as the argument value for argument specified by arg_index. The argument data pointed to by arg_value is copied and the arg_value pointer can therefore be reused by the application after clSetKernelArg returns. The argument value specified is the value used by all API calls that enqueue kernel (clEnqueueNDRangeKernel and clEnqueueTask) until the argument value is changed by a call to clSetKernelArg for kernel.

  • ​arg_value是指向数据的指针,该数据应用作arg_index指定的参数的参数值。arg_value指向的参数数据被复制,因此在clSetKernelArg返回后,arg_value指针可以被应用程序重用。指定的参数值是使内核入队的所有API调用(clEnqueueNDRangeKernel和clEnqueueTask)使用的值,直到内核的clSetKernelArg调用更改了参数值为止。

For example, consider the following kernel:

例如,考虑以下内核:

kernel void image_filter (int n,
                          int m,
                          constant float *filter_weights,
                          read_only image2d_t src_image,
                          write_only image2d_t dst_image)
{
...
}

Argument index values for image_filter will be 0 for n, 1 for m, 2 for filter_weights, 3 for src_image and 4 for dst_image.

image_filter的参数索引值对于n将为0,对于m将为1,对于filter_weights将为2,对于src_image将为3,对于dst_image为4。

If the argument is a memory object (buffer, pipe, image or image array), the arg_value entry will be a pointer to the appropriate buffer, pipe, image or image array object. The memory object must be created with the context associated with the kernel object. If the argument is a buffer object, the arg_value pointer can be NULL or point to a NULL value in which case a NULL value will be used as the value for the argument declared as a pointer to global or constant memory in the kernel. If the argument is declared with the local qualifier, the arg_value entry must be NULL. If the argument is of type sampler_t, the arg_value entry must be a pointer to the sampler object. If the argument is of type queue_t, the arg_value entry must be a pointer to the device queue object.

如果参数是内存对象(缓冲区、管道、图像或图像数组),则arg_value条目将是指向相应缓冲区、管道、图像或图片数组对象的指针。必须使用与内核对象关联的上下文创建内存对象。如果参数是缓冲区对象,则arg_value指针可以为NULL或指向NULL值,在这种情况下,NULL值将用作声明为指向内核中global或constant内存的指针的参数的值。如果使用local限定符声明参数,则arg_value条目必须为NULL。如果参数的类型为sampler_t,则arg_value条目必须是指向采样器对象的指针。如果参数的类型为queue_t,则arg_value条目必须是指向设备队列对象的指针。

If the cl_khr_gl_msaa_sharing extension is supported, then: If the argument is a multi-sample 2D image, the arg_value entry must be a pointer to a multi-sample image object. If the argument is a multi-sample 2D depth image, the arg_value entry must be a pointer to a multisample depth image object. If the argument is a multi-sample 2D image array, the arg_value entry must be a pointer to a multi-sample image array object. If the argument is a multi-sample 2D depth image array, the arg_value entry must be a pointer to a multi-sample depth image array object.

​如果支持cl_khr_gl_msaa_sharing扩展,则:如果参数是多样本2D图像,则arg_value条目必须是指向多样本图像对象的指针。如果参数是多采样2D深度图像,则arg_value条目必须是指向多采样深度图像对象的指针。如果参数是多样本二维图像数组,则arg_value条目必须是指向多样本图像数组对象的指针。如果参数是多样本2D深度图像数组,则arg_value条目必须是指向多样本深度图像数组对象的指针。

If the argument is declared to be a pointer of a built-in scalar or vector type, or a user defined structure type in the global or constant address space, the memory object specified as argument value must be a buffer object (or NULL). If the argument is declared with the constant qualifier, the size in bytes of the memory object cannot exceed CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE and the number of arguments declared as pointers to constant memory cannot exceed CL_DEVICE_MAX_CONSTANT_ARGS.

​如果参数被声明为内置标量或向量类型的指针,或者全局或常量地址空间中的用户定义结构类型,则指定为参数值的内存对象必须是缓冲区对象(或NULL)。如果参数是用constant限定符声明的,则内存对象的大小(以字节为单位)不能超过CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,并且声明为指向CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE内存的指针的参数数量不能超过CL_DEVICE_MAX_CONSTANT_ARGS。

The memory object specified as argument value must be a pipe object if the argument is declared with the pipe qualifier.

如果参数是用pipe限定符声明的,则指定为参数值的内存对象必须是管道对象。

The memory object specified as argument value must be a 2D image object if the argument is declared to be of type image2d_t. The memory object specified as argument value must be a 2D image object with image channel order = CL_DEPTH if the argument is declared to be of type image2d_depth_t. The memory object specified as argument value must be a 3D image object if argument is declared to be of type image3d_t. The memory object specified as argument value must be a 1D image object if the argument is declared to be of type image1d_t. The memory object specified as argument value must be a 1D image buffer object if the argument is declared to be of type image1d_buffer_t. The memory object specified as argument value must be a 1D image array object if argument is declared to be of type image1d_array_t. The memory object specified as argument value must be a 2D image array object if argument is declared to be of type image2d_array_t. The memory object specified as argument value must be a 2D image array object with image channel order = CL_DEPTH if argument is declared to be of type image2d_array_depth_t.

​如果参数声明为image2d_t类型,则指定为参数值的内存对象必须是2D图像对象。​如果参数声明为image2d_depth_t类型,则指定为参数值的内存对象必须是图像通道顺序为CL_DEPTH的2D图像对象。如果参数声明为image3d_t类型,则指定为参数值的内存对象必须是3D图像对象。如果参数声明为image1d_t类型,则指定为参数值的内存对象必须是1D图像对象。如果参数声明为image1d_buffer_t类型,则指定为参数值的内存对象必须是1D图像缓冲区对象。如果参数声明为image1d_array_t类型,则指定为参数值的内存对象必须是1D图像数组对象。如果参数声明为image2d_array_t类型,则指定为参数值的内存对象必须是二维图像数组对象。​如果参数声明为image2d_array_depth_t类型,则指定为参数值的内存对象必须是图像通道顺序为CL_DEPTH的2D图像数组对象。
​
​For all other kernel arguments, the arg_value entry must be a pointer to the actual data to be used as argument value.

​对于所有其他内核参数,arg_value条目必须是指向用作参数值的实际数据的指针。

A kernel object does not update the reference count for objects such as memory or sampler objects specified as argument values by clSetKernelArg. Users may not rely on a kernel object to retain objects specified as argument values to the kernel.

内核对象不会更新clSetKernelArg指定为参数值的内存或采样器对象等对象的引用计数。用户可能不依赖于内核对象来保留指定为内核参数值的对象。
​

Implementations shall not allow cl_kernel objects to hold reference counts to cl_kernel arguments, because no mechanism is provided for the user to tell the kernel to release that ownership right. If the kernel holds ownership rights on kernel args, that would make it impossible for users to tell with certainty when they may safely release user allocated resources associated with OpenCL objects such as the cl_mem backing store used with CL_MEM_USE_HOST_PTR.

​实现不应允许cl_kernel对象保存对cl_kernel参数的引用计数,因为没有为用户提供任何机制来告诉内核释放该所有权。如果内核对内核参数拥有所有权,那么用户将无法确定何时可以安全地释放与OpenCL对象相关的用户分配的资源,例如与CL_MEM_USE_HOST_PTR一起使用的cl_mem后备存储。

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

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

  • CL_INVALID_KERNEL if kernel is not a valid kernel object.

  • CL_INVALID_KERNEL,如果kernel不是有效的内核对象。

  • CL_INVALID_ARG_INDEX if arg_index is not a valid argument index.

  • 如果arg_index不是有效的参数索引,则返回CL_INVALID_ARG_INDEX。

  • CL_INVALID_ARG_VALUE if arg_value specified is not a valid value.

  • 如果指定的arg_value不是有效值,则返回CL_INVALID_ARG_VALUE。

  • CL_INVALID_MEM_OBJECT for an argument declared to be a memory object when the specified arg_value is not a valid memory object.

  • 当指定的arg_value不是有效的内存对象时,声明为内存对象的参数的CL_INVALID_MEM_OBJECT。

  • CL_INVALID_MEM_OBJECT for an argument declared to be a depth image, depth image array, multi-sample image, multi-sample image array, multi-sample depth image, or a multi-sample depth image array when the specified arg_value does not follow the rules described above for a depth memory object or memory array object argument.

  • 当指定的arg_value不符合上述深度存储对象或存储阵列对象参数的规则时,CL_INVALID_MEM_OBJECT用于声明为深度图像、深度图像阵列、多样本图像、多样本深度图像阵列或多样本深度图片阵列的参数。

  • CL_INVALID_SAMPLER for an argument declared to be of type sampler_t when the specified arg_value is not a valid sampler object.

  • 当指定的arg_value不是有效的采样器对象时,声明为sampler_t类型的参数的CL_INVALID_SAMPLER。

  • CL_INVALID_DEVICE_QUEUE for an argument declared to be of type queue_t when the specified arg_value is not a valid device queue object. This error code is missing before version 2.0.

  • 当指定的arg_value不是有效的设备队列对象时,声明为queue_t类型的参数的CL_INVALID_GUEUE。2.0版本之前缺少此错误代码。

  • CL_INVALID_ARG_SIZE if arg_size does not match the size of the data type for an argument that is not a memory object or if the argument is a memory object and arg_size != sizeof(cl_mem) or if arg_size is zero and the argument is declared with the local qualifier or if the argument is a sampler and arg_size != sizeof(cl_sampler).

  • CL_INVALID_ARG_SIZE,如果arg_size与非内存对象的参数的数据类型大小不匹配,或者如果参数是内存对象并且arg_size!=sizeof(cl_mem),或者如果arg_size为零并且参数是用局部限定符声明的,或者如果参数是采样器并且arg_size!=sizeof(cl_sampler)。

  • CL_MAX_SIZE_RESTRICTION_EXCEEDED if the size in bytes of the memory object (if the argument is a memory object) or arg_size (if the argument is declared with local qualifier) exceeds a language- specified maximum size restriction for this argument, such as the MaxByteOffset SPIR-V decoration. This error code is missing before version 2.2.

  • 如果内存对象的大小(如果参数是内存对象)或arg_size(如果参数用local限定符声明)超过了语言为此参数指定的最大大小限制,例如MaxByteOffset SPIR-V修饰,则CL_MAX_SIZE_RESTRICTION_EXCEEDED。2.2版本之前缺少此错误代码。

  • CL_INVALID_ARG_VALUE if the argument is an image declared with the read_only qualifier and arg_value refers to an image object created with cl_mem_flags of CL_MEM_WRITE_ONLY or if the image argument is declared with the write_only qualifier and arg_value refers to an image object created with cl_mem_flags of CL_MEM_READ_ONLY.

  • CL_INVALID_ARG_VALUE,如果参数是用read_only限定符声明的图像,并且arg_value是指用CL_MEM_WRITE_ONLY的cl_mem_flags创建的图像对象,或者如果图像参数是用写write_only限定符宣布的,并且arg_value是指使用CL_MEM_READ_ONLY的cl_mem_flags生成的图像对象。

  • 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实现所需的资源。

When clSetKernelArg returns an error code different from CL_SUCCESS, the internal state of kernel may only be modified when that error code is CL_OUT_OF_RESOURCES or CL_OUT_OF_HOST_MEMORY. When the internal state of kernel is modified, it is implementation-defined whether:

​当clSetKernelArg返回与CL_SUCCESS不同的错误代码时,只有当该错误代码为CL_OUT_OF_RESOURCES或CL_OUT_OF_HOST_MEMORY时,才能修改kernel的内部状态。当kernel的内部状态被修改时,实现定义了是否:

  • The argument value that was previously set is kept so that it can be used in further kernel enqueues.

  • 保留之前设置的参数值,以便在后续的内核排队中使用。

  • The argument value is unset such that a subsequent kernel enqueue fails with CL_INVALID_KERNEL_ARGS. [27]

  • ​参数值未设置,因此后续内核入队失败,返回CL_INVALID_KERNEL_ARGS。 [27]

To set a SVM pointer as the argument value for a specific argument of a kernel, call the function

要将SVM指针设置为内核特定参数的参数值,请调用函数

// Provided by CL_VERSION_2_0
cl_int clSetKernelArgSVMPointer(
    cl_kernel kernel,
    cl_uint arg_index,
    const void* arg_value);

clSetKernelArgSVMPointer is missing before version 2.0.

clSetKernelArgSVMPointer在2.0版本之前缺失。

  • kernel is a valid kernel object.

  • kernel是一个有效的内核对象。

  • arg_index is the argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.

  • arg_index是参数索引。指向内核的参数由从最左侧参数的0到n-1的索引引用,其中n是内核声明的参数总数。

  • arg_value is the SVM pointer that should be used as the argument value for argument specified by arg_index. The SVM pointer specified is the value used by all API calls that enqueue kernel (clEnqueueNDRangeKernel and clEnqueueTask) until the argument value is changed by a call to clSetKernelArgSVMPointer for kernel. The SVM pointer can only be used for arguments that are declared to be a pointer to global or constant memory. The SVM pointer value must be aligned according to the arguments type. For example, if the argument is declared to be global float4 *p, the SVM pointer value passed for p must be at a minimum aligned to a float4. The SVM pointer value specified as the argument value can be the pointer returned by clSVMAlloc or can be a pointer offset into the SVM region.

  • ​arg_value是SVM指针,应该用作arg_index指定的参数的参数值。指定的SVM指针是入队内核的所有API调用(clEnqueueNDRangeKernel和clEnqueueTask)使用的值,直到kernel的clSetKernelArgSVMPointer调用更改参数值为止。SVM指针只能用于声明为指向global或constant内存的指针的参数。SVM指针值必须根据参数类型进行对齐。例如,如果参数被声明为global float4 *p,则为p传递的SVM指针值必须与float4对齐。指定为参数值的SVM指针值可以是clSVMAlloc返回的指针,也可以是SVM区域的指针偏移量。

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

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

  • CL_INVALID_KERNEL if kernel is not a valid kernel object.

  • CL_INVALID_KERNEL,如果kernel不是有效的内核对象。

  • CL_INVALID_OPERATION if no devices in the context associated with kernel support SVM.

  • 如果与kernel关联的上下文中没有设备支持SVM,则为CL_INVALID_OPERATION。

  • CL_INVALID_ARG_INDEX if arg_index is not a valid argument index.

  • 如果arg_index不是有效的参数索引,则返回CL_INVALID_ARG_INDEX。

  • CL_INVALID_ARG_VALUE if arg_value specified is not a valid value.

  • 如果指定的arg_value不是有效值,则返回CL_INVALID_ARG_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 pass additional information other than argument values to a kernel, call the function

要将参数值以外的其他信息传递给内核,请调用函数

// Provided by CL_VERSION_2_0
cl_int clSetKernelExecInfo(
    cl_kernel kernel,
    cl_kernel_exec_info param_name,
    size_t param_value_size,
    const void* param_value);

clSetKernelExecInfo is missing before version 2.0.

clSetKernelExecInfo在2.0版本之前缺失。

  • kernel specifies the kernel object being queried.

  • kernel指定要查询的内核对象。

  • param_name specifies the information to be passed to kernel. The list of supported param_name types and the corresponding values passed in param_value is described in the Kernel Execution Properties table.

  • ​param_name指定要传递给内核的信息。内核执行属性表中描述了支持的param_name类型列表以及在param_value中传递的相应值。

  • param_value_size specifies the size in bytes of the memory pointed to by param_value.

  • param_value_size指定param_value指向的内存的大小(以字节为单位)。

  • param_value is a pointer to memory where the appropriate values determined by param_name are specified.

  • param_value是一个指向内存的指针,在内存中指定了由param_name确定的适当值。

Table 45. List of supported param_names by clSetKernelExecInfo

​表45 clSetKernelExecInfo支持的参数名称列表

Kernel Exec InfoTypeDescription

CL_KERNEL_EXEC_INFO_SVM_PTRS

missing before version 2.0.

void*[]

SVM pointers must reference locations contained entirely within buffers that are passed to kernel as arguments, or that are passed through the execution information.

SVM指针必须引用完全包含在缓冲区中的位置,这些位置作为参数传递给内核,或者通过执行信息传递。

Non-argument SVM buffers must be specified by passing pointers to those buffers via clSetKernelExecInfo for coarse-grain and fine-grain buffer SVM allocations but not for finegrain system SVM allocations.

​对于粗粒度和细粒度缓冲区SVM分配,必须通过clSetKernelExecInfo传递指向这些缓冲区的指针来指定非参数SVM缓冲区,但对于细粒度系统SVM分配则不能。

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM

missing before version 2.0.

cl_bool

This flag indicates whether the kernel uses pointers that are fine grain system SVM allocations. These fine grain system SVM pointers may be passed as arguments or defined in SVM buffers that are passed as arguments to kernel.

此标志指示内核是否使用细粒度系统SVM分配的指针。这些细粒度系统SVM指针可以作为参数传递,也可以在作为参数传递给内核的SVM缓冲区中定义。

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

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

  • CL_INVALID_KERNEL if kernel is a not a valid kernel object.

  • CL_INVALID_KERNEL,如果kernel不是有效的内核对象。

  • CL_INVALID_OPERATION if no devices in the context associated with kernel support SVM.

  • 如果与kernel 关联的上下文中没有设备支持SVM,则为CL_INVALID_OPERATION。

  • CL_INVALID_VALUE if param_name is not valid, if param_value is NULL or if the size specified by param_value_size is not valid.

  • 如果param_name无效、param_value为NULL或param_value_size指定的大小无效,则返回CL_INVALID_VALUE。

  • CL_INVALID_OPERATION if param_name is CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM and param_value is CL_TRUE but no devices in context associated with kernel support fine-grain system SVM allocations.

  • 如果param_name为CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,param_value为CL_TRUE,但与kernel关联的上下文中没有设备支持细粒度系统SVM分配,则为CL_INVALID_OPERATION。

  • 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实现所需的资源。

Coarse-grain or fine-grain buffer SVM pointers used by a kernel which are not passed as a kernel arguments must be specified using clSetKernelExecInfo with CL_KERNEL_EXEC_INFO_SVM_PTRS. For example, if SVM buffer A contains a pointer to another SVM buffer B, and the kernel dereferences that pointer, then a pointer to B must either be passed as an argument in the call to that kernel or it must be made available to the kernel using clSetKernelExecInfo. For example, we might pass extra SVM pointers as follows:

​
内核使用的粗粒度或细粒度缓冲区SVM指针,如果不作为内核参数传递,则必须使用clSetKernelExecInfo和CL_KERNEL_EXEC_INFO_SVM_PTRS指定。例如,如果SVM缓冲区A包含指向另一个SVM缓冲区B的指针,而内核取消引用该指针,则指向B的指针必须作为该内核调用中的参数传递,或者必须使用clSetsKernelExecInfo使其对内核可用。例如,我们可能会传递额外的SVM指针,如下所示:
​

clSetKernelExecInfo(kernel,
                    CL_KERNEL_EXEC_INFO_SVM_PTRS,
                    num_ptrs * sizeof(void *),
                    extra_svm_ptr_list);

Here num_ptrs specifies the number of additional SVM pointers while extra_svm_ptr_list specifies a pointer to memory containing those SVM pointers.

这里num_ptrs指定了额外SVM指针的数量,而extra_svm_ptr_list指定了一个指向包含这些SVM指针的内存的指针。

When calling clSetKernelExecInfo with CL_KERNEL_EXEC_INFO_SVM_PTRS to specify pointers to non-argument SVM buffers as extra arguments to a kernel, each of these pointers can be the SVM pointer returned by clSVMAlloc or can be a pointer + offset into the SVM region. It is sufficient to provide one pointer for each SVM buffer used.

​当使用CL_KERNEL_EXEC_INFO_SVM_PTRS调用clSetKernelExecInfo以指定指向非参数SVM缓冲区的指针作为内核的额外参数时,这些指针中的每一个都可以是clSVMAlloc返回的SVM指针,也可以是指向SVM区域的指针+偏移量。为每个使用的SVM缓冲区提供一个指针就足够了。

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM is used to indicate whether SVM pointers used by a kernel will refer to system allocations or not.

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM用于指示内核使用的SVM指针是否将引用系统分配。

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = CL_FALSE indicates that the OpenCL implementation may assume that system pointers are not passed as kernel arguments and are not stored inside SVM allocations passed as kernel arguments.

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM=CL_FALSE表示OpenCL实现可能假设系统指针不作为内核参数传递,也不存储在作为内核参数传入的SVM分配中。

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = CL_TRUE indicates that the OpenCL implementation must assume that system pointers might be passed as kernel arguments and/or stored inside SVM allocations passed as kernel arguments. In this case, if the device to which the kernel is enqueued does not support system SVM pointers, clEnqueueNDRangeKernel and clEnqueueTask will return a CL_INVALID_OPERATION error. If none of the devices in the context associated with kernel support fine-grain system SVM allocations, clSetKernelExecInfo will return a CL_INVALID_OPERATION error.

CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM=CL_TRUE表示OpenCL实现必须假设系统指针可以作为内核参数传递或存储在作为内核参数传入的SVM分配中。在这种情况下,如果内核排队的设备不支持系统SVM指针,clEnqueueNDRangeKernel和clEnqueueTask将返回CL_INVALID_OPERATION错误。如果与内核关联的上下文中没有设备支持细粒度系统SVM分配,clSetKernelExecInfo将返回CL_INVALID_OPERATION错误。

If clSetKernelExecInfo has not been called with a value for CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, the default value is used for this kernel attribute. The default value depends on whether the device on which the kernel is enqueued supports fine-grain system SVM allocations. If so, the default value used is CL_TRUE (system pointers might be passed); otherwise, the default is CL_FALSE.

如果未使用CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM的值调用clSetKernelExecInfo,则此内核属性将使用默认值。默认值取决于内核排队的设备是否支持细粒度系统SVM分配。如果是这样,则使用的默认值是CL_TRUE(可能会传递系统指针);否则,默认值为CL_FALSE。

A call to clSetKernelExecInfo for a given value of param_name replaces any prior value passed for that value of param_name. Only one param_value will be stored for each value of param_name.

​对于给定的param_name值调用clSetKernelExecInfo会替换之前为该param_name值传递的任何值。每个param_name值只存储一个param_value。

Kalibr标定避坑指南:如何用AprilGrid板快速完成双目IMU标定 本文详细介绍了使用AprilGrid板进行Kalibr双目IMU联合标定的实战技巧,包括标定工具选型、数据采集优化、标定流程及结果验证。通过AprilGrid板的唯一标识性和抗遮挡优势,结合IMU静止标定和运动激励设计,显著提升标定精度。文章还提供了常见报错处理和高级优化技巧,帮助开发者高效完成传感器标定。 阅读详情

相关推荐

基于 OptiSystem 的掺铒光纤放大器(EDFA)分析

通过构建 EDFA 仿真模型,系统分析了铒离子掺杂半径、离子浓度、光纤长度及泵浦功率等关键参数对放大器增益和噪声特性的影响规律,为 EDFA 的优化设计提供了理论依据与仿真支撑。继续增大至 9μm,增益趋于稳定(约 19dB)。继续增加至 200mW,增益仅增加 2dB,表明泵浦功率存在阈值效应(约 100mW),超过后增益饱和明显。:作为增益介质,主要参数包括光纤长度(5~50m)、铒离子掺杂半径(1~10μm)、离子浓度(1×10²⁵~5×10²⁵m⁻³)、纤芯半径 2.2μm、数值孔径 0.24。

2501_91855190的博客 2689

Windows Opencl clSetKernelArg()函数

Windows Opencl clSetKernelArg()函数详细解析 Setting Kernel Arguments 函数原型 cl_int clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) clSetKernelArg()用于为内核的特

qq_42877866的博客 4627

R3LIVE 1.0 适配 Velodyne 16线雷达:3步配置解决150米漂移问题

本文详细解析了R3LIVE 1.0适配Velodyne 16线雷达时出现的150米漂移问题,并提供三步配置方案。通过调整雷达类型设置、运动补偿与时间对齐、视觉-激光联合优化等关键参数,有效解决了系统漂移问题,提升定位精度。适用于机器人定位与建图领域的开发者。

weixin_29054195的博客 271

OpenCL中设置内核参数整理

很久没来了,一直在忙毕设的东西。这篇博文整理下OpenCL内核参数设置的问题。资源摘自OpenCL实战 首先,说一下kernel中的几种地址空间限定符: (1)__global 该参数的数据会保存在全局数据空间,在内核中的参数使用例子如下: __kernel void kernel_func(__global float *f) { } (2)__constant 该参数的

hanxing0的专栏 9459

海康机器人ID5000系列智能读码器实战:从安装到TCP通信的完整指南

本文提供了海康机器人ID5000系列智能读码器从开箱安装到TCP通信配置的完整实战指南。详细介绍了硬件连接、IDMVS软件配置、图像与算法参数调校,并重点解析了如何通过TCP Server模式实现稳定数据通信,辅以C#客户端编程示例和常见问题解决方案,帮助用户快速部署并应用于工业自动化场景。

weixin_29229989的博客 457

Cadence16.6安装教程

如需安装所需的软件,请到文章末尾处查看 安装步骤: 安装前先关闭杀毒软件和360卫士,注意安装路径不能有中文,安装包路径也不要有中文。 试装系统:win10 64bit 1.解压安装包(共5个压缩包,每个都要解压) 2.以管理员身份运行安装程序。 3.选择License Manager。 4.点击NEXT。 5.选择I accept,然后点击NEXT。 6.选择License Manage...

谢谢关注“小鱼教你模数电”,各平台同号 8万+

OpenCL 函数clSetKernelArg()返回错误值CL_INVALID_ARG_SIZE分析和理解

根据spec中查询到函数clSetKernelArg()返回错误值CL_INVALID_ARG_SIZE定义如下,下面展开分析。

Florence23的博客 960

迪文串口屏开发环境搭建全流程:从DGUS Tool到串口联调

串口屏作为嵌入式人机交互的核心组件,通过串口通信实现主控MCU与显示终端的指令交互。其工作原理基于变量地址映射,主控读写VP地址即可驱动屏上控件,兼具低功耗与高稳定性。在工业控制、医疗设备及智能家居面板等场景中,串口屏能显著降低开发门槛与硬件成本。迪文屏凭借DGUS Tool上位机与自定义串口协议,成为主流选择。掌握DGUS Tool版本匹配、串口驱动安装及VP地址规划,是快速搭建开发环境的关键。

weixin_33937499的博客 628

OpenCL函数-1

函数 Kernel OpenCL

OpenFPGA的博客 1367

手把手教你用STM32单片机DIY一个简易PLC(附完整电路图与PCB文件)

本文详细介绍了如何利用STM32单片机DIY一个简易PLC控制器,涵盖硬件设计、电路图解析、PCB布局优化及固件框架实现。通过完整的电路图和PCB文件,帮助读者从元器件选型到工业级优化,逐步构建可靠的PLC系统,特别适合工业自动化爱好者和学习者实践。

weixin_42527160的博客 584

SAP录入总账凭证报错 公司代码未被分配给国家或用于计算程序的国家消息号 FF703

SAP系统报错FF703的解决方案:当公司代码未分配国家或未配置计税程序时,会导致增值税计算失败。处理方法:1)通过OX02检查公司代码国家字段;2)使用OBBG为国家分配计税程序(如TAXCN)。配置步骤:1)SPRO分配公司代码到国家;2)OBBG设置国家对应的计税程序。注意事项:历史数据需清理才能修改国家字段,不同账簿可配置不同计税程序。完成配置后即可正常处理含税凭证。

金牌架构师 562

gpu opencl 向量加_如何传递和访问C向量到OpenCL内核?

>您必须分配一个OpenCL缓冲区并将您的cpu数据复制到其中. OpenCL缓冲区具有固定的大小,因此如果数据大小发生变化或者使其“足够大”,则必须重新创建它,如果需要更少的内存,则只能使用它的一部分.例如,为b创建缓冲区,同时将其所有数据复制到设备:cl_mem buffer_b = clCreateBuffer(context,// OpenCL contextCL_MEM_READ_...

weixin_42498346的博客 234

【从零开始学习 UVM】1.2、UVM 概述 —— UVM Installation(UVM 安装)

【从零开始学习 UVM】1.2、UVM 概述 —— UVM Installation(UVM 安装)

努力,加油每一天鸭~ 1951

OpenCL™规范 5.8.6.6. 查询内核参数信息的选项

​此选项允许编译器在程序可执行文件中存储有关内核参数的信息。存储的参数信息包括参数名称、类型、地址空间和使用的访问限定符。有关如何查询此信息,请参阅clGetCernelArgInfo的说明。在1.2版本之前,缺少对内核参数信息的查询。

aggs1990的专栏 148

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

OpenCL™规范 5.17.7.2. 内核命令更新结构

有关cl_mutable_dispatch_arg_khr成员的用法,请参阅clSetKernelArgSVMPointer,arg_size将被忽略。​local_work_size指向一个work_dim无符号值数组,该数组描述了组成将执行内核的工作组的工作项的数量。有关cl_mutable_dispatch_arg_khr成员的用法,请参阅clSetKernelArg。有关cl_mutable_dispatch_exec_info_khr成员的用法,请参阅clSetKernelExecInfo。

aggs1990的专栏 174

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

opencl coarse svm

设备端代码: //using for coarse svm test typedef struct _Element{ __global float *internal; __global float *external; float value; }Element; __kernel void svmbasic(__global Element *elements, ...

qingsong1001的专栏 552

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

OpenCL-SVM(共享虚拟内存)实验

在体验了OpenCV-OpenCL的使用之后,发现CPU和GPU之间的数据传输相当的耗时,既然我这个小菜鸟都发现了这个瓶颈,大佬们肯定也早就发现也有一些解决方案吧!在网上看到一篇与这个有关的文章《OpenCL2.0特性之SVM》,可以先了解一下,看完之后有所收获,但也有许多疑问如下: 1、SVM支持CPU和GPU之间不需要数据拷贝就可以数据共享,那这个SVM是软件实现的还是硬件实现的?如果是软件

楷尘·极客 4911

OpenCL OpenCL设备模型

1.Opencl设备模型:__global被称为地址空间修饰符,这是因为它所修饰的任何指针都会被保存在全局地址空间之中,而这个地址空间也被称为全局内存。每个引用内存的内核参数都必须有一个地址空间修饰符。 2.OpenCL设备模型提供了四种地址空间: (1)全局内存–保存整个设备的数据,既可读,也可写; (2)常数内存–和全局内存相似,但是只可读; (3)局部内存–保存工作组中工作项的数据; (4)...

INFINALGEORGE的博客 958

OpenCL简单入门介绍(根据《OpenCL Overview》翻译整理)

根据《OpenCL Overview》与《OpenCL Technical Overview》整理编写,由于第一次接触OpenCL,定会有部分的专业词汇翻译不当,敬请指正。 1.《OpenCL Overview》整理笔记 这是一个异构的世界   OpenCL让程序员写单一的可移植程序,在一个异构平台上使用所有的资源。 OpenCL使用   1. 定义平台; 2.

Johnson的技术博客 5466

学习OpenCL与卷积神经网络 Day4——OpenCL内核(Kernel)程序构建

目录内核程序修饰符函数修饰符kernel修饰符地址空间修饰符全局地址空间局部地址空间常量地址空间私有地址空间对象访问修饰符主程序中内核创建内核对象设置内核参数执行内核内核函数样例 内核程序修饰符 函数修饰符 函数修饰符用来修饰OpenCL内核函数及一般函数的一些特性,以帮助编译器确定一些信息。 kernel修饰符 __kernel修饰符声明一个函数为一个内核函数,这个内核函数将会在OpenCL设备上执行,这也是我们最常用的修饰符。内核函数返回类型必须是void类型,且主机端可以调用这个函数。 __kerne

不偷懒会死星人的blog 1816

opencl学习(六)——local memory使用

由于统一个workgroup中的所有work-item可以共用本地内存(local),也可以通过它进行同组work-item之间的通信,因此我们整理一下local memory的用法。 本地内存可以在kernel内部定义,也可以通过参数传递。下面就来说明一下这两种方式。 下面是一段来自《opencl异构计算》的代码: __kernel void localAccess( __global

噌胥苑——行思驿站 1万+

[OpenCL] 内核编程:数据类型和设备内存(13)

本章涵盖 介绍一个简单的 OpenCL 内核 使用 OpenCL 的标量和矢量数据类型 了解 OpenCL 设备模型   在本章中,我们将抛开创建和部署内核的脚手架,开始编写内核本身。 我们将检查 OpenCL 内核中可用的数据类型,这意味着我们最终将讨论向量。 当您使用向量处理数据时,您可以抛开 char、float 和 int 等枯燥的、几十年前的数据类型,而使用新的、令人兴奋的数据类型,例如 char16、int3 和 float4。   直到大学毕业后我才学习矢量编程,但从那以后我一直很喜欢.

unity尧明的博客 1257

OpenCL将数组从内存copy到显存

本来想对上一篇博客做优化,优化效果不明显。但知识点还是要记一下。 初衷是想把上一篇博客中定义域的计算搬到CPU来计算,因为定义域的计算对于每一个kernel都是一样的,所以直接读取应该是可以进一步减小kernel的执行时间的。 我的思路的初衷是将这块的数据送到显存之后再送到寄存器中,从寄存器读取的时间应该是很快的,通过这样把计算的时间改为读取的时间。当然,读取寄存器的时...

weixin_30950887的博客 647

[OpenCL] 主机编程:数据传输和分区(12)

3.6 数据分区   如果您使用 OpenCL 实现算法,您可能需要处理大量数据。 这使得数据分区成为一个重要的优先事项——处理负载分配得越好,计算任务就会越早完成。   您已经知道如何在多个设备之间划分数据,但您可以进一步划分数据。 大多数 OpenCL 设备包含多个处理元素,并且使用正确的代码,您可以控制每个处理元素接收的数据量。   只有一个函数需要知道:clEnqueueNDRangeKernel。 这是 OpenCL API 中最重要的功能之一,也是最复杂的功能之一。 与 clEnqueueTas

unity尧明的博客 1042

OpenCL错误码

#define CL_SUCCESS 0 #define CL_DEVICE_NOT_FOUND -1 #define CL_DEVICE_NOT_AVAILABLE -2 #define CL_COMPILER_NOT_AVAILABLE...

weixin_30955341的博客 982

OpenCL 2.0 规范 – SVM共享虚拟内存

OpenCL2.0规范相对于1.2版本做出了重大改进,使得一个多元系统中各个硬件之间增强了通信与协作能力。在接下来的系列文章中,将着重讲解OpenCL2.0的新特性,探究其重要性以及对开发、性能等方面会产生什么影响。

异构开发技术社区官方博客 9155
上一篇: OpenCL™规范 5.9.1. 创建内核对象
下一篇: OpenCL™规范 5.9.3. 复制内核对象
꧁白杨树下꧂
博客等级 码龄15年 1019粉丝 209原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值