Hello World!
Here is my report on GSoC Project- Openlibm.
The project’s primary purpose is to provide a consistent libm to Octave. I tested some of the Bugs listed on the wiki page and below is my observation and report.
I tested the bug on Ubuntu 20.04, UBuntu 22.04, and macOS using the Github Action. The code for Bug Testing can be found on the BugTesting repository.
The c++ programs relevant for each bug are compiled with different compilers and on the different systems using Github action. Then the programs are also compiled with openlibm to observe if the consistency of the math library is achieved.
Testing of Bug #55538: "logspace BIST tests fail when Octave built with LLVM libc++"
“When octave is compiled with llvm’s libc++ library the output of the below command differs from the accurate output that is compiled with gcc compiler.
#when octave copiled with gcc
>>power (10, complex (inf, 1))
ans = -Inf + Infi
>> power (complex (10, 0), complex (inf, 1))
ans = Inf - NaNi "
This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm
Output Expected:
(-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan)
- Ubuntu 22.04 (with GCC compiler and Libstdc++)
- Without OpenLibm
g++ -std=c++17 bug#55538.cc -o bug#55538 //compiling
ldd bug#55538 // to show shared libraries
./bug#55538 //output of program
linux-vdso.so.1 (0x00007fff09dde000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fca42c41000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007fca42b5a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fca42b3a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007fca42912000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca42e7f000)
(-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan)
- With OpenLibm
g++ -std=c++17 bug#55538.cc -o bug#55538 -lopenlibm //compiling
ldd bug#55538 //to show shared libraries
./bug#55538 //output of program
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++)
- Without OpenLibm
clang++ -stdlib=libc++ bug#55538.cc -o x //compiling
otool -L x // to show shared libraries
./x //output of program
/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)
- With OpenLibm
clang++ -stdlib=libc++ bug#55538.cc -o bug#55538 -lopenlibm
otool -L bug#55538 // to show shared libraries
./bug#55538 //output of program
/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)
Observation:
The expected output is not achieved by compiling the program with Openlibm. Also the output is not consistent with systems and different compilers. Hence, the openlibm as a proposed solution to solve this bug has failed.
Testing of Bug #62212: "Issues when casting large integers to floating point"
This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm.
Output Expected:
db_large_integer: 1.84467e+19
ui64_large_integer: 18446744073709551615
- Ubuntu 22.04 (with GCC compiler and Libstdc++)
- Without OpenLibm
g++ -std=c++2a bug#62212.cc -o bug#62212
ldd bug#62212
./bug#62212
linux-vdso.so.1 (0x00007ffd0f5e4000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff95887c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff958654000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff95856d000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff958aba000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff95854d000)
db_large_integer: 1.84467e+19
ui64_large_integer: 0
- With OpenLibm
g++ -std=c++2a bug#62212.cc -o bug#62212 -lopenlibm
ldd bug#62212
./bug#62212
linux-vdso.so.1 (0x00007ffed5d98000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd1778b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd17768c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd1775a5000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd177af2000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd177585000)
db_large_integer: 1.84467e+19
ui64_large_integer: 0
- macOS (with llvm/Clang and Libc++)
- Without OpenLibm
clang++ -stdlib=libc++ bug#62212.cc -o v
otool -L v
./v
/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)
db_large_integer: 1.84467e+19
ui64_large_integer: 0
- With OpenLibm
clang++ -stdlib=libc++ bug#62212.cc -o bug#62212 -lopenlibm
otool -L bug#62212
./bug#62212
/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)
db_large_integer: 1.84467e+19
ui64_large_integer: 0
Observation:
On Ubuntu openlibm is failed to link when compiling. The expected output is not achieved by compiling the program with Openlibm. Even compiling with OpenLibm is not giving any difference to output. Hence, the openlibm as a proposed solution to solve this bug has failed.
Testing of Bug #62332: "[MinGW] acos(z), asin(z) and atan(z) , ( z = x + yi ) return wrong result for imaginary part lower than 1e-12"
This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm.
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
- Ubuntu 22.04 (with GCC compiler and Libstdc++)
- Without OpenLibm
g++ -std=c++17 bug#62332.cc -o bug#62332
ldd bug#62332
./bug#62332
linux-vdso.so.1 (0x00007ffe6b1f7000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff1abc78000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff1abb91000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff1ab969000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff1abeb6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff1ab949000)
0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.41421e-12i
0.707107+1e-15i-->0.785398+-1.41421e-15i
0.707107+1e-18i-->0.785398+-1.41421e-18i
0.707107+1e-21i-->0.785398+-1.41421e-21i
0.707107+1e-24i-->0.785398+-1.41421e-24i
0.707107+1e-27i-->0.785398+-1.41421e-27i
0.707107+1e-30i-->0.785398+-1.41421e-30i
0.707107+1e-33i-->0.785398+-1.41421e-33i
0.707107+1e-36i-->0.785398+-1.41421e-36i
0.707107+1e-39i-->0.785398+-1.41421e-39i
0.707107+1e-42i-->0.785398+-1.41421e-42i
0.707107+1e-45i-->0.785398+-1.41421e-45i
0.707107+1e-48i-->0.785398+-1.41421e-48i
0.707107+1e-51i-->0.785398+-1.41421e-51i
0.707107+1e-54i-->0.785398+-1.41421e-54i
0.707107+1e-57i-->0.785398+-1.41421e-57i
0.707107+1e-60i-->0.785398+-1.41421e-60i
- With OpenLibm
g++ -std=c++17 bug#62332.cc -o bug#62332 -lopenlibm
ldd bug#62332
./bug#62332
linux-vdso.so.1 (0x00007ffef447c000)
libopenlibm.so.3 => /lib/x86_64-linux-gnu/libopenlibm.so.3 (0x00007efff64c3000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007efff6297000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007efff606f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007efff5f88000)
/lib64/ld-linux-x86-64.so.2 (0x00007efff6505000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007efff5f68000)
0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.44329e-15i
0.707107+1e-18i-->0.785398+0i
0.707107+1e-21i-->0.785398+0i
0.707107+1e-24i-->0.785398+0i
0.707107+1e-27i-->0.785398+0i
0.707107+1e-30i-->0.785398+0i
0.707107+1e-33i-->0.785398+0i
0.707107+1e-36i-->0.785398+0i
0.707107+1e-39i-->0.785398+0i
0.707107+1e-42i-->0.785398+0i
0.707107+1e-45i-->0.785398+0i
0.707107+1e-48i-->0.785398+0i
0.707107+1e-51i-->0.785398+0i
0.707107+1e-54i-->0.785398+0i
0.707107+1e-57i-->0.785398+0i
0.707107+1e-60i-->0.785398+0i
- macOS (with llvm/Clang and Libc++)
- Without OpenLibm
clang++ -stdlib=libc++ bug#62332.cc -o bug#62332
otool -L bug#62332
./bug#62332
/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)
0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.33227e-15i
0.707107+1e-18i-->0.785398+-0i
0.707107+1e-21i-->0.785398+-0i
0.707107+1e-24i-->0.785398+-0i
0.707107+1e-27i-->0.785398+-0i
0.707107+1e-30i-->0.785398+-0i
0.707107+1e-33i-->0.785398+-0i
0.707107+1e-36i-->0.785398+-0i
0.707107+1e-39i-->0.785398+-0i
0.707107+1e-42i-->0.785398+-0i
0.707107+1e-45i-->0.785398+-0i
0.707107+1e-48i-->0.785398+-0i
0.707107+1e-51i-->0.785398+-0i
0.707107+1e-54i-->0.785398+-0i
0.707107+1e-57i-->0.785398+-0i
0.707107+1e-60i-->0.785398+-0i
- With OpenLibm
clang++ -stdlib=libc++ bug#62332.cc -lopenlibm -o bug#62332
otool -L bug#62332
./bug#62332
/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)
0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.33227e-15i
0.707107+1e-18i-->0.785398+-0i
0.707107+1e-21i-->0.785398+-0i
0.707107+1e-24i-->0.785398+-0i
0.707107+1e-27i-->0.785398+-0i
0.707107+1e-30i-->0.785398+-0i
0.707107+1e-33i-->0.785398+-0i
0.707107+1e-36i-->0.785398+-0i
0.707107+1e-39i-->0.785398+-0i
0.707107+1e-42i-->0.785398+-0i
0.707107+1e-45i-->0.785398+-0i
0.707107+1e-48i-->0.785398+-0i
0.707107+1e-51i-->0.785398+-0i
0.707107+1e-54i-->0.785398+-0i
0.707107+1e-57i-->0.785398+-0i
0.707107+1e-60i-->0.785398+-0i
Observation:
Compiling with the Openlibm is providing the output that we want to avoid.The expected output is not achieved by compiling the program with Openlibm. Hence, the openlibm as a proposed solution to solve this bug has failed.
MY TAKE: The proposed solution to use Openlibm as a replacement of libm to deal with the inconsistancy in maths library caused when Octave is compiled with libc++ (default on macOS) and sometimes with libstdc++ has failed and the bug issues and can not be solved with openlibm. Hence, there is need to find an alternate solution to address this issue.