GraphicsMagick 的 OpenCL 开发记录(三)

文章目录

  • 调用`clCreateBuffer()`产生异常问题(一)
  • `vscode`环境

<2022-03-07 Mon>

调用clCreateBuffer()产生异常问题(一)

vscode上的堆栈输出如下:

libc.so.6!__pthread_kill_implementation (Unknown Source:0)
libc.so.6!raise (Unknown Source:0)
libc.so.6!abort (Unknown Source:0)
libigdrcl.so![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libOpenCL.so!clCreateBuffer (Unknown Source:0)
AcquireMagickCLCacheInfo(MagickCLDevice device, Quantum * pixels, const magick_int64_t length) (gm-ocl/magick/opencl.c:569)
GetAuthenticOpenCLBuffer(const Image * image, MagickCLDevice device, ExceptionInfo * exception) (gm-ocl/magick/pixel_cache.c:5252)

因为堆栈显示问题最终是出在__pthread_kill_implementation上,所以我的调查方向一直在线程同步上,代码调试了一遍又一遍却始终没有找到问题。心灰意冷并已经产生从头再开始的想法了。

注意到:

libigdrcl.so![Unknown/Just-In-Time compiled code] (Unknown Source:0)

谷歌了下libigdrcl.so,难道是安装intel驱动的问题?目前使用的是intel-compute-runtime,现改为intel-opencl-runtime,参考自:“GPGPU - ArchWiki”。

$ sudo pacman -Rns intel-compute-runtime
$ yay -S intel-opencl-runtime

我对比了intel-compute-runtimeintel-opencl-runtimeclinfo输出差异发现intel-compute-runtime支持GPUintel-opencl-runtime支持CPU

那代码到底有没有问题?clCreateBuffer()调用失败的原因要不要深究?

vscode环境

// tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build with opencl",
            "type": "shell",
            "command": "make",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
// launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/utilities/gm",
            "args": ["display", "~/temp/bg1a.jpg"],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [
                {
                    "name": "MAGICK_OCL_DEVICE",
                    "value": "true"
                }
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}

正在用的dev.sh内容如下:

#!/bin/bash

./configure CFLAGS='-g -O0' LDFLAGS='-ldl' --enable-opencl --prefix=$HOME/usr/local

commit:partially fix crash when replacing intel-compute-runtime with intel-opencl-runtime。

你可能感兴趣的:(GraphicsMagick,的,OpenCL,开发,GraphicsMagick,OpenCL,vscode)