In [1]:
using PyPlot
include("julia/laplace1D_devec.jl")
Out[1]:
In [1]:
#Boundary conditions.
a=0.0;
b=1.0;
#Number of grid points.
N=1000;
#Richardson iteration parameter.
alpha=1.0/2.0;
#Number of Richardson iterations.
iter=1000*N;
#Output vectors
u_c=zeros(N);
u_jl=zeros(N);
#Discretized domain
x=linspace(0,1,N);
In [1]:
#Time the C code
time_c = time()
ccall( (:driver,"./c/laplace1D.so"), # 2-tuple containing symbol and shared library path
Void, #Return type.
(Float64,Int64,Int64,Float64,Float64,Ptr{Float64}), #Function signature.
alpha,iter,N,a,b,u_c); #Arguments to C function. (Julia handles marshalling for you.)
time_c = time() - time_c;
plot(x,u_c);
In [1]:
#Time the Julia code
time_jl = time();
driver_devec(alpha,iter,N,a,b,u_jl);
time_jl = time() - time_jl;
plot(x,u_jl);
In [2]:
time_ratio=time_jl/time_c
Out[2]:
In [2]:
@profile driver_devec(alpha,iter,N,a,b,u_jl);
In [3]:
Profile.print()
In [5]:
In [6]:
In [7]:
In [8]:
In [9]:
In [ ]: