[go: up one dir, main page]

Optimization barrier not working on Clang-CL

Summary

p_sin_cos function when using AVX returns bad/random results. Only the AVX optimized part returns bad results (if the input is 18 float in size, the first 16 outputs are bad, but the last 2, the non-optim ones, are good). The probable cause is EIGEN_OPTIMIZATION_BARRIER.

Environment

  • Operating System : Windows
  • Architecture : x64
  • Eigen Version : main
  • Compiler Version : Clang-CL
  • Compile Flags :
  • Vector Extension : AVX

Minimal Example

I have not been able to reproduce it with only the Eigen library, and it is only reproducible a custom verion of clan-cl/Llvm.

The example I have is using a Onnx model with Onnx-Runtime that has a Cosine operator. The model return random output dur to the Cosine operator calling cos function from Eigen.

Steps to reproduce

  1. first step
  2. second step
  3. ...

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs

Anything else that might help

The macro EIGEN_OPTIMIZATION_BARRIER is not defined when using Clang-cl compiler. Even if this compiler's backend is similar to GNUC, it does not define the preprocessor macro __GNUC__, unlike other clang compiler. But it does define the preproc macro __clang__.

Before this commit (82d61af3), it used to work under clan-cl.

I suggest replacing the line here (https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Core/util/Macros.h?ref_type=heads#L996), From

    #if EIGEN_COMP_GNUC

To

    #if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
  • Have a plan to fix this issue.
Edited by Jean-Simon Lapointe