kpet / clvk

Implementation of OpenCL 3.0 on Vulkan
Apache License 2.0
345 stars 39 forks source link

`char*` doesn't work #716

Open hakanrw opened 1 month ago

hakanrw commented 1 month ago

while testing some OpenCL examples, i found out that char* is not working on my system (Raspberry Pi 5).

code from hello_world.cl

/**
 * This kernel function only fills a buffer with the sentence 'Hello World!'.
 **/

__kernel void helloWorld(__global char* data){
    data[0] = 'H';
    data[1] = 'e';
    data[2] = 'l';
    data[3] = 'l';
    data[4] = 'o';
    data[5] = ' ';
    data[6] = 'W';
    data[7] = 'o';
    data[8] = 'r';
    data[9] = 'l';
    data[10] = 'd';
    data[11] = '!';
    data[12] = '\n';
    data[13] = 0;
}

it generates the following error

error: 28: Structure id 10 decorated as Block for variable in StorageBuffer storage class must follow relaxed storage buffer layout rules: member 0 contains an array with stride 1 not satisfying alignment to 4
  %_struct_10 = OpTypeStruct %_runtimearr_uint

Build Status: -2Build Log:   clvk-RoBPoh/source.cl:22:1: warning: null character ignored
   22 | <U+0000>
      | ^
clvk-RoBPoh/source.cl:22:2: warning: no newline at end of file
   22 | <U+0000>
      |         ^

changing __global char* type to __global int* resolves the issue.

example source

kpet commented 1 month ago

Thanks for the report. This is an issue in clspv. I suggest you create an issue in the clspv project directly: https://github.com/google/clspv/issues.

We can keep this one to track the need to update clspv when the fix lands.

Rekt3421 commented 3 weeks ago

Definitely an issue with clspv.

leaving the kernel options here

-cl-single-precision-constant -cl-kernel-arg-info -rounding-mode-rte=16,32,64 -int8=0 -std430-ubo-layout -decorate-nonuniform -hack-convert-to-float -arch=spir --use-native-builtins=ceil,copysign,fabs,fdim,floor,fmax,fmin,half_cos,half_exp,half_exp10,half_exp2,half_rsqrt,half_sin,half_sqrt,half_tan,isequal,isfinite,isgreater,isgreaterequal,isinf,isless,islessequal,islessgreater,isnan,isnormal,isnotequal,isordered,isunordered,mad,rint,round,rsqrt,signbit,sqrt,trunc, -spv-version=1.6 -max-pushconstant-size=256 -max-ubo-size=65536 -global-offset -long-vector -module-constants-in-storage-buffer -cl-arm-non-uniform-work-group-size -enable-printf -printf-buffer-size=1048576
rjodinchr commented 1 week ago

We only need to update clspv to fix that issue now.