Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Use java.lang.StrictMath rather than java.lang.Math for compatibility in the following UDFs:
UDFCos.java
UDFExp.java
UDFLn.java
UDFLog.java
UDFLog2.java
UDFLog10.java
Currently, we have set up an ARM CI to test out how Hive works on ARM platform:
https://builds.apache.org/view/H-L/view/Hive/job/Hive-linux-ARM-trunk/
Among the failures, we have observed that some numeric operations can have different result across hardware archs, such as:
we can see that the calculation results of log, exp, cos, toRadians etc is slitly different than the .out file results that we are
comparing(they are tested and wrote on X86 machines), this is because of we use Math Library for these kind of calculations.
and according to the illustration:
Unlike some of the numeric methods of class StrictMath, all implementations of the equivalent functions of class Math are not
defined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strict reproducibility
is not required.
By default many of the Math methods simply call the equivalent method in StrictMath for their implementation.
Code generators are encouraged to use platform-specific native libraries or microprocessor instructions, where available,
to provide higher-performance implementations of Math methods.
so the result will have difference across hardware archs.
On the other hand, JAVA provided another library StrictMath that will not have this kind of problem as according to its' reference:
To help ensure portability of Java programs, the definitions of some of the numeric functions in this package require that they produce
the same results as certain published algorithms.
So in order to fix the above mentioned problem, we have to consider switch to use StrictMath instead of Math.
Attachments
Attachments
Issue Links
- relates to
-
HIVE-27145 Use StrictMath for remaining Math functions as followup of HIVE-23133
- Resolved