GithubHelp home page GithubHelp logo

bx::sqrt(0.f) will return NaN about bx HOT 10 CLOSED

junjie020 avatar junjie020 commented on July 17, 2024
bx::sqrt(0.f) will return NaN

from bx.

Comments (10)

bkaradzic avatar bkaradzic commented on July 17, 2024

Can't repro:

==== Building bx (release) ====
==== Building bx.test (release) ====
math_test.cpp
Linking bx.test
Running...
2023-04-16 20:41:39.397 bx.testRelease[14422:366556] ../../../tests/run_test.cpp(19): Compiler: Clang 14.0.3, CPU: ARM, Architecture: 64-bit, OS: OSX, CRT: Clang C Library, Date: Apr 13 2023, Time: 20:32:22, C++: C++14
Filters: libm
Randomness seeded to: 3232557189
===============================================================================
All tests passed (579889 assertions in 1 test case)

from bx.

junjie020 avatar junjie020 commented on July 17, 2024

I want to know, how do you build bx.test target from bx?

Here is what I try to build bx.test taget from bx/makefile, like:

cd bxfolder
make test
.build/osx-x64/bin/bx.testRelease

result:

2023-04-17 16:06:04.935 bx.testRelease[92617:3820883] ../../../tests/run_test.cpp(19): Compiler: Clang 14.0.3, CPU: x86, Architecture: 64-bit, OS: OSX, CRT: Clang C Library, Date: Apr 17 2023, Time: 15:26:31, C++: C++14
Randomness seeded to: 3560497745

bx.testRelease is a Catch2 v3.1.0 host application.
Run with -? for options

-------------------------------------------------------------------------------
isFinite, isInfinite, isNan
-------------------------------------------------------------------------------
../../../tests/math_test.cpp:15
...............................................................................

../../../tests/math_test.cpp:20: FAILED:
  REQUIRE( std::isnan(u.f) == bx::isNan(u.f) )
with expansion:
  false == true

903.920000
-------------------------------------------------------------------------------
Settings
-------------------------------------------------------------------------------
../../../tests/settings_test.cpp:10
...............................................................................

../../../tests/settings_test.cpp:10: FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGSEGV - Segmentation violation signal

===============================================================================
test cases:       35 |       33 passed | 2 failed
assertions: 10154393 | 10154391 passed | 2 failed

It's different from last result which build from my build system. But still have some strange errors.

Could you mind to show me how you build your bx.test target?

My test device is macbook M1 with macOS Ventura 13.2.1

Thanks.

from bx.

cloudwu avatar cloudwu commented on July 17, 2024

I think

const simd128_neon_t rsqrt = simd_rsqrt(_a);
simd_rsqrt(0) should be NaN here.

from bx.

bkaradzic avatar bkaradzic commented on July 17, 2024

Did you try with latest?

from bx.

junjie020 avatar junjie020 commented on July 17, 2024

I have try the new code(build from bx/makefile), all test passed.

Beside that, could you mind to define a macro, let the bx lib use the CRT version math methods?

from bx.

bkaradzic avatar bkaradzic commented on July 17, 2024

Beside that, could you mind to define a macro, let the bx lib use the CRT version math methods?

Not in official repo, I would suggest you just modify bx for your project to do whatever you need.

from bx.

junjie020 avatar junjie020 commented on July 17, 2024

I found it will failed the test with ARM architecture. To reproduce:

cd bxfolder
make osx-arm64-release
./.build/osx-arm64/bin/bx.testRelease

It will log:

2023-04-25 10:19:16.197 bx.testRelease[7498:1704298] ../../../tests/run_test.cpp(19): Compiler: Clang 14.0.3, CPU: ARM, Architecture: 64-bit, OS: OSX, CRT: Clang C Library, Date: Apr 25 2023, Time: 10:18:31, C++: C++14
Randomness seeded to: 2004761687

bx.testRelease is a Catch2 v3.1.0 host application.
Run with -? for options

libm
../../../tests/math_test.cpp:75

../../../tests/math_test.cpp:158: FAILED:
REQUIRE( bx::isNan(bx::sqrtRef(-1.0f) ) )
with expansion:
false

905.025000
test cases: 185 | 184 passed | 1 failed
assertions: 11271229 | 11271228 passed | 1 failed

from bx.

bkaradzic avatar bkaradzic commented on July 17, 2024

I found it will failed the test with ARM architecture. To reproduce:

But your original problem is solved? This is sqrtRef failure which is not used by default... I'll fix it, just asking for original issue?

from bx.

junjie020 avatar junjie020 commented on July 17, 2024

I try to reproduce my original problem, it can pass the test in release version, but it still failed in debug version.

cd bxfolder
make osx-arm64-debug
/.build/osx-arm64/bin/bx.testDebug

the log:

2023-04-25 10:53:00.302 bx.testDebug[9366:1716925] ../../../tests/run_test.cpp(19): Compiler: Clang 14.0.3, CPU: ARM, Architecture: 64-bit, OS: OSX, CRT: Clang C Library, Date: Apr 25 2023, Time: 10:51:01, C++: C++14
Randomness seeded to: 1175618260

bx.testDebug is a Catch2 v3.1.0 host application.
Run with -? for options

libm
../../../tests/math_test.cpp:75

../../../tests/math_test.cpp:115: FAILED:
REQUIRE( bx::isInfinite(bx::rsqrt(0.0f) ) )
with expansion:
false

905.026000
test cases: 185 | 184 passed | 1 failed
assertions: 11263216 | 11263215 passed | 1 failed

And I add this code in one of the test file, and build as debug version:

REQUIRE(bx::sqrt(0.f) == 0);

It still failed.

from bx.

bkaradzic avatar bkaradzic commented on July 17, 2024

Try again with latest.

from bx.

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.