镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

xt::cos funtion ruturn totally wrong number in release build #2811

Description

@XinyuKhan

Version:
xtensor version: 0.25.0
xsimd version: 13.0.0
xtl version: 0.7.7
Here is the gcc info

gcc -v                                                                                                                                         ─╯
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.1.0-8ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-IvzKaI/gcc-13-13.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-IvzKaI/gcc-13-13.1.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu1~22.04) 

Here is the complile flag
-fPIC -Wno-array-bounds -std=gnu++20 -mno-avx512f -msse4.2 -mavx2 -mfma

Here is the test code:
TEST(cos, test) {
  xt::xtensor<float, 2> test_data = xt::zeros<float>({180, 4});
  for (int i = 0; i < 180; i++) {
    test_data(i, 0) = i * M_PI / 180;
    test_data(i, 1) = i * M_PI / 180;
    test_data(i, 2) = i * M_PI / 180 + M_PI;
    test_data(i, 3) = i * M_PI / 180 + M_PI;
  }

  xt::xtensor<float, 2> cos_data = xt::cos(test_data);
  for (int i = 0; i < 180; i++) {
    std::cout << cos_data(i, 0) << " " << cos_data(i, 1) << " " << cos_data(i, 2) << " " << cos_data(i, 3) << std::endl;
    EXPECT_NEAR(cos_data(i, 0), std::cos(i * M_PI / 180), 1e-6);
    // EXPECT_NEAR(cos_data(i, 1), std::cos(i * M_PI / 180), 1e-6);
    // EXPECT_NEAR(cos_data(i, 2), std::cos(i * M_PI / 180 + M_PI), 1e-6);
    // EXPECT_NEAR(cos_data(i, 3), std::cos(i * M_PI / 180 + M_PI), 1e-6);
  }

}

Activity

  1. changed the title [-]xt::cos funtion ruture totally wrong number in release build[/-] [+]xt::cos funtion ruturn totally wrong number in release build[/+] on Oct 19, 2024
  2. XinyuKhan commented on Oct 19, 2024

    @XinyuKhan
    Author

    More Information: There is no problem when I use gcc 11 with -ffast-math flag and gcc13 without -ffast-math. But problem is exist when I use gcc13 with -ffast-math

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions