Bug 94823 - Segfault at CommandQueue generation
Summary: Segfault at CommandQueue generation
Status: RESOLVED FIXED
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: Xiuli Pan
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-04 16:59 UTC by charles
Modified: 2016-05-11 01:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
example file for reproducible error (4.49 KB, text/plain)
2016-04-04 16:59 UTC, charles
Details

Description charles 2016-04-04 16:59:59 UTC
Created attachment 122706 [details]
example file for reproducible error

I have come across a segmentation fault where I am trying to run a simple integer matrix multiplication using beignet and the OpenCL C++ API.

The error is currently reproducible on the following platform information:

Hardware = Lenovo t440p
OS = Debian GNU/Linux testing
GPU = Intel(R) HD Graphics Haswell GT2 Mobile
Beignet Version = 1.1.1 (installed from apt-get install beignet-dev)
OpenCL Headers = cl2.hpp (installed from apt-get install opencl-headers)

Compile the program with:

g++ opencl_test.cpp -o opencl_test -I/usr/include/eigen3 -DHAVE_CL2 -lOpenCL -std=c++11
./opencl_test 

which has been resulting in the following output:

 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
got platforms
selected default platform
Context Made
Device Found
Segmentation fault
Comment 1 Xiuli Pan 2016-04-28 07:50:54 UTC
Hi Charles,

It seems the problem is about the cl2.hpp, the release v1.1.1 does not support OpenCL2.0 API. Maybe you need a -DCL_HPP_TARGET_OPENCL_VERSION=120 as a compile option.

Could you give us the backtrace to confirm that?

Thanks
Xiuli
Comment 2 charles 2016-04-28 14:54:27 UTC
Hi Xiuli,

I am unfortunately working through this bug via a kind user who is able to reproduce this problem.  Do you have a proposed method that you prefer to get the backtrace?  gdb? valgrind? other method?

If you have any specific instructions I can contact the user and return the output to you.

Thanks,
Charles
Comment 3 Xiuli Pan 2016-04-29 05:00:41 UTC
Hi charles,

GBD with bt(backtrace) is fine.

Thanks
Xiuli
Comment 4 charles 2016-05-03 16:51:44 UTC
Here are the results from the backtrace

(gdb) r
Starting program: /home/Hornik/tmp/WWW/opencl_test
 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
got platforms
selected default platform
Context Made
Device Found

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) backtrace
#0  0x0000000000000000 in ?? ()
#1  0x0000000000404ba6 in cl::CommandQueue::CommandQueue (this=0x7fffffffdec0,
    context=..., device=..., properties=0, err=0x7fffffffe058)
    at /usr/include/CL/cl2.hpp:6833
#2  0x0000000000402dad in main () at opencl_test.cpp:96
Comment 5 Xiuli Pan 2016-05-04 02:41:32 UTC
Hi charles,

It seems to be the cl2.hpp called some api that only OpenCL 2.0 supported.
For beignet releasev1.1.1, it only support OpenCL 1.2 api. If you want to use beignet with the cl2.hpp please use -DCL_HPP_TARGET_OPENCL_VERSION=120 with -DHAVE_CL2 or just try to use cl.hpp.

In short, beignet 1.1.1 does not have those api cl2.hpp needed, use cl.hpp instead.

Thanks
Xiuli
Comment 6 charles 2016-05-04 12:13:49 UTC
Thanks for looking into this.  That said, is there a timeline for beignet to accept OpenCL 2.0?
Comment 7 Xiuli Pan 2016-05-05 03:08:41 UTC
(In reply to charles from comment #6)
> Thanks for looking into this.  That said, is there a timeline for beignet to
> accept OpenCL 2.0?

Could it work with OpenCL 1.2? If problem solved I'd like to close this bug.
For OpenCL 2.0 we are still working on it.

Thanks
Xiuli
Comment 8 charles 2016-05-09 13:10:02 UTC
It appears this didn't solve the problem.  The compiler complains about a minimum opencl version.

$ g++ opencl_test.cpp -o opencl_test -g -I/usr/include/eigen3 -lOpenCL -std=c++11 -DCL_HPP_TARGET_OPENCL_VERSION=120
In file included from opencl_test.cpp:11:0:
/usr/include/CL/cl2.hpp:407:3: error: #error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_O
Comment 9 Xiuli Pan 2016-05-10 03:35:53 UTC
Hi charles,

I have tried the exact case you provide, the problem is still about the cl2.hpp. For beignet-dev from apt-get it only support OpenCL 1.2 api.
So you must pass the exact option to enable only OpenCL 1.2 api.
I have used this to build and can run (maybe need to delete the cout in line 8)
g++ test.cpp -o opencl_test -g -I/usr/include/eigen3 -lOpenCL -std=c++11 -DHAVE_CL2 -DCL_HPP_TARGET_OPENCL_VERSION=120 -DCL_HPP_MINIMUM_OPENCL_VERSION=120

Please have a try, thanks!

The result:
./opencl_test
 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
 1  2  3  4
 5  6  7  8
 9 10 11 12
13 14 15 16
got platforms
selected default platform
Context Made
Device Found
Command Queue created
Program created
Program Built
Kernel made
Buffers initialized
Buffers written
kernel completed
Completed Buffer Read
Result
 90 100 110 120
202 228 254 280
314 356 398 440
426 484 542 600


Thanks
Xiuli
Comment 10 charles 2016-05-10 12:56:26 UTC
Xiuli,

The additional -DCL_HPP_MINIMUM_OPENCL_VERSION flag did in fact fix the problem.  It now compiles and runs without problem.  Thanks for your help.

Regards,
Charles
Comment 11 Xiuli Pan 2016-05-11 01:55:52 UTC
OK, I will close this bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.