Dear all, I'm using the following function in a broader algorithm.
The sequential part (commented) of the code works. Then, when I replace 
this part with the parallel one, this function still works but full 
algorithm crashes. I give the error message thereafter.

function get_n_order_basis(mi::Array{Int64}, mil::Array{Array{Int64}}, 
bl::Array{Array{Float64}})
    mils = get_included_multi_index_list(mi, mil)
    n_mils = length(mils)
    il = get_index(mils, mil)
    vec_te = evaluate_tensor_product(mi, mil, bl)
    ns = length(vec_te)
# # sequential version of the code
#    mat_b = vec_list_to_mat(bl[il])
#    mat_a = zeros(n_mils, n_mils)
#    for i = 1:n_mils
#        mat_a[i,:] = mat_b[:,i]' * mat_b / ns
#    end
# # # # # # # # # # # # # # # # # # # # # #
# # parallel version of the code with shared array
    smat_a = SharedArray(Float64, (n_mils, n_mils), pids = workers())
    smat_b = convert(SharedArray{Float64,2}, vec_list_to_mat(bl[il]))
    @sync begin
        for p in procs(smat_a)
            @async remotecall_wait(p, compute_smat_a!, smat_a, smat_b)
        end
    end
    mat_a = sdata(smat_a)
# # # # # # # # # # # # # # # # # # # # # #
    vec_d = - mat_b' * vec_te / ns
    vec_l = mat_a \ vec_d

    vec_b = vec_te - mean(vec_te)
    [vec_b += vec_l[i] * (mat_b[:,i] - mean(mat_b[:,i])) for i = 1:n_mils]
    return vec_b
end

Here's the error message (seems to be a memory leak but I'm not sure):

*** Error in `julia': double free or corruption (!prev): 0x00000000064e7f20 
***

signal (6): Abandon
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fc680dfa394)
unknown function (ip: 0x7fc680e0666e)
jl_gc_collect at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
jl_gc_alloc_3w at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
....

This error appears when i'm using the following function with the option 
"ordinary_least_square". Th option "lasso" works and obviously, everything 
works in the sequential case.

function get_coefficients(vec_sol::Array{Float64}, 
mil::Array{Array{Int64}}, bl::Array{Array{Float64}}, 
cfg::gsobol_configuration)
    nbr_obs = length(vec_sol)
    mat_b = vec_list_to_mat(bl[2:end])
    vec_y = vec_sol - mean(vec_sol)

    if cfg.reg_method == "ordinary_least_square"
    # failing code
        vec_c = inv(mat_b' * mat_b) * (mat_b' * vec_y)
    elseif cfg.reg_method == "lasso"
    # working code
        rp = glmnetcv(mat_b, vec_y; intercept = false, standardize = true)
        opt = indmin(rp.meanloss)
        vec_c = rp.path.betas[:,opt]
    end

    cl = Array(Float64, length(mil))
    cl[1] = mean(vec_sol)
    cl[2:end] = vec_c
    return cl
end


Any ideas?
Thank you.

Reply via email to