Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-12-01 Thread Andreas Beckmann
On 11/19/20 3:39 PM, Andreas Beckmann wrote:
> POCL built against LLVM 10 (sid) or LLVM 11 (experimental) causes a 
> autopkgtest regression on armhf in libgpuarray while it succeeded with 
> LLVM 9.

I finally managed to create a plain c reproducer (based on some pocl
test) which dies with this backtrace on abel.d.o:

#0  getEmissionKind () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/include/llvm/IR/DebugInfoMetadata.h:1244
#1  initialize () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LexicalScopes.cpp:53
#2  0xb13a82f0 in computeIntervals () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:979
#3  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:996
#4  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:1023
#5  0xb141d6c8 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/MachineFunctionPass.cpp:73
#6  0xb1297494 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1481
#7  0xb1297750 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1517
#8  0xb1297ba8 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1582
#9  run () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1694
#10 0xb6dfac82 in pocl_llvm_codegen (Device=Device@entry=0x1a3dfc8, 
Modp=0x20102d8, Output=Output@entry=0xbe9be8bc, 
OutputSize=OutputSize@entry=0xbe9be8d0) at ./lib/CL/pocl_llvm_wg.cc:624
#11 0xb6dbf1de in llvm_codegen (output=output@entry=0x1be75e0 
"/home/anbe/.cache/pocl/kcache/AP/PNFEAPBKBFEAKGGNMALGHGJEEKGMJFBFBMDHA/Sdot_kernel/0-0-0/Sdot_kernel.so",
 device_i=device_i@entry=0, kernel=kernel@entry=0xbe9c0290, device=0x1a3dfc8, 
command=command@entry=0xbe9c02c8, specialize=specialize@entry=0) at 
./lib/CL/devices/common.c:158
#12 0xb6dc0e44 in pocl_check_kernel_disk_cache 
(command=command@entry=0xbe9c02c8, specialized=specialized@entry=0) at 
./lib/CL/devices/common.c:958
#13 0xb6dc1262 in pocl_check_kernel_dlhandle_cache (command=0xbe9c02c8, 
initial_refcount=0, specialize=0) at ./lib/CL/devices/common.c:1081
#14 0xb6d993d4 in program_compile_dynamic_wg_binaries 
(program=program@entry=0x1a18350) at ./lib/CL/pocl_build.c:179
#15 0xb6da9f20 in get_binary_sizes (sizes=0xbe9c03d4, program=0x1a18350) at 
./lib/CL/clGetProgramInfo.c:36
#16 POclGetProgramInfo (program=0x1a18350, param_name=4453, 
param_value_size=128, param_value=0xbe9c03d4, param_value_size_ret=0xbe9c03d0) 
at ./lib/CL/clGetProgramInfo.c:115
#17 0x0045a070 in main () at 975931.c:238

I expect pocl built against llvm 11 (experimental) to fail similarily.
pocl built against llvm 9 (testing) passes.

Sylvestre, could you check whether this is an error on the LLVM side
or is POCL using LLVM incorrectly?


Andreas
#define CL_TARGET_OPENCL_VERSION 220

#include 
#include 
#include 
#include 

const char source[] =
"#ifdef DOUBLE_PRECISION\n"
"#ifdef cl_khr_fp64\n"
"#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"
"#else\n"
"#pragma OPENCL EXTENSION cl_amd_fp64 : enable\n"
"#endif\n"
"#endif\n"
"\n"
"__kernel void Sdot_kernel( __global float *_X, __global float *_Y, __global float *scratchBuff,\n"
"uint N, uint offx, int incx, uint offy, int incy, int doConj )\n"
"{\n"
"__global float *X = _X + offx;\n"
"__global float *Y = _Y + offy;\n"
"float dotP = (float) 0.0;\n"
"\n"
"if ( incx < 0 ) {\n"
"X = X + (N - 1) * abs(incx);\n"
"}\n"
"if ( incy < 0 ) {\n"
"Y = Y + (N - 1) * abs(incy);\n"
"}\n"
"\n"
"int gOffset;\n"
"for( gOffset=(get_global_id(0) * 4); (gOffset + 4 - 1) 0);

  CHECK_CL_ERROR(clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, ));
  TEST_ASSERT(ndevices > 0);

  cl_context context = clCreateContext(NULL, 1, devices, NULL, NULL, );
  CHECK_OPENCL_ERROR_IN("clCreateContext");

  const char * src[] = {source};
  program = clCreateProgramWithSource(context, 1, src, NULL, );
  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");

  CHECK_CL_ERROR(clBuildProgram(program, 1, devices, "-g -DINCX_NONUNITY -DINCY_NONUNITY", NULL, NULL));

  CHECK_CL_ERROR(clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(binsizes), binsizes, ));
  printf("binary size: %zd\n", binsizes[0]);

  CHECK_CL_ERROR(clReleaseProgram(program));

  CHECK_CL_ERROR (clReleaseContext (context));

  printf ("OK\n");

  return EXIT_SUCCESS;
}


Bug#974797: [Pkg-opencl-devel] Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-11-20 Thread Andreas Beckmann
On 11/19/20 11:20 PM, Rebecca N. Palmer wrote:
> This isn't testable in a qemu-armhf chroot, as pocl doesn't work there.

It works for me in a armhf pbuilder chroot driven via qemu-user-static 
on an amd64 host.

Trying to reproduce on abel.d.o, a real armhf porterbox:

* install in the chroot:
pocl-opencl-icd libpocl2-dbgsym libllvm10-dbgsym libclblas2-dbgsym 
libgpuarray3-dbgsym libc6-dbg python3-nose python3-pygpu-dbg python3-scipy 
libclblas-dev gdb

$ ulimit -c unlimited

$ DEVICE=opencl0:0 python3.9 -m nose -v pygpu.tests.test_blas
*** Testing for pthread-0x584
pygpu.tests.test_blas.test_dot(1, 'float32', True, True, True, False) ... 
Segmentation fault (core dumped)

$ gdb /usr/bin/python3.9 core

[...]
bt
#0  getEmissionKind () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/include/llvm/IR/DebugInfoMetadata.h:1244
#1  initialize () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LexicalScopes.cpp:53
#2  0xafa922f0 in computeIntervals () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:979
#3  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:996
#4  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:1023
#5  0xafb076c8 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/MachineFunctionPass.cpp:73
#6  0xaf981494 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1481
#7  0xaf981750 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1517
#8  0xaf981ba8 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1582
#9  run () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1694
#10 0xb54e4c82 in pocl_llvm_codegen (Device=Device@entry=0x1cdea20, 
Modp=0x4b88240, Output=Output@entry=0xbee61784, 
OutputSize=OutputSize@entry=0xbee61798) at ./lib/CL/pocl_llvm_wg.cc:624
#11 0xb54a91de in llvm_codegen (output=output@entry=0x4b7f530 
"/home/anbe/.cache/pocl/kcache/LE/ELACJMEDJOLOPBPKFGKJKDCIPBPEMINDFHLHI/Sdot_kernel/0-0-0/Sdot_kernel.so",
 device_i=device_i@entry=0, kernel=kernel@entry=0xbee63158, device=0x1cdea20, 
command=command@entry=0xbee63190, specialize=specialize@entry=0) at 
./lib/CL/devices/common.c:158
#12 0xb54aae44 in pocl_check_kernel_disk_cache 
(command=command@entry=0xbee63190, specialized=specialized@entry=0) at 
./lib/CL/devices/common.c:958
#13 0xb54ab262 in pocl_check_kernel_dlhandle_cache (command=0xbee63190, 
initial_refcount=0, specialize=0) at ./lib/CL/devices/common.c:1081
#14 0xb54833d4 in program_compile_dynamic_wg_binaries 
(program=program@entry=0x460d1e0) at ./lib/CL/pocl_build.c:179
#15 0xb5493f20 in get_binary_sizes (sizes=0xbee63288, program=0x460d1e0) at 
./lib/CL/clGetProgramInfo.c:36
#16 POclGetProgramInfo (program=0x460d1e0, param_name=4453, param_value_size=4, 
param_value=0xbee63288, param_value_size_ret=0x0) at 
./lib/CL/clGetProgramInfo.c:115
#17 0xa1ea1722 in getSingleBinaryFromProgram (binary=std::vector of length 0, 
capacity 0, program=0x460d1e0) at 
./src/library/blas/generic/binary_lookup.cc:392
#18 BinaryLookup::populateCache (this=this@entry=0xbee63308) at 
./src/library/blas/generic/binary_lookup.cc:466
#19 0xa1e9d738 in makeKernelCached (device=0x1cdea20, context=0x1cdf230, 
sid=sid@entry=320, key=key@entry=0xbee6348c, 
kernelGenerator=kernelGenerator@entry=0xa1ec8ad9 , 
dims=0x440e670, pgran=pgran@entry=0x440e6ac, extra=extra@entry=0xbee634d4, 
buildOpts=buildOpts@entry=0xbee6372c "-g -DINCX_NONUNITY -DINCY_NONUNITY", 
error=error@entry=0xbee63410) at ./src/library/blas/generic/common2.cc:90
#20 0xa1ea0662 in makeSolutionSeq (funcID=funcID@entry=CLBLAS_DOT, 
args=args@entry=0xbee639f0, numCommandQueues=numCommandQueues@entry=1, 
commandQueues=commandQueues@entry=0x1a2aee0, 
numEventsInWaitList=numEventsInWaitList@entry=0, 
eventWaitList=eventWaitList@entry=0x0, events=events@entry=0xbee63894, 
seq=seq@entry=0xbee63898) at ./src/library/blas/generic/solution_seq_make.c:587
#21 0xa1e8c9b6 in doDot (kargs=kargs@entry=0xbee639f0, N=1, 
dotProduct=, offDP=0, X=0x1d4c118, offx=1, incx=2, Y=0x43d7f90, 
offy=1, incy=2, scratchBuff=0x440e370, doConj=0, numCommandQueues=1, 
commandQueues=0x1a2aee0, numEventsInWaitList=0, 
eventWaitList=0x0, events=0xbee63b44) at ./src/library/blas/xdot.c:132
#22 0xa1e8cac8 in clblasSdot (N=, dotProduct=, 
offDP=, X=0x1d4c118, offx=1, incx=2, Y=0x43d7f90, offy=1, 
incy=2, scratchBuff=0x440e370, numCommandQueues=1, commandQueues=0x1a2aee0, 
numEventsInWaitList=0, 
eventWaitList=0x0, events=0xbee63b44) at ./src/library/blas/xdot.c:193
#23 0xb62314c2 in sdot (N=, X=0x1d3ce20, offX=1, incX=2, 

Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-11-19 Thread Rebecca N. Palmer

(libgpuarray maintainer)

This isn't testable in a qemu-armhf chroot, as pocl doesn't work there.

Do all the non-clblas tests pass?  (This can be checked by uninstalling 
libclblas-dev then running the tests - this will "error" the clblas 
tests but should at least not crash them.)


On 19/11/2020 14:39, Andreas Beckmann wrote:

It terminates with a segmentation fault in LLVM.


This is potentially an *LLVM* bug, as invalid input source code 
shouldn't crash the compiler, but that's less clear-cut when the 
compiler is being called as a library.


If it is, it doesn't seem to be known: there are no upstream LLVM bugs 
with this backtrace.



The CL kernel is a piece of generated source code created by the
(simplified) stack: python - libgpuarray - libclblas before it gets
handed over to pocl. While I managed to extract the CL kernel source, I


That's as expected.  Can you post this kernel source here?


#0  getEmissionKind () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/include/llvm/IR/DebugInfoMetadata.h:1244
#1  initialize () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LexicalScopes.cpp:53


Did you have libllvm10-dbgsym installed?  If not, does installing that 
give a more detailed backtrace?  (I suspect an invalid 'this', given 
that the crashing line accesses only a class member.)




Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-11-19 Thread Andreas Beckmann
POCL built against LLVM 10 (sid) or LLVM 11 (experimental) causes a 
autopkgtest regression on armhf in libgpuarray while it succeeded with 
LLVM 9.
https://ci.debian.net/packages/libg/libgpuarray/testing/armhf/
(The autopkgtest cannot be run in pure testing due to missing RC-buggy
libclblas, it only works (and previously passed) in sid (or rather
testing+sid). There are no problems on x86)

The failing test can be called with

POCL_CACHE_DIR=$(mktemp -d)/pocl-cache \
DEVICE=opencl0:0 python3.9 -m nose -v pygpu.tests.test_blas

It terminates with a segmentation fault in LLVM.

The CL kernel is a piece of generated source code created by the
(simplified) stack: python - libgpuarray - libclblas before it gets
handed over to pocl. While I managed to extract the CL kernel source, I
couldn't produce an OpenCL program that builds the kernel in the same
way s.t. it triggers the segmentation fault.

Backtraces from coredumps:

#0  getEmissionKind () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/include/llvm/IR/DebugInfoMetadata.h:1244
#1  initialize () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LexicalScopes.cpp:53
#2  0xf827f2f0 in computeIntervals () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:979
#3  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:996
#4  runOnMachineFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/LiveDebugVariables.cpp:1023
#5  0xf82f46c8 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/CodeGen/MachineFunctionPass.cpp:73
#6  0xf816e494 in runOnFunction () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1481
#7  0xf816e750 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1517
#8  0xf816eba8 in runOnModule () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1582
#9  run () at 
/build/llvm-toolchain-10-hVI0Qp/llvm-toolchain-10-10.0.1/llvm/lib/IR/LegacyPassManager.cpp:1694
#10 0xfdcd2446 in pocl_llvm_codegen (Device=Device@entry=0x839f60, 
Modp=0x321bdc0, Output=Output@entry=0xfffea5b4, 
OutputSize=OutputSize@entry=0xfffea5c8) at ./lib/CL/pocl_llvm_wg.cc:624
#11 0xfdc9669e in llvm_codegen (output=output@entry=0x3763c40 
"/tmp/tmp.hvljjDK8aD/pocl-cache/EG/BKJEEKFFENDHPDCNOBDADIAOJNAPPBJKDBOEM/Sdot_kernel/0-0-0/Sdot_kernel.so",
 device_i=device_i@entry=0, kernel=kernel@entry=0xfffebf88, device=0x839f60, 
command=command@entry=0xfffebfc0, specialize=specialize@entry=0) at 
./lib/CL/devices/common.c:158
#12 0xfdc98304 in pocl_check_kernel_disk_cache 
(command=command@entry=0xfffebfc0, specialized=specialized@entry=0) at 
./lib/CL/devices/common.c:958
#13 0xfdc98722 in pocl_check_kernel_dlhandle_cache (command=0xfffebfc0, 
initial_refcount=0, specialize=0) at ./lib/CL/devices/common.c:1081
#14 0xfdc70534 in program_compile_dynamic_wg_binaries 
(program=program@entry=0x31af008) at ./lib/CL/pocl_build.c:179
#15 0xfdc8153c in get_binary_sizes (sizes=0xfffec0b8, program=0x31af008) at 
./lib/CL/clGetProgramInfo.c:36
#16 POclGetProgramInfo (program=0x31af008, param_name=, 
param_value_size=4, param_value=0xfffec0b8, param_value_size_ret=0x0) at 
./lib/CL/clGetProgramInfo.c:116
#17 0xcaf53722 in getSingleBinaryFromProgram (binary=std::vector of length 0, 
capacity 0, program=0x31af008) at 
./src/library/blas/generic/binary_lookup.cc:392
#18 BinaryLookup::populateCache (this=this@entry=0xfffec138) at 
./src/library/blas/generic/binary_lookup.cc:466
#19 0xcaf4f738 in makeKernelCached (device=0x839f60, context=0x820cd0, 
sid=sid@entry=320, key=key@entry=0xfffec2bc, 
kernelGenerator=kernelGenerator@entry=0xcaf7aad9 , 
dims=0x2fb03d0, pgran=pgran@entry=0x2fb040c, extra=extra@entry=0xfffec304, 
buildOpts=buildOpts@entry=0xfffec55c "-g -DINCX_NONUNITY -DINCY_NONUNITY", 
error=error@entry=0xfffec240) at ./src/library/blas/generic/common2.cc:90
#20 0xcaf52662 in makeSolutionSeq (funcID=funcID@entry=CLBLAS_DOT, 
args=args@entry=0xfffec820, numCommandQueues=numCommandQueues@entry=1, 
commandQueues=commandQueues@entry=0x635598, 
numEventsInWaitList=numEventsInWaitList@entry=0, 
eventWaitList=eventWaitList@entry=0x0, events=events@entry=0xfffec6c4, 
seq=seq@entry=0xfffec6c8) at ./src/library/blas/generic/solution_seq_make.c:587
#21 0xcaf3e9b6 in doDot (kargs=kargs@entry=0xfffec820, N=1, 
dotProduct=, offDP=0, X=0xe2afe8, offx=1, incx=2, Y=0xab71a8, 
offy=1, incy=2, scratchBuff=0x9d7ff0, doConj=0, numCommandQueues=1, 
commandQueues=0x635598, numEventsInWaitList=0, 
eventWaitList=0x0, events=0xfffec974) at ./src/library/blas/xdot.c:132
#22 0xcaf3eac8 in clblasSdot (N=, dotProduct=, 
offDP=, X=0xe2afe8, offx=1, incx=2, Y=0xab71a8, offy=1, incy=2, 
scratchBuff=0x9d7ff0, 

Bug#974797: [Pkg-opencl-devel] Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-11-15 Thread Andreas Beckmann
Control: tag -1 upstream fixed-upstream

seems to be fixed upstream, but no new release yet

Andreas



Bug#974797: pocl: Please upgrade to llvm-toolchain-11

2020-11-14 Thread Sylvestre Ledru
Package: pocl
Severity: normal

Dear Maintainer,

As part of the effort to limit the number of llvm packages in the 
archive, please upgrade to -11.

Thanks,
Sylvestre