Openlibm: Difference between revisions

From Octave
Jump to navigation Jump to search
No edit summary
No edit summary
Line 50: Line 50:
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2355538.cc C++ PROGRAM]
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2355538.cc C++ PROGRAM]


*;Output Expected : ((-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan) )
*;Output Expected :  
    ((-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan) )
 
*;Commands:
    '''''On Ubuntu'''''
    g++ -std=c++17 bug#55538.cc -o bug#55538 -lopenlibm  '''''//compiling'''''
    ldd bug#55538                        '''''//to show shared libraries'''''
    ./bug#55538                                  '''''//output of program'''''
 
    '''''on macOS'''''
    clang++ -stdlib=libc++ bug#55538.cc -o bug#55538  -lopenlibm 
    otool -L bug#55538                  '''''// to show shared libraries'''''
    ./bug#55538                        '''''//output of program'''''
 
 
*;Ubuntu 22.04 (with GCC compiler and Libstdc++):
  linux-vdso.so.1 (0x00007ffe1cd2b000)
  libopenlibm.so.3 => /lib/x86_64-linux-gnu/libopenlibm.so.3 (0x00007fa21846e000)
  libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa218242000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa218222000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007fa217ffa000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007fa217f13000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fa2184b0000)
 
  (-inf,inf), (-nan,-nan), (-inf,inf), (inf,-nan)
 
*;macOS (with llvm/Clang and Libc++):
  /usr/local/opt/openlibm/lib/libopenlibm.4.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
 
  (inf,nan), (inf,nan), (-inf,inf), (inf,nan)
 
===Testing of bug {{bug|62212}}===
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2362212.cc C++ PROGRAM]
 
*;Output Expected :
    db_large_integer: 1.84467e+19
    ui64_large_integer: 18446744073709551615
 
*;Commands:
    '''''On Ubuntu'''''
    g++ -std=c++2a bug#62212.cc -o bug#62212 -lopenlibm
    ldd bug#62212
    ./bug#62212                             
 
    '''''on macOS'''''
    clang++ -stdlib=libc++ bug#62212.cc -o bug#62212  -lopenlibm
    otool -L bug#62212
    ./bug#62212                     
*;Ubuntu 22.04 (with GCC compiler and Libstdc++):
 
*;macOS (with llvm/Clang and Libc++):
 
===Testing of bug {{bug|62332}}===
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2362332.cc C++ PROGRAM]
 
*;Output Expected :
    7.071068e-01+1.000000e-03i -> 7.853992e-01-1.414212e-03i
    7.071068e-01+1.000000e-06i -> 7.853982e-01-1.414214e-06i
    7.071068e-01+1.000000e-09i -> 7.853982e-01-1.414214e-09i
    7.071068e-01+1.000000e-12i -> 7.853982e-01-1.414214e-12i
    7.071068e-01+1.000000e-15i -> 7.853982e-01-1.414214e-15i
    7.071068e-01+1.000000e-18i -> 7.853982e-01-1.414214e-18i
    7.071068e-01+1.000000e-21i -> 7.853982e-01-1.414214e-21i
    7.071068e-01+1.000000e-24i -> 7.853982e-01-1.414214e-24i
    7.071068e-01+1.000000e-27i -> 7.853982e-01-1.414214e-27i
    7.071068e-01+1.000000e-30i -> 7.853982e-01-1.414214e-30i
    7.071068e-01+1.000000e-33i -> 7.853982e-01-1.414214e-33i
    7.071068e-01+1.000000e-36i -> 7.853982e-01-1.414214e-36i
    7.071068e-01+1.000000e-39i -> 7.853982e-01-1.414214e-39i
    7.071068e-01+1.000000e-42i -> 7.853982e-01-1.414214e-42i
    7.071068e-01+1.000000e-45i -> 7.853982e-01-1.414214e-45i
    7.071068e-01+1.000000e-48i -> 7.853982e-01-1.414214e-48i
    7.071068e-01+1.000000e-51i -> 7.853982e-01-1.414214e-51i
    7.071068e-01+1.000000e-54i -> 7.853982e-01-1.414214e-54i
    7.071068e-01+1.000000e-57i -> 7.853982e-01-1.414214e-57i
    7.071068e-01+1.000000e-60i -> 7.853982e-01-1.414214e-60i
 
*;Commands:
    '''''On Ubuntu'''''
    g++ -std=c++17 bug#62332.cc -o bug#62332 -lopenlibm
    ldd bug#62332
    ./bug#62332                             
 
    '''''on macOS'''''
    clang++ -stdlib=libc++ bug#62332.cc  -lopenlibm -o bug#62332
    otool -L bug#62332
    ./bug#62332 
 
*;Ubuntu 22.04 (with GCC compiler and Libstdc++):
 
*;macOS (with llvm/Clang and Libc++):
                   
 


*;





Revision as of 06:58, 28 July 2022

A list of open issues that are related to the differences in math libraries among different systems:

Bug number Description
bug #57071 Fix math.h and function names that block 64-bit double
bug #55538 logspace BIST tests fail when Octave built with LLVM libc++
bug #62212 Wrong unsigned integer overflow with clang
bug #49984 fabs missing from libm implementation.
bug #61812 Math constants (e.g. M_PI) are not part of C/C++ standard
bug #49091 MinGW std::acosh less accurate than Linux versions
bug #60784 Inconsistent behavior for boolean matrix types with matrix functions
bug #45481 rem and fmod may give very wrong results for large arguments
bug #61715 Inconsistent NaN results for exponential function (0+0i)^0 with libc++ and libstdc++
bug #45746 Incorrect results of trigonometric functions gsl_sf_sin and gsl_sf_cos
bug #62332 [MinGW] acos(z), asin(z) and atan(z) , ( z = x + yi ) return wrong result for imaginary part lower than 1e-12

Report on OpenLibm

The very idea of Linking openLibm with GNU octave was to bring consistency of maths library functions across different compilers and systems, thus achieving a good Libm implementation and countering the above bugs. The project openLibm was part of GSoC 2022, where some of the above bugs' c++ snippets were tested against openLibm to achieve the desired result. Unfortunately, the openLibm failed to provide the expected results.OpenLibm has its own limitation such as not being fully built and well-maintained Libm and hence the result.

Tests of Bugs against OpenLibm

The three Bugs (bug #55538 ,bug #62212, bug #62332 ) were tested against openLibm on systems Ubuntu 20.04, Ubuntu 22.04 and macOS through the github action (code can be found at BugTesting Repository ).

Testing of bug #55538

  • Output Expected
   ((-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan) )
  • Commands
   On Ubuntu
   g++ -std=c++17 bug#55538.cc -o bug#55538 -lopenlibm  //compiling
   ldd bug#55538                         //to show shared libraries
   ./bug#55538                                  //output of program
  
   on macOS
   clang++ -stdlib=libc++ bug#55538.cc -o bug#55538  -lopenlibm  
   otool -L bug#55538                  // to show shared libraries
   ./bug#55538                         //output of program


  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  linux-vdso.so.1 (0x00007ffe1cd2b000)
  libopenlibm.so.3 => /lib/x86_64-linux-gnu/libopenlibm.so.3 (0x00007fa21846e000)
  libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa218242000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa218222000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007fa217ffa000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007fa217f13000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fa2184b0000)
  
  (-inf,inf), (-nan,-nan), (-inf,inf), (inf,-nan)
 
  • macOS (with llvm/Clang and Libc++)
  /usr/local/opt/openlibm/lib/libopenlibm.4.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
  
  (inf,nan), (inf,nan), (-inf,inf), (inf,nan)

Testing of bug #62212

  • Output Expected
   db_large_integer: 1.84467e+19
   ui64_large_integer: 18446744073709551615
  • Commands
   On Ubuntu
   g++ -std=c++2a bug#62212.cc -o bug#62212 -lopenlibm
   ldd bug#62212
   ./bug#62212                               
  
   on macOS
   clang++ -stdlib=libc++ bug#62212.cc -o bug#62212  -lopenlibm
   otool -L bug#62212
   ./bug#62212                      
  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  • macOS (with llvm/Clang and Libc++)

Testing of bug #62332

  • Output Expected
   7.071068e-01+1.000000e-03i -> 7.853992e-01-1.414212e-03i
   7.071068e-01+1.000000e-06i -> 7.853982e-01-1.414214e-06i
   7.071068e-01+1.000000e-09i -> 7.853982e-01-1.414214e-09i
   7.071068e-01+1.000000e-12i -> 7.853982e-01-1.414214e-12i
   7.071068e-01+1.000000e-15i -> 7.853982e-01-1.414214e-15i
   7.071068e-01+1.000000e-18i -> 7.853982e-01-1.414214e-18i
   7.071068e-01+1.000000e-21i -> 7.853982e-01-1.414214e-21i
   7.071068e-01+1.000000e-24i -> 7.853982e-01-1.414214e-24i
   7.071068e-01+1.000000e-27i -> 7.853982e-01-1.414214e-27i
   7.071068e-01+1.000000e-30i -> 7.853982e-01-1.414214e-30i
   7.071068e-01+1.000000e-33i -> 7.853982e-01-1.414214e-33i
   7.071068e-01+1.000000e-36i -> 7.853982e-01-1.414214e-36i
   7.071068e-01+1.000000e-39i -> 7.853982e-01-1.414214e-39i
   7.071068e-01+1.000000e-42i -> 7.853982e-01-1.414214e-42i
   7.071068e-01+1.000000e-45i -> 7.853982e-01-1.414214e-45i
   7.071068e-01+1.000000e-48i -> 7.853982e-01-1.414214e-48i
   7.071068e-01+1.000000e-51i -> 7.853982e-01-1.414214e-51i
   7.071068e-01+1.000000e-54i -> 7.853982e-01-1.414214e-54i
   7.071068e-01+1.000000e-57i -> 7.853982e-01-1.414214e-57i
   7.071068e-01+1.000000e-60i -> 7.853982e-01-1.414214e-60i
  • Commands
   On Ubuntu
   g++ -std=c++17 bug#62332.cc -o bug#62332 -lopenlibm
   ldd bug#62332
   ./bug#62332                               
  
   on macOS
   clang++ -stdlib=libc++ bug#62332.cc  -lopenlibm -o bug#62332
   otool -L bug#62332
   ./bug#62332  
  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  • macOS (with llvm/Clang and Libc++)