#1059511 pocl: FTBFS on many architectures: The testsuite has failed

#1059511#5
Date:
2023-12-27 08:54:53 UTC
From:
To:
Dear Maintainer,

I am looking at the build issue from riscv64 port view but it can not be
build many arches:
https://buildd.debian.org/status/package.php?p=pocl

It seems even updated the symbols file still failed due to exist
debian/stamp-failed-testsuite file.

```
run_dh_makeshlibs:
        dh_makeshlibs
delayed_check_dh_auto_test_result: run_dh_makeshlibs
        @set -ex; if test -f debian/stamp-failed-testsuite ; then \
                echo "***** The testsuite has failed! *****" ; \
                exit 1 ; \
        fi                                                                                                                                         @test -f obj-*/Testing/Temporary/LastTest.log && echo 'The testsuite has passed all tests.' || echo '*** The testsuite was *NOT* ru
n! ***'

```

The same issue happend on 5.0 also:
https://buildd.debian.org/status/package.php?p=pocl&suite=experimental

But from upstream 5.0 release note, there is support well expect 4 tests
failed. So what is your advice here about the issue?

http://portablecl.org/docs/html/notes_5_0.html#risc-v-cpu-support-improved

#1059511#10
Date:
2023-12-27 22:35:29 UTC
From:
To:
Control: retitle -1 pocl: FTBFS on riscv64: testsuite fails: can't link double-float modules with soft-float modules
Control: severity -1 wishlist

In the buildlog I see

   13% tests passed, 228 tests failed out of 263

Errors seem to happen at OpenCL kernel build time:

   LLVM ERROR: unable to write nop sequence of 2 bytes

and mostly

   /usr/bin/ld: /lib/riscv64-linux-gnu/libm.so: can't link double-float
   modules with soft-float modules

   /usr/bin/ld: failed to merge target specific data of file
   /lib/riscv64-linux-gnu/libm.so

   /usr/bin/ld: /lib/riscv64-linux-gnu/libgcc_s.so.1: can't link double-float
   modules with soft-float modules

   /usr/bin/ld: failed to merge target specific data of file
   /lib/riscv64-linux-gnu/libgcc_s.so.1

   /usr/bin/ld: /lib/riscv64-linux-gnu/libc.so.6: can't link double-float
   modules with soft-float modules

   /usr/bin/ld: failed to merge target specific data of file
   /lib/riscv64-linux-gnu/libc.so.6

   /usr/bin/ld: /lib/ld-linux-riscv64-lp64d.so.1: can't link double-float
   modules with soft-float modules

   /usr/bin/ld: failed to merge target specific data of file
   /lib/ld-linux-riscv64-lp64d.so.1

   /usr/bin/ld: /lib/riscv64-linux-gnu/libgcc_s.so.1: can't link double-float
   modules with soft-float modules

   /usr/bin/ld: failed to merge target specific data of file
   /lib/riscv64-linux-gnu/libgcc_s.so.1

   error: linker command failed with exit code 1 (use -v to see invocation)

   Final linking of kernel test_shuffle_2_2 failed.


I'd suggest postponing further analysis until sid has pocl 5.0 and
switched from llvm-15 to llvm-16. These two changes will *not* happen in
a single upload.


Andreas

#1059511#19
Date:
2023-12-28 23:23:49 UTC
From:
To:
Hi!
...

Thanks. I did not notice these special test logs from buildd.  I will
look at this more here.

BR,
Bo

#1059511#24
Date:
2024-01-18 07:41:16 UTC
From:
To:
I cost some time to try to fix the issue, progress is below.

Inspired by the commit:
https://github.com/pocl/pocl/issues/1088#issue-1340373438

If i build pocl by manual if follow:

```
cmake ..
     -DCMAKE_INSTALL_PREFIX='/usr'
     -DCMAKE_BUILD_TYPE='Debug'
     -DPOCL_DEBUG_MESSAGES=ON
     -DLLC_HOST_CPU='sifive-u54'
```

Then there are four test failed:

```
98% tests passed, 4 tests failed out of 263

Label Time Summary:
EinsteinToolkit    = 190.88 sec*proc (2 tests)
cuda               = 279.87 sec*proc (42 tests)
dlopen             =   0.52 sec*proc (3 tests)
hsa                =  35.00 sec*proc (4 tests)
hsa-native         = 1127.40 sec*proc (82 tests)
internal           = 3317.43 sec*proc (256 tests)
kernel             = 1719.95 sec*proc (76 tests)
level0             = 1446.25 sec*proc (124 tests)
matrix             =  40.41 sec*proc (4 tests)
poclbin            =  38.95 sec*proc (4 tests)
proxy              = 327.09 sec*proc (36 tests)
regression         = 933.17 sec*proc (95 tests)
runtime            = 179.38 sec*proc (31 tests)
tce                =  69.97 sec*proc (9 tests)
vulkan             = 176.65 sec*proc (26 tests)
workgroup          = 472.82 sec*proc (31 tests)

Total Test time (real) = 3791.39 sec

The following tests did not run:
         62 - kernel/test_shuffle_half_loopvec (Skipped)
         63 - kernel/test_shuffle_half_cbs (Skipped)
        190 - runtime/clGetKernelArgInfo (Disabled)
        199 - runtime/test_buffer_migration (Skipped)
        200 - runtime/test_buffer_ping_pong (Skipped)

The following tests FAILED:
         76 - kernel/test_printf_vectors_loopvec (Failed)
         77 - kernel/test_printf_vectors_cbs (Failed)
         78 - kernel/test_printf_vectors_ulongn_loopvec (Failed)
         79 - kernel/test_printf_vectors_ulongn_cbs (Failed)
Errors while running CTest
```

Obviously these tests failed was due to vectors missing from riscv64
now. This is expected I think.

The result is aligned with pocl upstream support riscv64:

```
In this release we improved support for RISC-V CPUs. We tested PoCL on a Starfive VisionFive 2 using a Ubuntu 23.10 preinstalled image. With LLVM 17 and GCC 13.2, 98% tests pass (only 4 tests fail out of 253).

```
http://portablecl.org/docs/html/notes_5_0.html#risc-v-cpu-support-improved

If glance at the buildd log from riscv64:

```
-- udivmodti4 compiles without extra flags
-- Checking if LLVM is a DEBUG build
-- DEBUG build
-- Find out LLC target triple (for host riscv64-unknown-linux-gnu)
-- Find out LLC host CPU with /usr/bin/llc-15
-- Autodetected CPU sifive-u74 overridden by user to GENERIC
-- Checking clang -march vs. -mcpu flag
--   Using -None=
-- Running LLVM link test
-- LLVM link test OK
```
https://buildd.debian.org/status/fetch.php?pkg=pocl&arch=riscv64&ver=5.0-1&stamp=1704805199&raw=0

So I suspect the `LLC_HOST_CPU='` was overriden by `GENERIC` then the
ABI was different. I will look at this more deeper.

#1059511#29
Date:
2024-01-18 09:41:28 UTC
From:
To:
If these tests are expected to fail, they should be annotated as such
for riscv64 (see e.g. handing of kernel/test_printf_vectors in
tests/kernel/CMakeLists.txt). Is there an upstream bug about these tests
failing on risc-v?

printf is a mess on most architectures (even or especially also x86)
since the ABI for passing the variadic parameters is not well defined,
especially when it comes to OpenCL vector types.
(i.e. without specifying -march=$whatever), s.t. the generated code
targets the riscv64 baseline (like all code in Debian binary packages).
(Assuming llvm targets the same baseline cpu architecture as gcc, which
unfortunately is not true for all Debian architectures.)
(By default upstream pocl wants to build for the native CPU which is a
no-go for distributing binaries. In order to fully utilize capabilities
for more modern CPUs (e.g. wider SIMD registers), pocl has a distro mode
where the bitcode libraries are provided for multiple targets and the
best one for the local CPU is selected at runtime. But first we should
get a baseline build for risc-v before we look into optimizing it (i.e.
supporting separately both CPUs without and with vector unit).

Andreas

PS: I'll look into switching pocl to llvm-16 now

#1059511#34
Date:
2024-01-21 04:35:22 UTC
From:
To:
Hi,
https://github.com/pocl/pocl/issues/1394

So we need to enable to select the best one for local CPU when runtime
for riscv64 here. I looked at the patch:
https://salsa.debian.org/opencl-team/pocl/-/blob/main/debian/patches/generic-cpu.patch?ref_type=heads
But I am not sure how to enable this.

The baseline of riscv64 port here is here:
```
The Debian port uses RV64GC as the hardware baseline and the lp64d ABI
(the default ABI for RV64G systems)
```
https://wiki.debian.org/RISC-V#Hardware_baseline_and_ABI_choice

Is this enough information? Please let me know of any issues or I can
do some experiment about this.

BR,
Bo

#1059511#39
Date:
2024-09-28 20:27:59 UTC
From:
To:
The double-float/soft-float issue has been solved in pocl 6.0

That leaves us (when using llvm-17) with

64% tests passed, 94 tests failed out of 264

The following tests FAILED:
	  7 - kernel/test_convert_type_1_loopvec (Failed)
	  8 - kernel/test_convert_type_1_cbs (Failed)
	  9 - kernel/test_convert_type_2_loopvec (Failed)
	 10 - kernel/test_convert_type_2_cbs (Failed)
	 11 - kernel/test_convert_type_4_loopvec (Failed)
	 12 - kernel/test_convert_type_4_cbs (Failed)
	 13 - kernel/test_convert_type_8_loopvec (Failed)
	 14 - kernel/test_convert_type_8_cbs (Failed)
	 15 - kernel/test_convert_type_16_loopvec (Failed)
	 16 - kernel/test_convert_type_16_cbs (Failed)
	 22 - kernel/test_min_max_loopvec (Failed)
	 23 - kernel/test_min_max_cbs (Failed)
	 24 - kernel/test_length_distance_loopvec (Failed)
	 25 - kernel/test_length_distance_cbs (Failed)
	 26 - kernel/test_fmin_fmax_fma_loopvec (Failed)
	 27 - kernel/test_fmin_fmax_fma_cbs (Failed)
	 34 - kernel/test_fabs_loopvec (Failed)
	 35 - kernel/test_fabs_cbs (Failed)
	 36 - kernel/test_copy_signbit_loopvec (Failed)
	 37 - kernel/test_copy_signbit_cbs (Failed)
	 38 - kernel/test_ilogb_loopvec (Failed)
	 39 - kernel/test_ilogb_cbs (Failed)
	 40 - kernel/test_ldexp_loopvec (Failed)
	 41 - kernel/test_ldexp_cbs (Failed)
	 42 - kernel/test_isnan_loopvec (Failed)
	 43 - kernel/test_isnan_cbs (Failed)
	 46 - kernel/test_frexp_modf_loopvec (Failed)
	 47 - kernel/test_frexp_modf_cbs (Failed)
	 48 - kernel/test_sampler_address_clamp_loopvec (Failed)
	 49 - kernel/test_sampler_address_clamp_cbs (Failed)
	 50 - kernel/test_image_query_funcs_loopvec (Failed)
	 51 - kernel/test_image_query_funcs_cbs (Failed)
	 76 - kernel/test_printf_vectors_loopvec (Failed)
	 77 - kernel/test_printf_vectors_cbs (Failed)
	 78 - kernel/test_printf_vectors_ulongn_loopvec (Failed)
	 79 - kernel/test_printf_vectors_ulongn_cbs (Failed)
	 94 - regression/test_workitem_func_outside_kernel_loopvec (Failed)
	 95 - regression/test_workitem_func_outside_kernel_cbs (Failed)
	 96 - regression/test_program_scope_vars (Subprocess aborted)
	 97 - regression/test_llvm_segfault_issue_889_loopvec (Failed)
	 98 - regression/test_llvm_segfault_issue_889_cbs (Failed)
	 99 - regression/test_issue_893_loopvec (Failed)
	100 - regression/test_issue_893_cbs (Failed)
	103 - regression/phi_nodes_not_replicated_loopvec (Failed)
	104 - regression/phi_nodes_not_replicated_cbs (Failed)
	105 - regression/phi_nodes_not_replicated_repl (Failed)
	106 - regression/issues_with_local_pointers_loopvec (Failed)
	107 - regression/issues_with_local_pointers_cbs (Failed)
	108 - regression/issues_with_local_pointers_repl (Failed)
	109 - regression/barrier_between_two_for_loops_loopvec (Failed)
	110 - regression/barrier_between_two_for_loops_cbs (Failed)
	111 - regression/barrier_between_two_for_loops_repl (Failed)
	112 - regression/simple_for-loop_with_a_barrier_inside_loopvec (Failed)
	113 - regression/simple_for-loop_with_a_barrier_inside_cbs (Failed)
	114 - regression/simple_for-loop_with_a_barrier_inside_repl (Failed)
	115 - regression/for-loop_with_computation_after_the_brexit_loopvec (Failed)
	116 - regression/for-loop_with_computation_after_the_brexit_cbs (Failed)
	117 - regression/for-loop_with_computation_after_the_brexit_repl (Failed)
	118 - regression/for-loop_with_a_variable_iteration_count_loopvec (Failed)
	119 - regression/for-loop_with_a_variable_iteration_count_cbs (Failed)
	120 - regression/for-loop_with_a_variable_iteration_count_repl (Failed)
	121 - regression/early_return_before_a_barrier_region_loopvec (Failed)
	122 - regression/early_return_before_a_barrier_region_cbs (Failed)
	123 - regression/early_return_before_a_barrier_region_repl (Failed)
	124 - regression/id-dependent_computation_before_kernel_exit_loopvec (Failed)
	125 - regression/id-dependent_computation_before_kernel_exit_cbs (Failed)
	126 - regression/id-dependent_computation_before_kernel_exit_repl (Failed)
	127 - regression/barrier_just_before_return_loopvec (Failed)
	128 - regression/barrier_just_before_return_cbs (Failed)
	129 - regression/barrier_just_before_return_repl (Failed)
	133 - regression/undominated_variable_from_conditional_barrier_handling_loopvec (Failed)
	134 - regression/undominated_variable_from_conditional_barrier_handling_cbs (Failed)
	135 - regression/undominated_variable_from_conditional_barrier_handling_repl (Failed)
	161 - regression/test_alignment_with_dynamic_wg2_loopvec (Failed)
	162 - regression/test_alignment_with_dynamic_wg2_cbs (Failed)
	165 - regression/setting_a_buffer_argument_to_NULL_causes_a_segfault_loopvec (Failed)
	166 - regression/setting_a_buffer_argument_to_NULL_causes_a_segfault_cbs (Failed)
	175 - regression/struct_kernel_arguments_loopvec (Failed)
	176 - regression/struct_kernel_arguments_cbs (Failed)
	247 - examples/example1_dot_product (Subprocess aborted)
	248 - examples/example1_poclbin (Failed)
	253 - examples/matrix1 (Subprocess aborted)
	254 - examples/matrix1_local (Subprocess aborted)
	255 - examples/matrix1_poclbin (Failed)
	256 - poclcc (Subprocess aborted)
	257 - examples/scalarwave_loopvec (Failed)
	258 - examples/scalarwave_cbs (Failed)
	259 - examples/trig (Subprocess aborted)
	260 - examples/vecadd (Subprocess aborted)
	261 - examples/vecadd_large_grid (Subprocess aborted)
	262 - examples/matadd (Subprocess aborted)
	263 - examples/boxadd (Subprocess aborted)
	264 - EinsteinToolkit (Subprocess aborted)
	265 - EinsteinToolkit_SubDev (Subprocess aborted)

I've just uploaded pocl building against llvm-18 to unstable
and plan to upload a snapshot (using -18, too) to experimental soon.
Thereafter might be a good time to further investigate pocl on riscv64.

Andreas