Toybrick

RK3399Pro入门教程(12)OpenGL/CL在Debian10上的安装和使用

jefferyzhang

版主

积分
12851
发表于 2020-3-20 11:31:27    查看: 99012|回复: 96 | [复制链接]    打印 | 显示全部楼层
本帖最后由 jefferyzhang 于 2020-3-31 10:41 编辑

安装准备:

安装前请务必先更新Debian10到最新版本,参考:
http://t.rock-chips.com/forum.php?mod=viewthread&tid=1319&extra=page%3D1


安装步骤:


1. 安装Toybrick GBM mali组件
  1. sudo apt install toybrick-gbm-dev libgbm-dev
复制代码


2. 安装OpenGL测试工具glmark2
  1. sudo apt install glmark2
复制代码


3. 安装OpenCL和clinfo
  1. sudo apt install ocl-icd-opencl-dev ocl-icd-dev clinfo
复制代码


4. 链接mali库
  1. sudo toybrick-mali.sh link
复制代码



5. 如果有任何GL/CL库的操作,记得操作之前先unlink mali库
  1. sudo toybrick-mali.sh unlink
复制代码



测试验证:

1. OpenGL性能测试
  1. glmark2-es2-drm
复制代码


可以看到画面出现OpenGL 3D图像测试程序正在运行。完整运行指标如下:
toybrick@debian10:~$ glmark2-es2-drm
=======================================================
    glmark2 2017.07
=======================================================
    OpenGL Information
    GL_VENDOR:     ARM
    GL_RENDERER:   Mali-T860
    GL_VERSION:    OpenGL ES 3.2 v1.r18p0-01rel0.5630b190419266e7fe8b09ec0007fb39
=======================================================
[build] use-vbo=false: FPS: 59 FrameTime: 16.949 ms
[build] use-vbo=true: FPS: 59 FrameTime: 16.949 ms
[texture] texture-filter=nearest: FPS: 60 FrameTime: 16.667 ms
[texture] texture-filter=linear: FPS: 60 FrameTime: 16.667 ms
[texture] texture-filter=mipmap: FPS: 60 FrameTime: 16.667 ms
[shading] shading=gouraud: FPS: 60 FrameTime: 16.667 ms
[shading] shading=blinn-phong-inf: FPS: 59 FrameTime: 16.949 ms
[shading] shading=phong: FPS: 60 FrameTime: 16.667 ms
[shading] shading=cel: FPS: 59 FrameTime: 16.949 ms
[bump] bump-render=high-poly: FPS: 59 FrameTime: 16.949 ms
[bump] bump-render=normals: FPS: 59 FrameTime: 16.949 ms
[bump] bump-render=height: FPS: 59 FrameTime: 16.949 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 31 FrameTime: 32.258 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 27 FrameTime: 37.037 ms
[pulsar] light=false:quads=5:texture=false: FPS: 59 FrameTime: 16.949 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 26 FrameTime: 38.462 ms
[desktop] effect=shadow:windows=4: FPS: 30 FrameTime: 33.333 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 20 FrameTime: 50.000 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 20 FrameTime: 50.000 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 29 FrameTime: 34.483 ms
[ideas] speed=duration: FPS: 30 FrameTime: 33.333 ms
[jellyfish] <default>: FPS: 32 FrameTime: 31.250 ms
[terrain] <default>: FPS: 11 FrameTime: 90.909 ms
[shadow] <default>: FPS: 29 FrameTime: 34.483 ms
[refract] <default>: FPS: 29 FrameTime: 34.483 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 59 FrameTime: 16.949 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 30 FrameTime: 33.333 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 60 FrameTime: 16.667 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 59 FrameTime: 16.949 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 31 FrameTime: 32.258 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 59 FrameTime: 16.949 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 59 FrameTime: 16.949 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 30 FrameTime: 33.333 ms
=======================================================
                                  glmark2 Score: 44
=======================================================





2. OpenCL环境验证
  1. clinfo
复制代码


输出正确的Mali CL环境:

toybrick@debian10:~$ clinfo
Number of platforms                               1
  Platform Name                                   ARM Platform
  Platform Vendor                                 ARM
  Platform Version                                OpenCL 1.2 v1.r18p0-01rel0.5630b190419266e7fe8b09ec0007fb39
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_fp64 cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_arm_core_id cl_arm_printf cl_arm_thread_limit_hint cl_arm_non_uniform_work_group_size cl_arm_import_memory
  Platform Extensions function suffix             ARM

  Platform Name                                   ARM Platform
Number of devices                                 1
  Device Name                                     Mali-T860
  Device Vendor                                   ARM
  Device Vendor ID                                0x8602000
  Device Version                                  OpenCL 1.2 v1.r18p0-01rel0.5630b190419266e7fe8b09ec0007fb39
  Driver Version                                  1.2
  Device OpenCL C Version                         OpenCL C 1.2 v1.r18p0-01rel0.5630b190419266e7fe8b09ec0007fb39
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               4
  Max clock frequency                             5MHz
  Device Partition                                (core)
    Max number of sub-devices                     0
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             256x256x256
  Max work group size                             256
  Preferred work group size multiple              4
  Preferred / native vector sizes                 
    char                                                16 / 16      
    short                                                8 / 8      
    int                                                  4 / 4      
    long                                                 2 / 2      
    half                                                 8 / 8        (cl_khr_fp16)
    float                                                4 / 4      
    double                                               2 / 2        (cl_khr_fp64)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              4029341696 (3.753GiB)
  Error Correction support                        No
  Max memory allocation                           1007335424 (960.7MiB)
  Unified memory for Host and Device              Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        262144 (256KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            65536 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   32 bytes
    Pitch alignment for 2D image buffers          16 pixels
    Max 2D image size                             65536x65536 pixels
    Max 3D image size                             65536x65536x65536 pixels
    Max number of read image args                 128
    Max number of write image args                8
  Local memory type                               Global
  Local memory size                               32768 (32KiB)
  Max number of constant args                     8
  Max constant buffer size                        65536 (64KiB)
  Max size of kernel argument                     1024
  Queue properties                                
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Prefer user sync for interop                    No
  Profiling timer resolution                      1000ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_fp64 cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_arm_core_id cl_arm_printf cl_arm_thread_limit_hint cl_arm_non_uniform_work_group_size cl_arm_import_memory

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  ARM Platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [ARM]
  clCreateContext(NULL, ...) [default]            Success [ARM]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-T860
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-T860
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-T860





GL/CL Sample 教程参考:

* GL可以参考glmark2的源码,写的非常好 https://github.com/glmark2/glmark2
* CL支持到1.2,可以参考CL官方教程 https://www.khronos.org/developers/reference-cards/

回复

使用道具 举报

newcomer3399

注册会员

积分
77
发表于 2020-3-20 18:50:44 | 显示全部楼层
我使用fedora,安装命令:
dnf install toybrick-gbm-dev
报错,为找到匹配的参数
CL的so本地源已经装好了
回复

使用道具 举报

newcomer3399

注册会员

积分
77
发表于 2020-3-20 19:03:47 | 显示全部楼层
dnf install ocl-icd-opencl-dev
报错:未找到匹配的参数
回复

使用道具 举报

jefferyzhang

版主

积分
12851
 楼主| 发表于 2020-3-20 22:05:34 | 显示全部楼层
newcomer3399 发表于 2020-3-20 19:03
dnf install ocl-icd-opencl-dev
报错:未找到匹配的参数

注意审题,本文仅适用于debian10
回复

使用道具 举报

newcomer3399

注册会员

积分
77
发表于 2020-3-23 12:55:08 | 显示全部楼层
jefferyzhang 发表于 2020-3-20 22:05
注意审题,本文仅适用于debian10

何时推出fedola的安装opencl教程?
回复

使用道具 举报

jefferyzhang

版主

积分
12851
 楼主| 发表于 2020-3-23 14:23:20 | 显示全部楼层
newcomer3399 发表于 2020-3-23 12:55
何时推出fedola的安装opencl教程?

fedola之前就有人问过,有回复过。
教程不会单独出了。
回复

使用道具 举报

newcomer3399

注册会员

积分
77
发表于 2020-3-24 12:28:33 | 显示全部楼层
我在fedora系统下安装opencl,首先添加Rockhip官方源:
dnf localinstall --nogpgcheck http://repo.rock-chips.com/fedor ... -4.fc28.aarch64.rpm
然后升级:
dnf clean all
dnf update
安装包:
dnf install ocl-icd-devel.aarch64
readlink -f /usr/lib64/libOpenCL.so  /usr/lib64/libmali.so.r18p0
安装clinfo:
dnf install clinfo
最后使用命令:
clinfo
出现结果:
Number of platforms                               1
  Platform Name                                   ARM Platform
  Platform Vendor                                 ARM
  Platform Version                                OpenCL 1.2 v1.r18p0-01rel0.42aa65ae5fdfdec464479cb891075220
  Platform Profile                                FULL_PROFILE
Failed creating base context during opening of kernel driver.
Kernel module may not have been loaded
  Platform Extensions                             <printPlatformInfo:4: get CL_PLATFORM_EXTENSIONS size : error -6>
Failed creating base context during opening of kernel driver.
Kernel module may not have been loaded
printPlatformInfo:488: number of devices : error -6
不知道是哪里有问题?始终没有显现mali的信息
回复

使用道具 举报

jefferyzhang

版主

积分
12851
 楼主| 发表于 2020-3-24 16:06:25 | 显示全部楼层
newcomer3399 发表于 2020-3-24 12:28
我在fedora系统下安装opencl,首先添加Rockhip官方源:
dnf localinstall --nogpgcheck http://repo.rock-c ...

Fedora的我就不是很清楚了,当时应该只要安装ocl就可以,不需要你链接,默认已经换了。
当然也要看你硬件是不是Toybrick的/
回复

使用道具 举报

newcomer3399

注册会员

积分
77
发表于 2020-3-24 16:21:13 | 显示全部楼层
jefferyzhang 发表于 2020-3-24 16:06
Fedora的我就不是很清楚了,当时应该只要安装ocl就可以,不需要你链接,默认已经换了。
当然也要看你硬件 ...

我的硬件是toybrick的,tb-rk3399proD
回复

使用道具 举报

jefferyzhang

版主

积分
12851
 楼主| 发表于 2020-3-24 16:23:25 | 显示全部楼层
newcomer3399 发表于 2020-3-24 16:21
我的硬件是toybrick的,tb-rk3399proD

是toybrick的话就太好办了,烧debian10把。不然你rknn都没办法更新到最新。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表