OpenCL clBuildProgram() barfs on stdout

I am using OpenCL on this device:

PowerVR B-Series BXM-4-64 Imagination Technologies with [1 units] localmem=4KiB globalmem=5445MiB dims=3(512x512x512) max workgrp sz 512 fp16=y

I use it with the RISCV Sipeed Pi4A SBC.

Calling clCreateProgramWithSource() succeeds.

When I then call clBuildProgram() it returns success, but out the stdout I get:

44444444444444444444444444

Why does libPVROCL.so.1 spew this weird string consisting of 26 ‘4’ characters?

I see the same happen on Native_SDK’s OpenCL example.

debian@lpi4a:~/src/Native_SDK/build/bin$ ./OpenCLMatrixMultiplication 

Single Precision General Matrix Multiplication (SGEMM) benchmarking test.
Host library 'libOpenCL.so' loaded
OpenCL Bindings: Successfully loaded library libOpenCL.so for OpenCL
[cl::createOpenCLContext]: Created context on platform PowerVR.
Running DEMO mode. 
M:    512     N:   1536     P:  1024
Left Matrix(MxN):  512x1536      Right Matrix(NxP): 1536x1024
==> Creating OpenCL program                   - Time: 0.186
444444444444444444444444444444==> Beginning Matrix setup                    - Time: 1049.69(1049.71ms)
==> Populating Matrices                       - Time: 1.04975(313.522ms)
==> Transposing Matrix B                      - Time: 1.36334(478.444ms)
==> Setting up buffers                        - Time: 1.52825(39.413ms)
==> Preparing ground truth: CPU-side multiply  - Time: 1.56773(0.037376ms)

===== EXECUTION:  matmul_transposedA                      (4492.34ms)
===== EXECUTION:  matmul_transposedB                      (4068.88ms)
===== EXECUTION:  matmul_transposedC                      (4769.83ms)
===== EXECUTION:  matmul_transposedAC                     (4507.65ms)
===== EXECUTION:  matmul_transposedBC                     (4092.99ms)
===== EXECUTION:  matmul_linearwg_AT                      (4263.81ms)
===== EXECUTION:  matmul_linearwg_BT                      (3868.56ms)
===== EXECUTION:  matmul_linearwg_vec4                    (1097.46ms)
===== EXECUTION:  matmul_linearwg_vec4_local              (1546.28ms)
===== EXECUTION:  matmul_tile_square                      (2031.60ms)
===== EXECUTION:  matmul_tile_rect                        (1488.14ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x16x4   (1104.75ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x32x4   (1550.73ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x64x4   (2029.77ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x16x4   (863.97 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x32x4   (836.47 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x64x4   (906.36 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          8x32x4   (778.41 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          8x64x4   (798.79 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          16x64x4  (1113.55ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x32x8   (1050.65ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x64x8   (1150.97ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x32x8   (650.49 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x64x8   (689.34 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          8x32x8   (655.85 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          8x64x8   (709.09 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          16x64x8  (1020.12ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          2x64x16  (1199.32ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          4x64x16  (614.44 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          8x64x16  (654.15 ms)444444444444444444444444444444
===== EXECUTION:  matmul_tile_rect_vec4          16x64x16 (992.91 ms)


*** HALL OF FAME ***
--------------------------------------------------
 1 : matmul_tile_rect_vec4 4x64x16   	(614.53ms)
 2 : matmul_tile_rect_vec4 4x32x8    	(650.58ms)
 3 : matmul_tile_rect_vec4 8x64x16   	(654.24ms)
 4 : matmul_tile_rect_vec4 8x32x8    	(655.93ms)
 5 : matmul_tile_rect_vec4 4x64x8    	(689.43ms)
 6 : matmul_tile_rect_vec4 8x64x8    	(709.18ms)
 7 : matmul_tile_rect_vec4 8x32x4    	(778.50ms)
 8 : matmul_tile_rect_vec4 8x64x4    	(798.88ms)
 9 : matmul_tile_rect_vec4 4x32x4    	(836.56ms)
10 : matmul_tile_rect_vec4 4x16x4    	(864.04ms)
11 : matmul_tile_rect_vec4 4x64x4    	(906.45ms)
12 : matmul_tile_rect_vec4 16x64x16  	(993.39ms)
13 : matmul_tile_rect_vec4 16x64x8   	(1020.21ms)
14 : matmul_tile_rect_vec4 2x32x8    	(1050.74ms)
15 : matmul_linearwg_vec4            	(1097.53ms)
16 : matmul_tile_rect_vec4 2x16x4    	(1104.85ms)
17 : matmul_tile_rect_vec4 16x64x4   	(1113.64ms)
18 : matmul_tile_rect_vec4 2x64x8    	(1151.05ms)
19 : matmul_tile_rect_vec4 2x64x16   	(1199.41ms)
20 : matmul_tile_rect                	(1488.23ms)
21 : matmul_linearwg_vec4_local      	(1546.37ms)
22 : matmul_tile_rect_vec4 2x32x4    	(1550.83ms)
23 : matmul_tile_rect_vec4 2x64x4    	(2029.86ms)
24 : matmul_tile_square              	(2032.10ms)
25 : matmul_linearwg_BT              	(3868.65ms)
26 : matmul_transposedB              	(4068.96ms)
27 : matmul_transposedBC             	(4093.08ms)
28 : matmul_linearwg_AT              	(4263.90ms)
29 : matmul_transposedA              	(4492.45ms)
30 : matmul_transposedAC             	(4507.74ms)
31 : matmul_transposedC              	(4769.92ms)

Hi bram,

Thank you for your message.
I am getting this behaviour checked with the OpenCL team and shall get back once I have more information.

Best Regards,
Nagnath

Hi bram,

Could we have more details about the Host environment and DDK revision?

Best Regards,
Nagnath

I am not using the DDK, I am not an OEM, but end-user.

The host is a Sipeed Pi4A, RISCV with TH1520 SoC.

The OpenCL library is included in Sipeed’s Debian image.

$ inxi -G 
Graphics:
  Device-1: gpu driver: pvrsrvkm v: kernel
  Device-2: light-hdmi-tx driver: dwhdmi_light v: N/A
  Device-3: display-subsystem driver: vs_drm v: N/A
  Display: x11 server: X.org v: 1.20.10 driver: X: loaded: modesetting
    unloaded: fbdev gpu: pvrsrvkm,dwhdmi_light,vs_drm tty: 80x24
  API: OpenGL Message: GL data unavailable in console. Try -G --display
$ clinfo
Number of platforms                               1
  Platform Name                                   PowerVR
  Platform Vendor                                 Imagination Technologies
  Platform Version                                OpenCL 3.0 
  Platform Profile                                EMBEDDED_PROFILE
  Platform Extensions                             cl_khr_icd cl_khr_fp16 cl_img_spirv cles_khr_int64 cl_img_yuv_image cl_khr_device_uuid cl_khr_depth_images cl_khr_priority_hints cl_img_generate_mipmap cl_khr_3d_image_writes cl_img_cached_allocations cl_khr_create_command_queue cl_img_mem_properties cl_img_mem_properties_relax_alloc_requirements cl_khr_extended_versioning cl_khr_image2d_from_buffer cl_khr_byte_addressable_store cl_khr_local_int32_base_atomics cl_khr_global_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_global_int32_extended_atomics cl_khr_spir cl_khr_egl_image cl_arm_import_memory cl_arm_import_memory_dma_buf cl_img_protected_content cl_img_semaphore cl_img_external_semaphore cl_img_external_semaphore_sync_fd
  Platform Extensions with Version                cl_khr_icd                                                       0x400000 (1.0.0)
                                                  cl_khr_fp16                                                      0x400000 (1.0.0)
                                                  cl_img_spirv                                                     0x400000 (1.0.0)
                                                  cles_khr_int64                                                   0x400000 (1.0.0)
                                                  cl_img_yuv_image                                                 0x400000 (1.0.0)
                                                  cl_khr_device_uuid                                               0x400000 (1.0.0)
                                                  cl_khr_depth_images                                              0x400000 (1.0.0)
                                                  cl_khr_priority_hints                                            0x400000 (1.0.0)
                                                  cl_img_generate_mipmap                                           0x400000 (1.0.0)
                                                  cl_khr_3d_image_writes                                           0x400000 (1.0.0)
                                                  cl_img_cached_allocations                                        0x400000 (1.0.0)
                                                  cl_khr_create_command_queue                                      0x400000 (1.0.0)
                                                  cl_img_mem_properties                                            0x400000 (1.0.0)
                                                  cl_img_mem_properties_relax_alloc_requirements                   0x400000 (1.0.0)
                                                  cl_khr_extended_versioning                                       0x400000 (1.0.0)
                                                  cl_khr_image2d_from_buffer                                       0x400000 (1.0.0)
                                                  cl_khr_byte_addressable_store                                    0x400000 (1.0.0)
                                                  cl_khr_local_int32_base_atomics                                  0x400000 (1.0.0)
                                                  cl_khr_global_int32_base_atomics                                 0x400000 (1.0.0)
                                                  cl_khr_local_int32_extended_atomics                              0x400000 (1.0.0)
                                                  cl_khr_global_int32_extended_atomics                             0x400000 (1.0.0)
                                                  cl_khr_spir                                                      0x400000 (1.0.0)
                                                  cl_khr_egl_image                                                 0x400000 (1.0.0)
                                                  cl_arm_import_memory                                             0x400000 (1.0.0)
                                                  cl_arm_import_memory_dma_buf                                     0x400000 (1.0.0)
                                                  cl_img_protected_content                                         0x400000 (1.0.0)
                                                  cl_img_semaphore                                                 0x400000 (1.0.0)
                                                  cl_img_external_semaphore                                        0x400000 (1.0.0)
                                                  cl_img_external_semaphore_sync_fd                                0x400000 (1.0.0)
  Platform Numeric Version                        0xc00000 (3.0.0)
  Platform Extensions function suffix             IMG
  Platform Host timer resolution                  0ns

  Platform Name                                   PowerVR
Number of devices                                 1
  Device Name                                     PowerVR B-Series BXM-4-64
  Device Vendor                                   Imagination Technologies
  Device Vendor ID                                0x1
  Device Version                                  OpenCL 3.0 
  Device UUID                                     33362035-3220-3130-3420-313832000000
  Driver UUID                                     36303939-3538-3000-0000-000000000000
  Valid Device LUID                               No
  Device LUID                                     0000-000000000000
  Device Node Mask                                0
  Device Numeric Version                          0xc00000 (3.0.0)
  Driver Version                                  1.16@6099580
  Device OpenCL C Version                         OpenCL C 1.2 
  Device OpenCL C Numeric Version                 0x402000 (1.2.0)
  Device OpenCL C all versions                    OpenCL C                                                         0x400000 (1.0.0)
                                                  OpenCL C                                                         0x401000 (1.1.0)
                                                  OpenCL C                                                         0x402000 (1.2.0)
                                                  OpenCL C                                                         0xc00000 (3.0.0)
  Device OpenCL C features                        __opencl_c_int64                                                 0x400000 (1.0.0)
                                                  __opencl_c_pipes                                                 0xc00000 (3.0.0)
                                                  __opencl_c_images                                                0x400000 (1.0.0)
                                                  __opencl_c_subgroups                                             0xc00000 (3.0.0)
                                                  __opencl_c_3d_image_writes                                       0x400000 (1.0.0)
                                                  __opencl_c_read_write_images                                     0x400000 (1.0.0)
                                                  __opencl_c_generic_address_space                                 0xc00000 (3.0.0)
                                                  __opencl_c_program_scope_global_variables                        0xc00000 (3.0.0)
                                                  __opencl_c_work_group_collective_functions                       0xc00000 (3.0.0)
  Latest conformance test passed                  v2021-06-16-00
  Device Type                                     GPU
  Device Profile                                  EMBEDDED_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               1
  Max clock frequency                             792MHz
  Device Partition                                (core)
    Max number of sub-devices                     1
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             512x512x512
  Max work group size                             512
  Preferred work group size multiple (device)     32
44444444444444444444444444  Preferred work group size multiple (kernel)     32
  Max sub-groups per work group                   512
  Preferred / native vector sizes                 
    char                                                 1 / 1       
    short                                                1 / 1       
    int                                                  1 / 1       
    long                                                 1 / 1       
    half                                                 0 / 0        (cl_khr_fp16)
    float                                                1 / 1       
    double                                               0 / 0        (n/a)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (n/a)
  Address bits                                    64, Little-Endian
  Global memory size                              4019400704 (3.743GiB)
  Error Correction support                        No
  Max memory allocation                           1004850176 (958.3MiB)
  Unified memory for Host and Device              Yes
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 Yes
    Fine-grained buffer sharing                   No
    Fine-grained system sharing                   No
    Atomics                                       No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Preferred alignment for atomics                 
    SVM                                           0 bytes
    Global                                        0 bytes
    Local                                         0 bytes
  Atomic memory capabilities                      relaxed, work-group scope
  Atomic fence capabilities                       relaxed, acquire/release, work-group scope
  Max size for global variable                    16384 (16KiB)
  Preferred total size of global vars             0
  Global Memory cache type                        Read/Write
  Global Memory cache size                        16384 (16KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             8
    Max size for 1D images from buffer            8192 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   64 bytes
    Pitch alignment for 2D image buffers          64 pixels
    Max 2D image size                             8192x8192 pixels
    Max 3D image size                             8192x8192x2048 pixels
    Max number of read image args                 8
    Max number of write image args                1
    Max number of read/write image args           64
  Pipe support                                    Yes
  Max number of pipe args                         16
  Max active pipe reservations                    1
  Max pipe packet size                            1024
  Local memory type                               Local
  Local memory size                               4096 (4KiB)
  Max number of constant args                     4
  Max constant buffer size                        65536 (64KiB)
  Generic address space support                   Yes
  Max size of kernel argument                     1024
  Queue properties (on host)                      
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Device enqueue capabilities                     (n/a)
  Queue properties (on device)                    
    Out-of-order execution                        No
    Profiling                                     No
    Preferred size                                0
    Max size                                      0
  Max queues on device                            0
  Max events on device                            0
  Prefer user sync for interop                    Yes
  Profiling timer resolution                      1000ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            Yes
    Non-uniform work-groups                       Yes
    Work-group collective functions               Yes
    Sub-group independent forward progress        No
    IL version                                    (n/a)
    ILs with version                              (n/a)
    SPIR versions                                 1.2
  printf() buffer size                            65536 (64KiB)
  Built-in kernels                                (n/a)
  Built-in kernels with version                   (n/a)
  Device Extensions                               cl_khr_icd cl_khr_fp16 cl_img_spirv cles_khr_int64 cl_img_yuv_image cl_khr_device_uuid cl_khr_depth_images cl_khr_priority_hints cl_img_generate_mipmap cl_khr_3d_image_writes cl_img_cached_allocations cl_khr_create_command_queue cl_img_mem_properties cl_img_mem_properties_relax_alloc_requirements cl_khr_extended_versioning cl_khr_image2d_from_buffer cl_khr_byte_addressable_store cl_khr_local_int32_base_atomics cl_khr_global_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_global_int32_extended_atomics cl_khr_spir cl_khr_egl_image cl_arm_import_memory cl_arm_import_memory_dma_buf cl_img_protected_content cl_img_semaphore cl_img_external_semaphore cl_img_external_semaphore_sync_fd
  Device Extensions with Version                  cl_khr_icd                                                       0x400000 (1.0.0)
                                                  cl_khr_fp16                                                      0x400000 (1.0.0)
                                                  cl_img_spirv                                                     0x400000 (1.0.0)
                                                  cles_khr_int64                                                   0x400000 (1.0.0)
                                                  cl_img_yuv_image                                                 0x400000 (1.0.0)
                                                  cl_khr_device_uuid                                               0x400000 (1.0.0)
                                                  cl_khr_depth_images                                              0x400000 (1.0.0)
                                                  cl_khr_priority_hints                                            0x400000 (1.0.0)
                                                  cl_img_generate_mipmap                                           0x400000 (1.0.0)
                                                  cl_khr_3d_image_writes                                           0x400000 (1.0.0)
                                                  cl_img_cached_allocations                                        0x400000 (1.0.0)
                                                  cl_khr_create_command_queue                                      0x400000 (1.0.0)
                                                  cl_img_mem_properties                                            0x400000 (1.0.0)
                                                  cl_img_mem_properties_relax_alloc_requirements                   0x400000 (1.0.0)
                                                  cl_khr_extended_versioning                                       0x400000 (1.0.0)
                                                  cl_khr_image2d_from_buffer                                       0x400000 (1.0.0)
                                                  cl_khr_byte_addressable_store                                    0x400000 (1.0.0)
                                                  cl_khr_local_int32_base_atomics                                  0x400000 (1.0.0)
                                                  cl_khr_global_int32_base_atomics                                 0x400000 (1.0.0)
                                                  cl_khr_local_int32_extended_atomics                              0x400000 (1.0.0)
                                                  cl_khr_global_int32_extended_atomics                             0x400000 (1.0.0)
                                                  cl_khr_spir                                                      0x400000 (1.0.0)
                                                  cl_khr_egl_image                                                 0x400000 (1.0.0)
                                                  cl_arm_import_memory                                             0x400000 (1.0.0)
                                                  cl_arm_import_memory_dma_buf                                     0x400000 (1.0.0)
                                                  cl_img_protected_content                                         0x400000 (1.0.0)
                                                  cl_img_semaphore                                                 0x400000 (1.0.0)
                                                  cl_img_external_semaphore                                        0x400000 (1.0.0)
                                                  cl_img_external_semaphore_sync_fd                                0x400000 (1.0.0)

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  PowerVR
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [IMG]
  clCreateContext(NULL, ...) [default]            Success [IMG]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 PowerVR
    Device Name                                   PowerVR B-Series BXM-4-64
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 PowerVR
    Device Name                                   PowerVR B-Series BXM-4-64
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  Invalid device type for platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 PowerVR
    Device Name                                   PowerVR B-Series BXM-4-64

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.1
  ICD loader Profile                              OpenCL 3.0

Hi bram,

The required information is mentioned in the log you shared. Thank you.

Best Regards,
Nagnath

Hello bram,

I’ve got some update from our OCL team to share with you on this issue of yours,
Unfortunately we were unable to reproduce this at our end. Our OCL team shared some of their thoughts on possible causes. For the driver to deliberately send out 26 fours is implausible - is there another thread or GPU task on user’s machine that we don’t know about? "Do you see this behaviour always, or only occasionally?

Could you try some other program, such as ocl_unit_test add, to see if any 4s appear?

Best Regards,
Nagnath

It is always.

I guess it is something that Sipeed put in the driver they shipped their riscv device with.