Skip to content

Commit

Permalink
Use openspecfun.
Browse files Browse the repository at this point in the history
Amos and Faddeeva were moved out of openlibm.
libopenlibm-extras is now libopenspecfun.
  • Loading branch information
Viral B. Shah committed Dec 24, 2013
1 parent 68feb08 commit 80b3592
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
[submodule "deps/openlibm"]
path = deps/openlibm
url = git:https://github.com/JuliaLang/openlibm.git
[submodule "deps/openspecfun"]
path = deps/openspecfun
url = git:https://github.com/JuliaLang/openspecfun.git
[submodule "deps/Rmath"]
path = deps/Rmath
url = git:https://github.com/JuliaLang/Rmath.git
[submodule "doc/juliadoc"]
path = doc/juliadoc
url = git:https://github.com/JuliaLang/JuliaDoc.git

1 change: 1 addition & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ USE_SYSTEM_PCRE=0
USE_SYSTEM_LIBM=0
USE_SYSTEM_OPENLIBM=0
UNTRUSTED_SYSTEM_LIBM=0
USE_SYSTEM_OPENSPECFUN=0
USE_SYSTEM_BLAS=0
USE_SYSTEM_LAPACK=0
USE_SYSTEM_FFTW=0
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ ifeq ($(USE_SYSTEM_PCRE),0)
JL_PRIVATE_LIBS += pcre
endif
ifeq ($(USE_SYSTEM_OPENLIBM),0)
JL_PRIVATE_LIBS += openlibm-extras
ifeq ($(USE_SYSTEM_LIBM),0)
JL_PRIVATE_LIBS += openlibm
endif
endif
ifeq ($(USE_SYSTEM_OPENSPECFUN),0)
JL_PRIVATE_LIBS += openspecfun
endif
ifeq ($(USE_SYSTEM_BLAS),0)
JL_PRIVATE_LIBS += openblas
else ifeq ($(USE_SYSTEM_LAPACK),0)
Expand Down
24 changes: 12 additions & 12 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ log(b,x) = log(x)./log(b)
# type specific math functions

const libm = Base.libm_name
const openlibm_extras = "libopenlibm-extras"
const openspecfun = "libopenspecfun"

# functions with no domain error
for f in (:cbrt, :sinh, :cosh, :tanh, :atan, :asinh, :exp, :erf, :erfc, :exp2, :expm1)
Expand Down Expand Up @@ -435,7 +435,7 @@ global airy
function airy(k::Int, z::Complex128)
id = int32(k==1 || k==3)
if k == 0 || k == 1
ccall((:zairy_,openlibm_extras), Void,
ccall((:zairy_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z),
Expand All @@ -444,7 +444,7 @@ function airy(k::Int, z::Complex128)
pointer(ae,1), pointer(ae,2))
return complex(ai[1],ai[2])
elseif k == 2 || k == 3
ccall((:zbiry_,openlibm_extras), Void,
ccall((:zbiry_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z),
Expand Down Expand Up @@ -482,7 +482,7 @@ const ae = Array(Int32,2)
const wrk = Array(Float64,2)

function _besselh(nu::Float64, k::Integer, z::Complex128)
ccall((:zbesh_,openlibm_extras), Void,
ccall((:zbesh_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Int32}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z), &nu, &1, &k, &1,
Expand All @@ -492,7 +492,7 @@ function _besselh(nu::Float64, k::Integer, z::Complex128)
end

function _besseli(nu::Float64, z::Complex128)
ccall((:zbesi_,openlibm_extras), Void,
ccall((:zbesi_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z), &nu, &1, &1,
Expand All @@ -502,7 +502,7 @@ function _besseli(nu::Float64, z::Complex128)
end

function _besselj(nu::Float64, z::Complex128)
ccall((:zbesj_,openlibm_extras), Void,
ccall((:zbesj_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z), &nu, &1, &1,
Expand All @@ -512,7 +512,7 @@ function _besselj(nu::Float64, z::Complex128)
end

function _besselk(nu::Float64, z::Complex128)
ccall((:zbesk_,openlibm_extras), Void,
ccall((:zbesk_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}),
&real(z), &imag(z), &nu, &1, &1,
Expand All @@ -522,7 +522,7 @@ function _besselk(nu::Float64, z::Complex128)
end

function _bessely(nu::Float64, z::Complex128)
ccall((:zbesy_,openlibm_extras), Void,
ccall((:zbesy_,openspecfun), Void,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32},
Ptr{Int32}, Ptr{Float64}, Ptr{Float64}, Ptr{Int32},
Ptr{Float64}, Ptr{Float64}, Ptr{Int32}),
Expand Down Expand Up @@ -1183,17 +1183,17 @@ end
for f in (:erf, :erfc, :erfcx, :erfi, :Dawson)
fname = (f === :Dawson) ? :dawson : f
@eval begin
($fname)(z::Complex128) = complex128(ccall(($(string("Faddeeva_",f)),openlibm_extras), Complex{Float64}, (Complex{Float64}, Float64), z, zero(Float64)))
($fname)(z::Complex64) = complex64(ccall(($(string("Faddeeva_",f)),openlibm_extras), Complex{Float64}, (Complex{Float64}, Float64), complex128(z), float64(eps(Float32))))
($fname)(z::Complex128) = complex128(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), z, zero(Float64)))
($fname)(z::Complex64) = complex64(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), complex128(z), float64(eps(Float32))))
($fname)(z::Complex) = ($fname)(complex128(z))
end
end
end
for f in (:erfcx, :erfi, :Dawson)
fname = (f === :Dawson) ? :dawson : f
@eval begin
($fname)(x::Float64) = ccall(($(string("Faddeeva_",f,"_re")),openlibm_extras), Float64, (Float64,), x)
($fname)(x::Float32) = float32(ccall(($(string("Faddeeva_",f,"_re")),openlibm_extras), Float64, (Float64,), float64(x)))
($fname)(x::Float64) = ccall(($(string("Faddeeva_",f,"_re")),openspecfun), Float64, (Float64,), x)
($fname)(x::Float32) = float32(ccall(($(string("Faddeeva_",f,"_re")),openspecfun), Float64, (Float64,), float64(x)))
($fname)(x::Integer) = ($fname)(float(x))
@vectorize_1arg Number $fname
end
Expand Down
70 changes: 44 additions & 26 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ endif
CONFIGURE_COMMON = $(CONFIGURE_OPTIONS) $(CONFIGURE_CC)

#autoconf configure-driven scripts: llvm readline pcre arpack fftw unwind gmp mpfr patchelf uv
#custom configure-driven script: zlib
#custom Makefile rules: openlibm Rmath double-conversion random suitesparse-wrapper suitesparse lapack openblas

# prevent installing libs into usr/lib64 on opensuse
Expand Down Expand Up @@ -56,13 +55,15 @@ endif
## USE_SYSTEM_LIBS options

ifeq ($(USE_SYSTEM_OPENLIBM), 0)
# No matter if we are using a system-libm or not, if we don't have a system-openlibm, we need the extras
STAGE1_DEPS += openlibm-extras
ifeq ($(USE_SYSTEM_LIBM), 0)
STAGE1_DEPS += openlibm
endif
endif

ifeq ($(USE_SYSTEM_OPENSPECFUN), 0)
STAGE1_DEPS += openspecfun
endif

ifeq ($(USE_SYSTEM_LLVM), 0)
STAGE1_DEPS += llvm
endif
Expand Down Expand Up @@ -144,7 +145,7 @@ install: $(addprefix install-, $(LIBS))
cleanall: $(addprefix clean-, $(LIBS))
distclean: $(addprefix distclean-, $(LIBS))
rm -rf $(BUILD)
getall: get-llvm get-readline get-uv get-pcre get-double-conversion get-openlibm get-random get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-zlib get-patchelf
getall: get-llvm get-readline get-uv get-pcre get-double-conversion get-openlibm get-openspecfun get-random get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-zlib get-patchelf

## PATHS ##
DIRS = $(addprefix $(BUILD)/,lib include bin share etc)
Expand Down Expand Up @@ -623,31 +624,24 @@ check-double-conversion: compile-double-conversion
install-double-conversion: $(BUILD)/$(JL_LIBDIR)/libgrisu.$(SHLIB_EXT)


## openlibm && openlibm-extras ##
## openlibm ##

OPENLIBM_FLAGS = ARCH="$(ARCH)" CC="$(CC)" FC="$(FC)" AR="$(AR)" OS="$(OS)" USECLANG=$(USECLANG) USEGCC=$(USEGCC)

OPENLIBM_OBJ_TARGET = $(BUILD)/$(JL_LIBDIR)/libopenlibm.$(SHLIB_EXT)
OPENLIBM_OBJ_SOURCE = openlibm/libopenlibm.$(SHLIB_EXT)
OPENLIBMEXT_OBJ_TARGET = $(BUILD)/$(JL_LIBDIR)/libopenlibm-extras.$(SHLIB_EXT)
OPENLIBMEXT_OBJ_SOURCE = openlibm/libopenlibm-extras.$(SHLIB_EXT)

openlibm/Makefile openlibm/Makefile.extras:
openlibm/Makefile:
(cd .. && git submodule init && git submodule update)
ifeq (exists, $(shell [ -d openlibm/.git ] && echo exists ))
$(OPENLIBM_OBJ_SOURCE): openlibm/.git/HEAD
$(OPENLIBMEXT_OBJ_SOURCE): openlibm/.git/HEAD
endif
ifeq (exists, $(shell [ -d $(JULIAHOME)/.git/modules/deps/openlibm ] && echo exists ))
$(OPENLIBM_OBJ_SOURCE): $(JULIAHOME)/.git/modules/deps/openlibm/HEAD
$(OPENLIBMEXT_OBJ_SOURCE): $(JULIAHOME)/.git/modules/deps/openlibm/HEAD
endif
$(OPENLIBM_OBJ_SOURCE): openlibm/Makefile
$(MAKE) -C openlibm $(OPENLIBM_FLAGS)
touch -c $@
$(OPENLIBMEXT_OBJ_SOURCE): openlibm/Makefile.extras
$(MAKE) -C openlibm -f Makefile.extras $(OPENLIBM_FLAGS)
touch -c $@
$(OPENLIBM_OBJ_TARGET): $(OPENLIBM_OBJ_SOURCE) | $(BUILD)/lib
ifeq ($(OS),WINNT)
cp openlibm/libopenlibm.a $(BUILD)/lib/libopenlibm.a
Expand All @@ -656,31 +650,55 @@ else
endif
cp $< $@
$(INSTALL_NAME_CMD)libopenlibm.$(SHLIB_EXT) $@
$(OPENLIBMEXT_OBJ_TARGET): $(OPENLIBMEXT_OBJ_SOURCE) | $(BUILD)/lib
cp $< $@
$(INSTALL_NAME_CMD)libopenlibm-extras.$(SHLIB_EXT) $@

clean-openlibm:
-$(MAKE) -C openlibm distclean $(OPENLIBM_FLAGS)
-rm $(OPENLIBM_OBJ_TARGET)
distclean-openlibm: clean-openlibm

clean-openlibm-extras:
-$(MAKE) -C openlibm -f Makefile.extras distclean
-rm $(OPENLIBMEXT_OBJ_TARGET)
distclean-openlibm-extras: clean-openlibm-extras

get-openlibm: openlibm/Makefile
configure-openlibm: get-openlibm
compile-openlibm: $(OPENLIBM_OBJ_SOURCE)
check-openlibm: compile-openlibm
install-openlibm: $(OPENLIBM_OBJ_TARGET)

get-openlibm-extras: openlibm/Makefile.extras
configure-openlibm-extras: get-openlibm-extras
compile-openlibm-extras: $(OPENLIBMEXT_OBJ_SOURCE)
check-openlibm-extras: compile-openlibm-extras
install-openlibm-extras: $(OPENLIBMEXT_OBJ_TARGET)
## openspecfun ##

OPENSPECFUN_FLAGS = ARCH="$(ARCH)" CC="$(CC)" FC="$(FC)" AR="$(AR)" OS="$(OS)" USECLANG=$(USECLANG) USEGCC=$(USEGCC) USE_OPENLIBM=1 OPENLIBM_HOME=$(JULIAHOME)/deps/openlibm

OPENSPECFUN_OBJ_TARGET = $(BUILD)/$(JL_LIBDIR)/libopenspecfun.$(SHLIB_EXT)
OPENSPECFUN_OBJ_SOURCE = openspecfun/libopenspecfun.$(SHLIB_EXT)

openspecfun/Makefile openspecfun/Makefile.extras:
(cd .. && git submodule init && git submodule update)
ifeq (exists, $(shell [ -d openspecfun/.git ] && echo exists ))
$(OPENSPECFUN_OBJ_SOURCE): openspecfun/.git/HEAD
endif
ifeq (exists, $(shell [ -d $(JULIAHOME)/.git/modules/deps/openspecfun ] && echo exists ))
$(OPENSPECFUN_OBJ_SOURCE): $(JULIAHOME)/.git/modules/deps/openspecfun/HEAD
endif
$(OPENSPECFUN_OBJ_SOURCE): openspecfun/Makefile
$(MAKE) -C openspecfun $(OPENSPECFUN_FLAGS)
touch -c $@
$(OPENSPECFUN_OBJ_TARGET): $(OPENSPECFUN_OBJ_SOURCE) | $(BUILD)/lib
ifeq ($(OS),WINNT)
cp openspecfun/libopenspecfun.a $(BUILD)/lib/libopenspecfun.a
else
cp openspecfun/libopenspecfun.a $(BUILD)/$(JL_LIBDIR)/libopenspecfun.a
endif
cp $< $@
$(INSTALL_NAME_CMD)libopenspecfun.$(SHLIB_EXT) $@

clean-openspecfun:
-$(MAKE) -C openspecfun distclean $(OPENSPECFUN_FLAGS)
-rm $(OPENSPECFUN_OBJ_TARGET)
distclean-openspecfun: clean-openspecfun

get-openspecfun: openspecfun/Makefile
configure-openspecfun: get-openspecfun
compile-openspecfun: $(OPENSPECFUN_OBJ_SOURCE)
check-openspecfun: compile-openspecfun
install-openspecfun: $(OPENSPECFUN_OBJ_TARGET)

## LIBRANDOM ##

Expand Down
2 changes: 1 addition & 1 deletion deps/openlibm
Submodule openlibm updated from 9bc257 to 320de7
1 change: 1 addition & 0 deletions deps/openspecfun
Submodule openspecfun added at 13863b

0 comments on commit 80b3592

Please sign in to comment.