Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: julia
os:
- linux
- osx
julia:
- 0.5
- nightly
notifications:
email: false
sudo: false
after_success:
- julia -e 'cd(Pkg.dir("VML")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
14 changes: 8 additions & 6 deletions src/VML.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module VML

import Base: .^, ./

# TODO detect CPU architecture
const lib = :libmkl_vml_avx
Libdl.dlopen(:libmkl_rt)
Expand Down Expand Up @@ -49,7 +51,7 @@ function vml_prefix(t::DataType)
end

function def_unary_op(tin, tout, jlname, jlname!, mklname)
mklfn = Base.Meta.quot(symbol("$(vml_prefix(tin))$mklname"))
mklfn = Base.Meta.quot(Symbol("$(vml_prefix(tin))$mklname"))
exports = Symbol[]
isa(jlname, Expr) || push!(exports, jlname)
isa(jlname!, Expr) || push!(exports, jlname!)
Expand Down Expand Up @@ -80,7 +82,7 @@ function def_unary_op(tin, tout, jlname, jlname!, mklname)
end

function def_binary_op(tin, tout, jlname, jlname!, mklname, broadcast)
mklfn = Base.Meta.quot(symbol("$(vml_prefix(tin))$mklname"))
mklfn = Base.Meta.quot(Symbol("$(vml_prefix(tin))$mklname"))
exports = Symbol[]
isa(jlname, Expr) || push!(exports, jlname)
isa(jlname!, Expr) || push!(exports, jlname!)
Expand Down Expand Up @@ -113,8 +115,8 @@ for t in (Float32, Float64, Complex64, Complex128)
def_unary_op(t, t, :(Base.log), :log!, :Ln)

# Binary, real or complex
def_binary_op(t, t, :(Base.(:.^)), :pow!, :Pow, true)
def_binary_op(t, t, :(Base.(:./)), :divide!, :Div, true)
def_binary_op(t, t, :(.^), :pow!, :Pow, true)
def_binary_op(t, t, :(./), :divide!, :Div, true)
end

for t in (Float32, Float64)
Expand Down Expand Up @@ -153,7 +155,7 @@ for t in (Float32, Float64)
def_unary_op(t, t, :(Base.log10), :log10!, :Log10)

# .^ to scalar power
mklfn = Base.Meta.quot(symbol("$(vml_prefix(t))Powx"))
mklfn = Base.Meta.quot(Symbol("$(vml_prefix(t))Powx"))
@eval begin
export pow!
function pow!{N}(out::Array{$t,N}, A::Array{$t,N}, b::$t)
Expand All @@ -162,7 +164,7 @@ for t in (Float32, Float64)
vml_check_error()
out
end
function Base.(:(.^)){N}(A::Array{$t,N}, b::$t)
function (.^){N}(A::Array{$t,N}, b::$t)
out = similar(A)
ccall(($mklfn, lib), Void, (Int, Ptr{$t}, $t, Ptr{$t}), length(A), A, b, out)
vml_check_error()
Expand Down
6 changes: 3 additions & 3 deletions test/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const base_unary_real = (
const base_binary_real = (
(Base.atan2, (-1, 1), (-1, 1)),
(Base.hypot, (-1000, 1000), (-1000, 1000)),
(Base.(:./), (-1000, 1000), (-1000, 1000)),
(Base.(:.^), (0, 100), (-5, 20))
(getfield(Base, :./), (-1000, 1000), (-1000, 1000)),
(getfield(Base, :.^), (0, 100), (-5, 20))
)

const base_unary_complex = (
Expand All @@ -62,7 +62,7 @@ const base_unary_complex = (
)

const base_binary_complex = (
(Base.(:./), (-1000, 1000), (-1000, 1000)),
(getfield(Base, :./), (-1000, 1000), (-1000, 1000)),
# (Base.(:.^), (0, 100), (-2, 10))
)

Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
run(`$(joinpath(JULIA_HOME, "julia")) $(joinpath(dirname(@__FILE__), "real.jl"))`)
run(`$(joinpath(JULIA_HOME, "julia")) $(joinpath(dirname(@__FILE__), "complex.jl"))`)
include("common.jl")