Skip to content

Using OpTypeBool for kernel parameters is invalid according to OpenCL SPIR-V Env specification #11531

@karolherbst

Description

@karolherbst

Describe the bug
With some SyCL-CTS tests I'm seeing SPIR-V declaring OpTypeBool as Kernel function parameters, e.g. test_spec_constants. It might not be the best test to dig into this problem as it executes a lot of spirvs.

               OpEntryPoint Kernel %1337 "_ZTSN33specialization_constants_external6kernelIbLi1EEE" %__spirv_BuiltInWorkgroupId %__spirv_BuiltInGlobalLinearId %__spirv_BuiltInWorkgroupSize
...
       %bool = OpTypeBool
...
        %218 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_Function_class_sycl___V1__id %bool
...
       %1337 = OpFunction %void None %218
...
%_arg_ref_43 = OpFunctionParameter %bool

The OpenCL SPIR-V env specification states:

An OpFunctionParameter for an OpFunction that is identified with OpEntryPoint defines an OpenCL kernel argument. Allowed types for OpenCL kernel arguments are:

  • OpTypeInt
  • OpTypeFloat
  • OpTypeStruct
  • OpTypeVector
  • OpTypePointer
  • OpTypeSampler
  • OpTypeImage
  • OpTypePipe
  • OpTypeQueue

The problem with using OpTypeBool or bool in OpenCL C is, that its size is not defined by the OpenCL specification and hence calls to clSetKernelArg on arguments with a OpTypeBool parameter is undefined.

I suspect that just using OpTypeInt 8 0 might be a good alternative here.

To Reproduce
Run SyCL-CTS test_spec_constants

Environment (please complete the following information):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions