Openlibm: Difference between revisions

Jump to navigation Jump to search
1,130 bytes added ,  28 July 2022
m
no edit summary
No edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 42: Line 42:
==Report on OpenLibm==
==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.
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==
==Tests of Bugs against OpenLibm==
The three Bugs (bug {{bug|55538}} ,bug {{bug|62212}}, bug {{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 [https://github.com/shreyaswikriti/BugTesting BugTesting Repository] ).
The three Bugs (bug {{bug|55538}} ,bug {{bug|62212}}, bug {{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 [https://github.com/shreyaswikriti/BugTesting BugTesting Repository] ).


===Testing of bug {{bug|55538}}===
===Testing of bug {{bug|55538}}===
*;CODE SOURCE:
*;CODE SOURCE:


<syntaxhighlight lang="C++">
#include <complex>
#include <limits>
#include <iostream>


int
main (int argc, char *argv[])
{
  double x = 10.0;
  std::complex<double> y (std::numeric_limits<double>::infinity (), 1.0);


  std::complex<double> z1 = std::pow (x, y);
  std::complex<double> z2 = std::pow (std::complex<double> (x), y);
  std::complex<double> z3 = std::exp (y * std::log (x));
  std::complex<double> z4 = std::exp (y * std::log (std::complex<double> (x)));
  std::cout << z1 << ", "
            << z2 << ", "
            << z3 << ", "
            << z4 << std::endl;
}
</syntaxhighlight>


*;Output Expected :  
*;Output Expected :  
Line 87: Line 107:
*;''Observations :''  
*;''Observations :''  


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.
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 {{bug|62212}} ===
 
*;CODE SOURCE:


===Testing of bug {{bug|62212}}===
<syntaxhighlight lang="C++">
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2362212.cc C++ PROGRAM]
#include <cmath>
#include <iostream>
 
int main (void)
{
  double db_large_integer = std::pow (2., 64.);
  std::cout << "db_large_integer: " << db_large_integer << std::endl;
  uint64_t ui64_large_integer = db_large_integer;
  std::cout << "ui64_large_integer: " << ui64_large_integer << std::endl;
  return 0;
}
</syntaxhighlight>


*;Output Expected :  
*;Output Expected :  
Line 127: Line 162:
  On Ubuntu, openlibm 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 the output. Hence, the openlibm as a proposed solution to solve this bug has failed.
  On Ubuntu, openlibm 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 the output. Hence, the openlibm as a proposed solution to solve this bug has failed.


===Testing of bug {{bug|62332}}===
=== Testing of bug {{bug|62332}} ===
*;CODE SOURCE: [https://github.com/shreyaswikriti/BugTesting/blob/main/bug%2362332.cc C++ PROGRAM]
 
*;CODE SOURCE:
 
<syntaxhighlight lang="C++">
#include <iostream>
#include <cmath>
#include <complex>
#define cosd(x) (cos((x) * M_PI / 180))
int main()
{
    for(int i=1;i<=20;i++)
    { std::complex<double> x( cosd(45) , std::pow(10, -3*i) );
    std::cout << real(x)<<"+"<<imag(x)<<"i"<<"-->"<<real(acos(x))<<"+"<<imag(acos(x))<<"i"<< std::endl ;}
}
</syntaxhighlight>


*;Output Expected :  
*;Output Expected :  
Line 218: Line 267:
     0.707107+1e-57i-->0.785398+-0i
     0.707107+1e-57i-->0.785398+-0i
     0.707107+1e-60i-->0.785398+-0i
     0.707107+1e-60i-->0.785398+-0i
*;''Observations: ''
*;''Observations: ''
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.
 
                   
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.
 
 
==Conclusion==
==Conclusion==
The proposed solution is to use Openlibm as a replacement of libm to deal with the inconsistency in the 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 a need to find an alternate solution to address this issue.
The proposed solution is to use Openlibm as a replacement of libm to deal with the inconsistency in the 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 a need to find an alternate solution to address this issue.




[[Category:Development]]
[[Category:Development]]

Navigation menu