You can build Julia with MKL (see the build instructions in the README). 
Then you example (slightly modified) simply works by:

julia> function myasum(n::Integer, X::Vector{Float64}, incx::Integer)
         ccall((:cblas_dasum, :libmkl_rt), 
               Float64, 
               (Int64, Ptr{Float64}, Int64),
               n, X, incx)
       end
myasum (generic function with 1 method)

julia> X = Float64[1,2,3]
3-element Array{Float64,1}:
 1.0
 2.0
 3.0

julia> myasum(3,X,1)
6.0

To get your paths right, try the equivalent of 

source /opt/intel/composer_xe_2015/mkl/bin/mklvars.sh intel64 ilp64

On Friday, October 16, 2015 at 9:37:13 PM UTC+2, Lionel du Peloux wrote:
>
>
> Dear all,
>
> I'm struggling with the Julia C-API. I've installed the last version of 
> the Intel Composer on my Mac (MKL & C++ compiler).
> I thought I could call MKL directly from Julia with the C-API as explained 
> in the doc, using MKL Single Dynamic Library 
> <https://registrationcenter.intel.com/irc_nas/2690/mkl_userguide_mac.pdf>(SDL)
>  
> model.
>
> I've tried to wrap the asum for double (inspired by the Base.LinAlg.BLAS 
> source code) :
>
> function myasum(n::Integer, X::Vector{Float64}, incx::Integer)
>   ccall((:cblas_dasum, "/opt/intel/mkl/lib/libmkl_rt"), 
>         Float64, 
>         (Ptr{Int64}, Ptr{Float64}, Ptr{Int64}),
>         &n, X, &incx)
> end
>
> X = Float64[1,2,3]
> myasum(3,X,1)
>
> It seems the dylib is reached and the "cblas_dasum" is the right name to 
> call (otherwidse I get some errors about that).
>
> But now my Julia gets into this error :
> Intel MKL FATAL ERROR:
> Cannot load libmkl_intel_thread.dylib.
>
> I've tried to add /opt/intel/mkl/lib and /opt/intel/lib directories to my 
> PATH, but I still get the same error ...
>
> Do you have any though how I can make it work ??
>
> Thank you for helping,
> Lionel
>
>
>
>
>
>
>

Reply via email to