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

AVX512 part of code uses std libraries that may leak avx512 instructions. #46

Closed
Yangqing opened this issue Dec 10, 2018 · 1 comment
Closed

Comments

@Yangqing
Copy link

In code here:

https://github.com/pytorch/FBGEMM/blob/master/src/GenerateKernelU8S8S32ACC16Avx512.cc#L294

STL functions are used (from iostream). This is also seen in avx2 part of the code here:

#include <algorithm> // for min and max
#include <cassert>
#include <cmath> // for lrintf and sqrt
#include <tuple> // for tie

Usage of stl functions is known to possibly leak intrinsic instructions in template functions: during linkage time, the linker is free to choose the instantiation of template functions, and if the linker chooses the instantiation that is built with, say, avx512, and then the code is run on a machine that does not have avx512, segfault with "illegal instruction" happens.

We might want to explicitly ban all usage of c++ headers, and avoid the use of any template instantiations, in .cc files (and included header files) that are built with -mavx2 and -mavx512f.

@dskhudia
Copy link
Contributor

dskhudia commented Dec 11, 2018

This particular file ( GenerateKernelU8S8S32ACC16Avx512.cc) is not compiled with -mavx2 or -mavx512 flag. It does generate avx512 code but at runtime. We did clean up files compiled with -mavx2 and -mavx512 flags in a series of diffs (https://github.com/pytorch/FBGEMM/commits/master; series of diffs on Dec 5) to minimize the use of STL. However, there are still very few STL functions used (e.g., min/max/nearbyint in src/QuantUtilsAvx2.cc) in files compiled with -mavx2/-mavx512 that can be cleaned up by providing a local implementation.

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

3 participants