-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[OpenCL] Save kernel cache & tuned params immediatelly #6440
[OpenCL] Save kernel cache & tuned params immediatelly #6440
Conversation
…oop finish. test=develop
Thanks for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
关于localthread,需要充分测试。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not work on app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…addlePaddle#6440) * move save to destructor of RuntimeProgram * fix multi models executed in sequential way in one thread * support multi-thread executation
【问题1】
单线程单个模型运行时,在 APP 环境下无法保存 cache 文件。
【原因分析】
CLRuntime
全局单例类的析构函数中。在 adb shell 环境下,CLRuntime
单例类的析构函数在程序结束时一定会被调用到,因此可以正常触发保存文件操作;CLRuntime
全局单例类的析构函数并不会被执行到,因此无法触发保存文件操作。【解决方法】
将保存文件操作提前,放在
RuntimeProgram
类的析构函数内执行,确保 APP 退出时一定执行保存文件操作。【问题2】
在一个线程内,串行执行 2 个模型,在 adb shell 环境下只保存了第1个模型对应的 cache 文件,无法保存第2个模型对应的 cache 文件。
【原因分析】
在
SetBinaryPathName
函数中,对kernel_path_name_
变量是直接通过push_back
赋值,然后在GetBinaryPathName
函数中,通过at(0)/at(1)
方法获得的永远都是第一个path/name。因此需要在push_back
前clear
数据。【解决方法】
在
push_back
前执行clear
。【问题3】
在N个线程下,每个线程有自己的 predictor,并行执行N个模型,在 adb shell 环境下无法正常保存N个模型的对应的N个 cache file。
【原因分析】
CLRuntime
是一个单例类,因此该类的成员变量并不是线程安全的,也就会出现binary_path_name_
只保存了其中一个模型对应的设置。【解决方法】
通过定义一个
thread_local
的实例,实现该实例在每个线程内是唯一的。