JuliaMath / Yeppp.jl

Yeppp! bindings
Other
55 stars 14 forks source link

Wrong result using 32-bit Julia on 64-bit system #19

Open panlanfeng opened 9 years ago

panlanfeng commented 9 years ago

Yeppp.exp! gives wrong result without any warning if using 32-bit Julia if the system is actually 64-bit.

I am not sure how to decide if the system is 64-bit or 32-bit. So now the dependency will not be installed if Sys.ARCH is not :x86_64 to be safe. The user should choose the library themselves if they use 32-bit Julia.

ViralBShah commented 9 years ago

Cc: @Maratyszcza

tkelman commented 9 years ago

I'd be surprised if there were any difference between using 32 bit yeppp on a 32 bit machine vs using 32 bit yeppp on a 64 bit machine.

Maratyszcza commented 9 years ago

I can reproduce the problem. The cause is not clear yet.

panlanfeng commented 9 years ago

I tested on both 32-bit julia and 64-bit julia on a 64-bit windows. Yeppp.exp! on 32-bit julia calling x86 Yeppp! library gives the wrong result.

julia> versioninfo()
Julia Version 0.3.11
Commit 483dbf5* (2015-07-27 06:18 UTC)
Platform Info:
  System: Windows (i686-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU           E5540  @ 2.53GHz
  WORD_SIZE: 32
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

julia> x = [1.0,2.0,3.0,4.0];

julia> xtmp = ones(4);

julia> using Yeppp

julia> Yeppp.exp!(xtmp, x)
4-element Array{Float64,1}:
  1.99976
  8.00076
 15.9996
 63.9904

The result seems to be the power of 2. But if I force it to use x86_64 Yeppp! library then it is fine.

Maratyszcza commented 9 years ago

ARM is affected too. It appears that the problem is in the reference implementation of exp function.