Skip to content
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

Check SSE/AVX/AVX2 at runtime to decline in number of release binaries #768

Closed
1 of 2 tasks
gangliao opened this issue Dec 8, 2016 · 6 comments
Closed
1 of 2 tasks
Assignees

Comments

@gangliao
Copy link
Contributor

gangliao commented Dec 8, 2016

Currently, we have four release binaries, no-avx CPU, avx-CPU, no-avx-GPU, avx-GPU., which looks quite miscellaneous. Actually, we can check CPU capabilities at runtime via

  1. query cpuid
#ifdef _WIN32
/// MSVC CPUID
#define cpuid(info, x)    __cpuidex(info, x, 0)
#else
//  GCC Intrinsics
#include <cpuid.h>
/// gcc / clang CPUID
#define cpuid(info, x) __cpuid_count(x, 0, info[0], info[1], info[2], info[3])
#endif
  1. Then, do some bit manipulation to check whether AVX is supported or not.

That can help us decline in number of release binaries from four to two.

@gangliao gangliao changed the title Runtime check SSE/AVX/AVX2 to decline in number of release binaries Check SSE/AVX/AVX2 at runtime to decline in number of release binaries Dec 8, 2016
@gangliao
Copy link
Contributor Author

gangliao commented Dec 8, 2016

@reyoung
Copy link
Collaborator

reyoung commented Dec 8, 2016

@gangliao To query CPUID will detect whether CPU supports AVX instincts during runtime. But Paddle code needs to be refactored to switch calculation between AVX and SSE.

The code in SIMDFunction.h and CUDA package only export one symbol for both AVX and SSE. Has this been done? Is there any plan?

@hedaoyuan
Copy link
Contributor

这个可以搞定这个issue后在来做,不只是SIMDFunction.hCUDA的问题。

  1. SIMDFunction.h里面很多不用的函数可以删掉了
  2. hl_cpu_lstm.cuh这种文件,把avx和非avx代码拆成两个文件分别编译,avx的加-mavx,符号名本来就是不同的两个。
  3. BaseMatrix.cu需要考虑一下怎么同时编译avx和非avx两个版本。

@reyoung
Copy link
Collaborator

reyoung commented Dec 8, 2016

Maybe the first step is to add a cpuid.h/cpp in util package.

@gangliao
Copy link
Contributor Author

gangliao commented Dec 8, 2016

@reyoung @hedaoyuan Yeah, util/simd.h almost done.
It will detect all CPUID flags related to SIMD for general-purpose utilities (SSE2, SSE3, SSSE3, AVX, AVX2, AVX512) to support switch calculation.

@typhoonzero
Copy link
Contributor

I think this was already done.

Closing this issue, feel free to reopen it.

wwbitejotunn pushed a commit to wwbitejotunn/Paddle that referenced this issue Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants