Skip to content

[BugFix][OPENCL] Fix initalization sequence of opencl backend valid API. test=develop #4003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 30, 2020

Conversation

ysh329
Copy link
Contributor

@ysh329 ysh329 commented Jul 28, 2020

状态:等待review


主要内容

修正OpenCL的预判API导致的初始化顺序问题。先前的预判API会让CLRuntime调用CLWrapper去检查库是否找到,符号加载是否正常。但因为该顺序问题导致后续segfault bug(如加载cpu+gpu库,但加载cpu模型,在不支持gpu的手机上面会挂的问题)。

因先初始化CLRuntime会初始化相关平台设备等等,二者存在交叉依赖的问题。现改为,预判API先不调用CLRuntime,而是先通过CLWrapper获取是否找到lib和符号方法,在做CLRuntime层面的检查(fp16的支持等等)。

再就是RuntimeProgram创建的时候,有针对opencl设置每个kernel的kernelContext,这部分之前咱们是每个kernel共用一个kernelContext,因为cl::Context是唯一的。这里也需要考虑到当跑CPU模型时,遇到这里需要预判是否硬件支持opencl。否则出现segfault(gdb定位到这里),因而这里加上了预判再去setContext。

@ysh329 ysh329 changed the title [OPENCL] fix opencl backend. test=develop [OPENCL] Fix opencl backend. test=develop Jul 28, 2020
@ysh329 ysh329 requested a review from xiebaiyuan July 28, 2020 09:57
@ysh329 ysh329 changed the title [OPENCL] Fix opencl backend. test=develop [OPENCL] Fix initalization sequence of opencl backend valid API. test=develop Jul 28, 2020
@ysh329 ysh329 changed the title [OPENCL] Fix initalization sequence of opencl backend valid API. test=develop [BugFix][OPENCL] Fix initalization sequence of opencl backend valid API. test=develop Jul 28, 2020
xiebaiyuan
xiebaiyuan previously approved these changes Jul 29, 2020
Copy link
Collaborator

@xiebaiyuan xiebaiyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@xiebaiyuan xiebaiyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ysh329 ysh329 merged commit de299b9 into PaddlePaddle:develop Jul 30, 2020
@ysh329 ysh329 deleted the fix-gpu-load-cpu-model branch July 30, 2020 03:21
ysh329 added a commit to ysh329/Paddle-Lite-1 that referenced this pull request Jul 30, 2020
ysh329 added a commit that referenced this pull request Jul 30, 2020
…PI. test=develop (#4003) (#4021)

* fix opencl backend. test=develop
@ysh329 ysh329 added the OpenCL label Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants