Giter Site home page Giter Site logo

There is a problem with max and min about vc HOT 4 OPEN

wjr-z avatar wjr-z commented on June 1, 2024
There is a problem with max and min

from vc.

Comments (4)

bernhardmgruber avatar bernhardmgruber commented on June 1, 2024

No worries, I could translate! I will answer in English, so you can pick your favorite translation engine!

I can confirm, this is a bug in the implementation of uchar Vc::Detail::max(__m128i a, uchar). It should use uchar instead of schar in it's implementation. The bug also occurs when the function is called via the public API:

    uint8_t a[32]{0, 10, 250};
    std::cout << (int)Vc::schar_v((signed char*)a).max() << '\n'; // correctly returns 10
    std::cout << (int)Vc::uchar_v(a).max() << '\n'; // returns 10, should be 250

See: https://godbolt.org/z/8K6Yb3oYv.

Would you like to provide us with a pull request? Otherwise, I can fix it myself.

from vc.

wjr-z avatar wjr-z commented on June 1, 2024

不用担心,我可以翻译!我会用英语回答,所以你可以选择你最喜欢的翻译引擎!

我可以确认,这是实现中的错误。它应该使用而不是在其实现中使用。当通过公共 API 调用函数时,也会发生此错误:uchar Vc::Detail::max(__m128i a, uchar)``uchar``schar

    uint8_t a[32]{0, 10, 250};
    std::cout << (int)Vc::schar_v((signed char*)a).max() << '\n'; // correctly returns 10
    std::cout << (int)Vc::uchar_v(a).max() << '\n'; // returns 10, should be 250

请参阅:https://godbolt.org/z/8K6Yb3oYv。

您想向我们提供拉取请求吗?否则,我可以自己修复它。

我不太会pull请求,您可以自己修复它。

from vc.

wjr-z avatar wjr-z commented on June 1, 2024

No worries, I could translate! I will answer in English, so you can pick your favorite translation engine!

I can confirm, this is a bug in the implementation of uchar Vc::Detail::max(__m128i a, uchar). It should use uchar instead of schar in it's implementation. The bug also occurs when the function is called via the public API:

    uint8_t a[32]{0, 10, 250};
    std::cout << (int)Vc::schar_v((signed char*)a).max() << '\n'; // correctly returns 10
    std::cout << (int)Vc::uchar_v(a).max() << '\n'; // returns 10, should be 250

See: https://godbolt.org/z/8K6Yb3oYv.

Would you like to provide us with a pull request? Otherwise, I can fix it myself.

实际上min也有问题,不过我当时只列出了max的测试,抱歉!
对于min的测试如下
https://godbolt.org/z/d36c8YPsY
显然第二个的min应该是0而不是1。
对于a[2+16]=250,如果没有这一句,很容易发现不出错误。
https://godbolt.org/z/q9dnqx4v8
造成这个的原因大概是使用Vc_AVX_TO_SSE_2_NEW,导致先使用了AVX2中的unsigned函数,后使用SSE2中的signed函数,使得250先与1进行min_epu8,导致发现不出错误。

from vc.

bernhardmgruber avatar bernhardmgruber commented on June 1, 2024

Reopen, because of remaining issue with clang.

from vc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.