[Beignet] [PATCH] add introduction to build Beignet with yocto

Guo, Yejun yejun.guo at intel.com
Mon May 11 19:04:54 PDT 2015


It is verified by another project using yocto, it would be nice if someone can help to test it independently. 

Another option is to upstream first, and to refine it according to feedback.

-----Original Message-----
From: Zhigang Gong [mailto:zhigang.gong at linux.intel.com] 
Sent: Tuesday, May 12, 2015 8:01 AM
To: Guo, Yejun
Cc: beignet at lists.freedesktop.org
Subject: Re: [Beignet] [PATCH] add introduction to build Beignet with yocto

Yejun thanks for the patch. It looks good, but it's better to get some one help to test this method on Yocto.

On Mon, May 11, 2015 at 01:53:49PM +0800, Guo Yejun wrote:
> Signed-off-by: Guo Yejun <yejun.guo at intel.com>
> ---
>  docs/Beignet.mdwn                    |  2 +-
>  docs/howto/cross-compiler-howto.mdwn | 75 
> ++++++++++++++++++++++++++++++++++--
>  2 files changed, 73 insertions(+), 4 deletions(-)
> 
> diff --git a/docs/Beignet.mdwn b/docs/Beignet.mdwn index 
> 90a00e5..ec528b5 100644
> --- a/docs/Beignet.mdwn
> +++ b/docs/Beignet.mdwn
> @@ -289,7 +289,7 @@ by running the beignet's unit test.
>  
>  Documents for OpenCL application developers
>  -------------------------------------------
> -- [[Cross compile|Beignet/howto/cross-compiler-howto]]
> +- [[Cross compile (yocto)|Beignet/howto/cross-compiler-howto]]
>  - [[Work with old system without c++11|Beignet/howto/oldgcc-howto]]
>  - [[Kernel Optimization Guide|Beignet/optimization-guide]]
>  - [[Libva Buffer Sharing|Beignet/howto/libva-buffer-sharing-howto]]
> diff --git a/docs/howto/cross-compiler-howto.mdwn 
> b/docs/howto/cross-compiler-howto.mdwn
> index 535cd9a..d541816 100644
> --- a/docs/howto/cross-compiler-howto.mdwn
> +++ b/docs/howto/cross-compiler-howto.mdwn
> @@ -7,6 +7,8 @@ and OpenCL kernels for a target machine 
> (embedded/handheld devices) in a  host machine with the help of cross 
> compiler, and also the large-size-reduced  Beignet driver package for the target machine.
>  
> +Key part of yocto receipt is shown as an example.
> +
>  Build Beignet with a cross compiler
>  -----------------------------------
>  
> @@ -17,6 +19,10 @@ configure Beignet with cmake.
>    Beignet depends on llvm+clang, this option refers to the path of llvm-config,
>    llvm-as, llvm-link and clang in the cross compiler environment.
>  
> +  Please ensure that llvm-config, llvm-as, llvm-link and clang are in 
> + the same  directory. Please also make sure 'your_llvm_install_dir/llvm-config --libdir'
> +  and 'your_llvm_install_dir/llvm-config --includedir' print the right output.
> +
>  - CMAKE_SKIP_RPATH
>    Some cross compiler systems forbid the usage of rpath in binaries/libraries,
>    set this option to be TRUE.
> @@ -26,8 +32,30 @@ configure Beignet with cmake.
>    of Intel Ivybridge GPU, and 0x0f31 is Intel Baytrail GPU. The information can
>    be queried with command 'lspci -n'.
>  
> -- CMAKE_INSTALL_PREFIX
> -  This option controls the prefix of installation path.
> +- CMAKE_INSTALL_PREFIX and BEIGNET_INSTALL_DIR
> +  These two options control the installation path.
> +
> +
> +To build Beignet with yocto, the receipt looks like:
> +
> +S = "${WORKDIR}/git"
> +BEIGNET_BUILD_DIR = "${S}/build"
> +do_configure() {
> +    mkdir -p ${BEIGNET_BUILD_DIR}
> +    cd ${BEIGNET_BUILD_DIR}
> +    cmake \
> +        .. \
> +        -DLLVM_INSTALL_DIR=${TMPDIR}/sysroots/baytraili/usr/bin/ \
> +        -DCMAKE_INSTALL_PREFIX=/usr/ \
> +        -DBEIGNET_INSTALL_DIR=/usr/lib/ \
> +        -DCMAKE_SKIP_RPATH=TRUE \
> +        -DGEN_PCI_ID=0x0f31
> +}
> +do_compile() {
> +    cd ${BEIGNET_BUILD_DIR}
> +    oe_runmake
> +}
> +
>  
>  Distribution of large-size-reduced Beignet driver package
>  ---------------------------------------------------------
> @@ -37,7 +65,48 @@ provide only the OpenCL runtime library without 
> OpenCL compiler, and only the  executable binary kernel is supported on such devices.
>  
>  It means that just distribute libcl.so and libgbeinterp.so (~320k in 
> total after strip) -are enough for OpenCL embeded profile in the target machine.
> +are enough for OpenCL embeded profile in the target machine. The 
> +whole Beignet driver set can be separated into several packages for different usage.
> +
> +
> +Take yocto as an example, the receipt looks like:
> +SYSROOT_PREPROCESS_FUNCS += "beignet_sysroot_preprocess"
> +beignet_sysroot_preprocess() {
> +    install -d ${SYSROOT_DESTDIR}${bindir}
> +    install -m 0755 
> +${BEIGNET_BUILD_DIR}/backend/src/gbe_bin_generater 
> +${SYSROOT_DESTDIR}${bindir} }
> +do_install() {
> +    cd ${BEIGNET_BUILD_DIR}
> +    oe_runmake DESTDIR=${D} install
> +
> +    #install OpenCL offline compiler
> +    install -d ${D}${bindir}
> +    install -m 0755 
> + ${BEIGNET_BUILD_DIR}/backend/src/gbe_bin_generater ${D}${bindir}
> +
> +    #install utest
> +    install -d ${D}${bindir}/beignet
> +    install -d ${D}${bindir}/beignet/include
> +    install -m 0755 ${BEIGNET_BUILD_DIR}/utests/utest_run ${D}${bindir}/beignet
> +    install -m 0755 ${S}/setenv.sh ${D}${bindir}/beignet
> +    install -m 0644 ${S}/kernels/*.cl ${D}${bindir}/beignet
> +    install -m 0644 ${S}/kernels/*.bmp ${D}${bindir}/beignet
> +    install -m 0644 ${S}/kernels/compiler_ceil.bin ${D}${bindir}/beignet
> +    install -m 0644 ${S}/kernels/runtime_compile_link.h ${D}${bindir}/beignet
> +    install -m 0644 ${S}/kernels/include/runtime_compile_link_inc.h ${D}${bindir}/beignet/include/runtime_compile_link_inc.h
> +    install -d ${D}${libdir}
> +    install -m 0644 ${BEIGNET_BUILD_DIR}/utests/libutests.so 
> +${D}${libdir} }
> +do_install_append() {
> +    rm -rf ${D}${sysconfdir}
> +}
> +PACKAGES += "${PN}-compiler ${PN}-test"
> +FILES_${PN} = "${libdir}/libcl.so ${libdir}/libgbeinterp.so"
> +FILES_${PN}-compiler = "${bindir}/gbe_bin_generater 
> +${libdir}/libgbe.so ${libdir}/beignet.bc ${libdir}/beignet.pch ${libdir}/ocl_stdlib .h ${libdir}/include/"
> +FILES_${PN}-dev = "${includedir}/CL/"
> +FILES_${PN}-test = "${bindir}/beignet/"
> +FILES_${PN}-test += "${libdir}/libutests.so"
> +
>  
>  Build OpenCL kernels with OpenCL offline compiler
>  -------------------------------------------------
> --
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list