Skip to content

support cpu count > 64 #6189

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

JaredforReal
Copy link

Fix: #6142 support cpu count > 64


对于Win平台:
使用多组掩码方案,每组默认为64。根据Windows系统版本设置最大CPU支持数
生产环境中,group = 1(cpu count <= 64)的情况下,使用legacy mode,保留原始逻辑

缺憾:在group > 1(cpu count > 64)的情况下,假定了每组的性能以及功能相同,未区分大小核

新增单元测试:test_multicpu,在测试环境中,屏蔽 legacy mode 强制使用 group 逻辑,验证多组掩码的逻辑功能

对于Linux/Android平台:
未作修改。
cpu_set_t 的大小,在现代主流实现(如 glibc)默认通过 CPU_SETSIZE 定义为 ​1024。即原生支持 cpu count > 64 如想支持 > 1024,可使用 cpu_set_t* 加上带有_S POSIX指令实现

对于Apple平台:
未作修改。
unsigned int 最高支持32核,考虑到Apple目前没有超过32核的芯片,为了面向未来的健壮性,可改用 uint64_t以支持64 cpu

其余单元测试结果与主分支一致

修改文件
src/cpu.cpp
src/cpu.h
tests/CMakeList.txt

新增文件
tests/test_multicpu.cpp

support cpu count > 64

对于Win平台:
使用多组掩码方案,每组默认为64。根据Windows系统版本设置最大CPU支持数
生产环境中,group = 1(cpu count <= 64)的情况下,使用legacy mode,保留原始逻辑

缺憾:在group > 1(cpu count > 64)的情况下,假定了每组的性能以及功能相同,未区分大小核
新增单元测试:test_multicpu,在测试环境中,屏蔽 legacy mode 强制使用 group 逻辑,验证多组掩码的逻辑功能

对于Linux/Android平台:
未作修改。
cpu_set_t 的大小,在现代主流实现(如 glibc)默认通过 CPU_SETSIZE 定义为 ​1024。即原生支持 cpu count > 64
如想支持 > 1024,可使用 cpu_set_t* 加上带有_S POSIX指令实现

对于Apple平台:
未作修改。
unsigned int最高支持32核,考虑到Apple目前没有超过32核的芯片,为了面向未来的健壮性,可改用uint64_t以支持64 cpu

其余单元测试结果与主分支一致

修改文件
src/cpu.cpp
src/cpu.h
tests/CMakeList.txt

新增文件
tests/test_multicpu.cpp
@tencent-adm
Copy link
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

The binary size change of libncnn.so (bytes)

architecture base size pr size difference
x86_64 15602512 15602512 0 😘
armhf 6611348 6611348 0 😘
aarch64 9921904 9921904 0 😘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

【多人竞赛】support cpu count > 64
2 participants