# Help me pls with method error

I’m trying to implement the multiplication of two random matrices 100x100, but every time I get a method error, no matter what I do

``````using MPI

function multiply_matrices()
MPI.Init()

comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)

if rank == 0
A = rand(100, 100)
B = rand(100, 100)
start_time = MPI.Wtime()
else
A = Vector{Matrix{Any}}(100, 100)
B = Vector{Matrix{Any}}(100, 100)
end

MPI.Bcast!(A, 0, comm)
MPI.Bcast!(B, 0, comm)

block_size = 100 // size
local_A = Vector{Matrix{Any}}(block_size, 100)
local_B = Vector{Matrix{Any}}(100, block_size)
local_C = Vector{Matrix{Any}}(block_size, block_size)

if rank == 0
for i in 0:size-1
start_row = i * block_size + 1
end_row = start_row + block_size - 1
MPI.Send(A[start_row:end_row, :], i, 0, comm)
end
local_A = A[1:block_size, :]
else
MPI.Recv!(local_A, 0, rank, comm)
end

MPI.Scatter(B, local_B, block_size * 100, 0, comm)

for i in 1:block_size
for j in 1:block_size
local_C[i, j] = dot(local_A[i, :], local_B[:, j])
end
end

C = zeros(100, 100)
MPI.Gather(local_C, C, block_size, 0, comm)

if rank == 0
elapsed_time = MPI.Wtime() - start_time
println("Время выполнения умножения матриц: ", elapsed_time, " секунд.")
println("Итоговая матрица:")
println(C)
end

MPI.Finalize()
end

multiply_matrices()

``````
``````ERROR: ERROR: ERROR: LoadError: LoadError: LoadError: MethodError: no method matching MethodError: no method matching Vector{Matrix{Any}}(::Int64, ::Int64)Vector{Matrix{Any}}(::Int64, ::Int64)MethodError: no method matching Vector{Matrix{Any}}(::Int64, ::Int64)

Closest candidates are:
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
Vector{T}(!Matched::UndefInitializer, ::Int64) where T
@ Core boot.jl:477
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:15
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59

Closest candidates are:
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
Vector{T}(!Matched::UndefInitializer, ::Int64) where T
@ Core boot.jl:477
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:15
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------

[23916] signal (15): Завершено
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
unknown function (ip: 0x7f2f95c0ee3b)
opal_progress at /lib/x86_64-linux-gnu/libopen-pal.so.40 (unknown line)
ompi_sync_wait_mt at /lib/x86_64-linux-gnu/libopen-pal.so.40 (unknown line)
ompi_request_default_wait_all at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
ompi_coll_base_bcast_intra_basic_linear at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
ompi_coll_tuned_bcast_intra_dec_fixed at /usr/lib/x86_64-linux-gnu/openmpi/lib/openmpi3/mca_coll_tuned.so (unknown line)
MPI_Bcast at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
MPI_Bcast at /home/kirill/.julia/packages/MPI/N1m5D/src/api/generated_api.jl:378
Bcast! at /home/kirill/.julia/packages/MPI/N1m5D/src/collective.jl:56 [inlined]
Bcast! at /home/kirill/.julia/packages/MPI/N1m5D/src/collective.jl:60 [inlined]
multiply_matrices at /home/kirill/Документы/Lesha/proiz.jl:19
unknown function (ip: 0x7f2fb1caa3af)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_call at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:126
eval_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:226
eval_stmt_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:177 [inlined]
eval_body at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:624
jl_interpret_toplevel_thunk at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:762
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:912
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:856
ijl_toplevel_eval_in at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
include at ./Base.jl:457
jfptr_include_43521.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
exec_options at ./client.jl:307
_start at ./client.jl:522
jfptr__start_37386.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
true_main at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7f2fb3029d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x401098)
unknown function (ip: (nil))
Allocations: 2998 (Pool: 2985; Big: 13); GC: 0

[23919] signal (15): Завершено
in expression starting at none:0
obvious_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1594
obvious_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1600
obvious_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1790
ijl_subtype_env at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1925
ijl_type_morespecific at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:4099
ml_matches at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:3449
ijl_matching_methods at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2153
_methods_by_ftype at ./reflection.jl:952 [inlined]
_findall at ./compiler/methodtable.jl:107 [inlined]
#findall#275 at ./compiler/methodtable.jl:76 [inlined]
findall at ./compiler/methodtable.jl:75 [inlined]
#findall#277 at ./compiler/methodtable.jl:123
findall at ./compiler/methodtable.jl:114 [inlined]
find_matching_methods at ./compiler/abstractinterpretation.jl:336
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:80
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[21967,1],3]
Exit code:    1
--------------------------------------------------------------------------
ERROR: failed process: Process(`mpiexec julia proiz.jl`, ProcessExited(1)) [1]

Stacktrace:
[1] pipeline_error
@ ./process.jl:565 [inlined]
[2] run(::Cmd; wait::Bool)
@ Base ./process.jl:480
[3] run(::Cmd)
@ Base process.jl:477
[4] (::var"#3#4")(exe::Cmd)
@ Main none:4
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[6] mpiexec(f::Function)
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[7] top-level scope
@ none:4

``````

Hi, welcome to the forum!

The problem is with `Vector{Matrix{Any}}(100, 100)` (and all the other constructions of `Vector`). `Vector` represents a 1-D array. To construct a vector, you can use, e.g., `zeros(T, m)`, `ones(T, m)`, or `Vector{T}(undef, m)`, where `T` is the element type and `m` is the vector’s length.

However, it looks that you want to construct a matrix (i.e., 2-D array) instead of a vector. For that, you can use, e.g., `zeros(T, m, n)`, `ones(T, m, n)`, or `Matrix{T}(undef, m, n)`, where `T` is the element type, `m` is the number of rows, and `n` is the number of columns.

2 Likes

unfortunately this did not help me, I already tried every method that you suggested before creating the thread, it seems to me that the matter is different

``````using MPI

function multiply_matrices()
MPI.Init()

comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)

if rank == 0
A = rand(100, 100)
B = rand(100, 100)
start_time = MPI.Wtime()
else
A = Matrix{Any}(100, 100)
B = Matrix{Any}(100, 100)
end

MPI.Bcast!(A, 0, comm)
MPI.Bcast!(B, 0, comm)

block_size = 100 // size
local_A = Matrix{Any}(block_size, 100)
local_B = Matrix{Any}(100, block_size)
local_C = Matrix{Any}(block_size, block_size)

if rank == 0
for i in 0:size-1
start_row = i * block_size + 1
end_row = start_row + block_size - 1
MPI.Send(A[start_row:end_row, :], i, 0, comm)
end
local_A = A[1:block_size, :]
else
MPI.Recv!(local_A, 0, rank, comm)
end

MPI.Scatter(B, local_B, block_size * 100, 0, comm)

for i in 1:block_size
for j in 1:block_size
local_C[i, j] = dot(local_A[i, :], local_B[:, j])
end
end

C = zeros(100, 100)
MPI.Gather(local_C, C, block_size, 0, comm)

if rank == 0
elapsed_time = MPI.Wtime() - start_time
println("Время выполнения умножения матриц: ", elapsed_time, " секунд.")
println("Итоговая матрица:")
println(C)
end

MPI.Finalize()
end

multiply_matrices()

``````
``````ERROR: ERROR: ERROR: LoadError: LoadError: LoadError: MethodError: no method matching Matrix{Any}(::Int64, ::Int64)MethodError: no method matching Matrix{Any}(::Int64, ::Int64)MethodError: no method matching Matrix{Any}(::Int64, ::Int64)

Closest candidates are:
Matrix{T}(!Matched::LinearAlgebra.UniformScaling, ::Integer, !Matched::Integer) where T
@ LinearAlgebra /opt/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/uniformscaling.jl:508
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:15
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59

Closest candidates are:
Matrix{T}(!Matched::LinearAlgebra.UniformScaling, ::Integer, !Matched::Integer) where T
@ LinearAlgebra /opt/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/uniformscaling.jl:508
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:15
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------

[24699] signal (15): Завершено
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
opal_progress at /lib/x86_64-linux-gnu/libopen-pal.so.40 (unknown line)
ompi_sync_wait_mt at /lib/x86_64-linux-gnu/libopen-pal.so.40 (unknown line)
ompi_request_default_wait_all at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
ompi_coll_base_bcast_intra_basic_linear at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
ompi_coll_tuned_bcast_intra_dec_fixed at /usr/lib/x86_64-linux-gnu/openmpi/lib/openmpi3/mca_coll_tuned.so (unknown line)
MPI_Bcast at /lib/x86_64-linux-gnu/libmpi.so (unknown line)
MPI_Bcast at /home/kirill/.julia/packages/MPI/N1m5D/src/api/generated_api.jl:378
Bcast! at /home/kirill/.julia/packages/MPI/N1m5D/src/collective.jl:56 [inlined]
Bcast! at /home/kirill/.julia/packages/MPI/N1m5D/src/collective.jl:60 [inlined]
multiply_matrices at /home/kirill/Документы/Lesha/proiz.jl:19
unknown function (ip: 0x7fa4b66473af)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_call at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:126
eval_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:226
eval_stmt_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:177 [inlined]
eval_body at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:624
jl_interpret_toplevel_thunk at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:762
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:912
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:856
ijl_toplevel_eval_in at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
include at ./Base.jl:457
jfptr_include_43521.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
exec_options at ./client.jl:307
_start at ./client.jl:522
jfptr__start_37386.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
true_main at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7fa4b7a29d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x401098)
unknown function (ip: (nil))
Allocations: 2997 (Pool: 2985; Big: 12); GC: 0

[24700] signal (15): Завершено
in expression starting at none:0
obviously_disjoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:362 [inlined]
obviously_disjoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:430
obviously_disjoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:362 [inlined]
ijl_type_morespecific at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:4093
ml_matches at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:3449
ijl_matching_methods at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2153
_methods_by_ftype at ./reflection.jl:952 [inlined]
_findall at ./compiler/methodtable.jl:107 [inlined]
#findall#275 at ./compiler/methodtable.jl:76 [inlined]
findall at ./compiler/methodtable.jl:75 [inlined]
#findall#277 at ./compiler/methodtable.jl:123
findall at ./compiler/methodtable.jl:114 [inlined]
find_matching_methods at ./compiler/abstractinterpretation.jl:336
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:80
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_ext at ./compiler/typeinfer.jl:1058
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1091
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[26832,1],3]
Exit code:    1
--------------------------------------------------------------------------
ERROR: failed process: Process(`mpiexec julia proiz.jl`, ProcessExited(1)) [1]

Stacktrace:
[1] pipeline_error
@ ./process.jl:565 [inlined]
[2] run(::Cmd; wait::Bool)
@ Base ./process.jl:480
[3] run(::Cmd)
@ Base process.jl:477
[4] (::var"#3#4")(exe::Cmd)
@ Main none:4
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[6] mpiexec(f::Function)
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[7] top-level scope
@ none:4

``````

This is the same problem still. You are now calling a constructor of `Matrix` which does not exist. You cannot create a matrix like this. To create a matrix with uninitialized elements, use

``````A = Matrix{Any}(undef, 100, 100)
``````

which creates a 100x100 matrix of uninitialized elements of type `Any`. Consider replacing `Any` with a concrete type. I am not familiar with your code but it seems that `Float64` should work, i.e.,

``````A = Matrix{Float64}(undef, 100, 100)
``````

Also note that using this constructor is generally discouraged due to the danger of accessing and using the uninitialized elements on accident:

``````julia> A = Matrix{Float64}(undef, 100, 100);

julia> A[1,1]
7.753566e-317
``````

You can use `zeros(100, 100)` instead, to get zeroed matrix of size 100x100.

2 Likes

alas, this does not help either, neither the mention of undef, nor the zeros method. In any case, there will be a method error. I don’t know what’s the matter…

``````RROR: ERROR: ERROR: ERROR: LoadError: LoadError: LoadError: LoadError: MethodError: no method matching Matrix{Float64}(::UndefInitializer, ::Rational{Int64}, ::Int64)MethodError: no method matching Matrix{Float64}(::UndefInitializer, ::Rational{Int64}, ::Int64)MethodError: no method matching Matrix{Float64}(::UndefInitializer, ::Rational{Int64}, ::Int64)MethodError: no method matching Matrix{Float64}(::UndefInitializer, ::Rational{Int64}, ::Int64)

Closest candidates are:
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
Matrix{T}(::UndefInitializer, !Matched::Int64, ::Int64) where T
@ Core boot.jl:479
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:23
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------

[28026] signal (15): Завершено
in expression starting at none:0
jl_is_kind at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1280 [inlined]
jl_is_type at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1286 [inlined]
var_gt at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:676
subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1231
local_forall_exists_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1398
forall_exists_equal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1426
subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1304
subtype_unionall at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:793
subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1257
subtype_unionall at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:800
subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1254
exists_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1441 [inlined]
_forall_exists_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1473
forall_exists_subtype at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1489 [inlined]
ijl_subtype_env at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:1937
jl_type_intersection_env_s at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:3526
jl_type_intersection_env at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:3611 [inlined]
ijl_type_intersection_with_env at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/subtype.c:3624
make_typealias at ./show.jl:614
show_typealias at ./show.jl:790
_show_type at ./show.jl:955
show at ./show.jl:950
jfptr_show_43092.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
show_typeparams at ./show.jl:699
show_datatype at ./show.jl:1092
_show_type at ./show.jl:992
show at ./show.jl:950
print at ./strings/io.jl:35
print at ./strings/io.jl:46
jfptr_print_28797.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
show_method_candidates at ./errorshow.jl:460
showerror at ./errorshow.jl:326
#showerror#898 at ./errorshow.jl:88
showerror at ./errorshow.jl:86
unknown function (ip: 0x7f861bb365ba)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
#showerror#899 at ./errorshow.jl:96
showerror at ./errorshow.jl:94
unknown function (ip: 0x7f861bb03d12)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
show_exception_stack at ./errorshow.jl:895
display_error at ./client.jl:111
unknown function (ip: 0x7f861bb03456)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940

Closest candidates are:
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
Matrix{T}(::UndefInitializer, !Matched::Int64, ::Int64) where T
@ Core boot.jl:479
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:23
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59

[28028] signal (15): Завершено
in expression starting at none:0
_ZN12_GLOBAL__N_114SimplifyCFGOpt18simplifyCondBranchEPN4llvm10BranchInstERNS1_9IRBuilderINS1_14ConstantFolderENS1_24IRBuilderDefaultInserterEEE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm11simplifyCFGEPNS_10BasicBlockERKNS_19TargetTransformInfoEPNS_14DomTreeUpdaterERKNS_18SimplifyCFGOptionsENS_8ArrayRefINS_6WeakVHEEE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZL22iterativelySimplifyCFGRN4llvm8FunctionERKNS_19TargetTransformInfoEPNS_14DomTreeUpdaterERKNS_18SimplifyCFGOptionsE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZL23simplifyFunctionCFGImplRN4llvm8FunctionERKNS_19TargetTransformInfoEPNS_13DominatorTreeERKNS_18SimplifyCFGOptionsE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
operator() at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:1152
operator() at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:1117 [inlined]
emit at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:631
_ZN4llvm3orc31BasicIRLayerMaterializationUnit11materializeESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession22dispatchOutstandingMUsEv at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession17OL_completeLookupESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EESt10shared_ptrINS0_23AsynchronousSymbolQueryEESt8functionIFvRKNS_8DenseMapIPNS0_8JITDylibENS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISF_vEEEENSG_ISD_vEENS_6detail12DenseMapPairISD_SI_EEEEEE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc25InProgressFullLookupState8completeESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession19OL_applyQueryPhase1ESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EENS_5ErrorE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16Execution

Closest candidates are:
Array{T, N}(!Matched::Nothing, ::Any...) where {T, N}
@ Base baseext.jl:42
Array{T, N}(!Matched::Missing, ::Any...) where {T, N}
@ Base baseext.jl:43
Matrix{T}(::UndefInitializer, !Matched::Int64, ::Int64) where T
@ Core boot.jl:479
...

Stacktrace:
[1] multiply_matrices()
@ Main ~/Документы/Lesha/proiz.jl:23
[2] top-level scope
@ ~/Документы/Lesha/proiz.jl:59
in expression starting at /home/kirill/Документы/Lesha/proiz.jl:59
Session6lookupENS0_10LookupKindERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS8_EENS0_15SymbolLookupSetENS0_11SymbolStateENS_15unique_functionIFvNS_8ExpectedINS_8DenseMapINS0_15SymbolStringPtrENS_18JITEvaluatedSymbolENS_12DenseMapInfoISI_vEENS_6detail12DenseMapPairISI_SJ_EEEEEEEEESt8functionIFvRKNSH_IS6_NS_8DenseSetISI_SL_EENSK_IS6_vEENSN_IS6_SV_EEEEEE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS7_EERKNS0_15SymbolLookupSetENS0_10LookupKindENS0_11SymbolStateESt8functionIFvRKNS_8DenseMapIS5_NS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISK_vEEEENSL_IS5_vEENS_6detail12DenseMapPairIS5_SN_EEEEEE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS7_EENS0_15SymbolStringPtrENS0_11SymbolStateE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupENS_8ArrayRefIPNS0_8JITDylibEEENS0_15SymbolStringPtrENS0_11SymbolStateE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupENS_8ArrayRefIPNS0_8JITDylibEEENS_9StringRefENS0_11SymbolStateE at /opt/julia-1.9.0/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_jl_compile_codeinst at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:241
jl_generate_fptr_impl at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:460
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2348 [inlined]
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2237
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2750 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
_atexit at ./initdefs.jl:384
jfptr__atexit_36489.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
ijl_atexit_hook at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/init.c:280
ijl_exit at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/init.c:207
exit at ./initdefs.jl:28 [inlined]
exec_options at ./client.jl:312
_start at ./client.jl:522
jfptr__start_37386.clone_1 at /opt/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
true_main at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7fdff4229d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x401098)
unknown function (ip: (nil))
Allocations: 2461804 (Pool: 2458264; Big: 3540); GC: 4
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[26066,1],3]
Exit code:    1
--------------------------------------------------------------------------
ERROR: failed process: Process(`mpiexec julia proiz.jl`, ProcessExited(1)) [1]

Stacktrace:
[1] pipeline_error
@ ./process.jl:565 [inlined]
[2] run(::Cmd; wait::Bool)
@ Base ./process.jl:480
[3] run(::Cmd)
@ Base process.jl:477
[4] (::var"#3#4")(exe::Cmd)
@ Main none:4
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[6] mpiexec(f::Function)
@ MPIPreferences.System ~/.julia/packages/MPIPreferences/cvCac/src/system.jl:7
[7] top-level scope
@ none:4

``````

This is a problem, because `//` in Julia does not produce an integer but instead a rational number, e.g.

``````julia> 100 // 2
50//1

julia> 100 // 2 |> typeof
Rational{Int64}
``````

So you need to convert the result explicitly, e.g.

``````julia> Int64(100 // 2)
50

julia> Int64(100 // 2) |> typeof
Int64
``````
2 Likes

ok, I fixed it, but now there is a question that when I try to execute the code, it goes into eternal waiting, I don’t know why

``````using MPI

function multiply_matrices()
MPI.Init()

comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)

if rank == 0
A = rand(100, 100)
B = rand(100, 100)
start_time = MPI.Wtime()
else
A = zeros(100, 100)
B = zeros(100, 100)
end

MPI.Bcast!(A, 0, comm)
MPI.Bcast!(B, 0, comm)

block_size = Int64(100 // size)
local_A = zeros(block_size, 100)
local_B = zeros(100, block_size)
local_C = zeros(block_size, block_size)

if rank == 0
for i in 0:size-1
start_row = i * block_size + 1
end_row = start_row + block_size - 1
MPI.Send(A[start_row:end_row, :], i, 0, comm)
end
local_A = A[1:block_size, :]
else
MPI.Recv!(local_A, 0, rank, comm)
end

MPI.Scatter(B, local_B, block_size * 100, 0, comm)

for i in 1:block_size
for j in 1:block_size
local_C[i, j] = dot(local_A[i, :], local_B[:, j])
end
end

C = zeros(100, 100)
MPI.Gather(local_C, C, block_size, 0, comm)

if rank == 0
elapsed_time = MPI.Wtime() - start_time
println("Время выполнения умножения матриц: ", elapsed_time, " секунд.")
println("Итоговая матрица:")
println(C)
end

MPI.Finalize()
end

multiply_matrices()
``````

Are you sure your calls to `MPI.Scatter, MPI.Gather` are correct?

The documentation does not list any ‘public’ methods with 5 arguments, cf. (you can check yourself by typing `? MPI.Scatter` in the REPL):

``````help?> MPI.Scatter
Scatter(sendbuf, T, comm::Comm; root::Integer=0)

Splits the buffer sendbuf in the root process into Comm_size(comm) chunks, sending the j-th chunk to the process of rank j-1 as an object of type T.

≡≡≡≡≡≡≡≡≡≡

•  Scatter!

help?> MPI.Gather
Gather(sendbuf, comm::Comm; root=0)

Each process sends the contents of the buffer sendbuf to the root process. The root allocates the output buffer and stores elements in rank order.

sendbuf can be an AbstractArray or a scalar, and should be the same length on all processes.

≡≡≡≡≡≡≡≡≡≡

•  Gather! for the mutating operation.

•  Gatherv! if the number of elements varies between processes.

•  Allgather!/Allgather to send the result to all processes.

≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

•  MPI_Gather man page: OpenMPI (https://www.open-mpi.org/doc/current/man3/MPI_Gather.3.php), MPICH
(https://www.mpich.org/static/docs/latest/www3/MPI_Gather.html)

``````

Or alternatively check on the website: Collective communication · MPI.jl

Which version of Julia and `MPI.jl` are you on?
You can check with `versioninfo()` and `using Pkg; Pkg.status()`.

Also, instead of trying to write a MPI program from scratch (especially if you are new to Julia), I would recommend starting from an example from the docs here Hello world · MPI.jl and progressively modify things till you get it to do what you want.

yes, I also thought about it, but I saw these lines on another site and wrote in their likeness
julia version 1.9.0
and mpi.jl version is 0.20.9

Disclaimer: I am no MPI expert, yet
But my guess is that the problem already appears when you call `Send, Recv`, since according to the docs, those are blocking operations.

So,I could get your code to work, but I think what you have written so far does not compute the full matrix multiplication, but only the block diagonals of the result of `A * B`.
Anyways, here is the code

``````using MPI
using LinearAlgebra

function multiply_matrices()
MPI.Init()

comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)

N = 16
if rank == 0
A = rand(N, N)
B = rand(N, N)
start_time = MPI.Wtime()
else
A = zeros(N, N)
B = zeros(N, N)
end

block_size = Int64(N // size)
local_A = zeros(block_size, N)
local_B = zeros(N, block_size)
local_C = zeros(block_size, block_size)

if rank == 0
for i in 1:size-1
start_row = i * block_size + 1
end_row = start_row + block_size - 1
MPI.Send(A[start_row:end_row, :], comm, dest=i, tag=123)
end
local_A = A[1:block_size, :]
else
MPI.Recv!(local_A, comm, source=0, tag=123)
end

MPI.Scatter!(B, local_B, comm)

for i in 1:block_size
for j in 1:block_size
local_C[i, j] = dot(local_A[i, :], local_B[:, j])
end
end

C = MPI.Gather(local_C, comm)

if rank == 0
ref_C = A*B
for i = 1:size
nblock = block_size^2
rng = 1+(i-1)*nblock:i*nblock
Ci = reshape(C[rng], (block_size,block_size))
ref_rng = 1+(i-1)*block_size:i*block_size
ref_Ci = ref_C[ref_rng,ref_rng]
println("\$i-th diagonal block")
println("computed with MPI")
display(Ci)
println("reference")
display(ref_Ci)
end
end

MPI.Finalize()
end

multiply_matrices()
``````

Running with `mpiexecjl --project=<path> -n 4 julia mwe.jl` (see here Usage · MPI.jl under `Installation` on how to get `mpiexecjl`; `<path>` should point to where your project’s `Project.toml` or leave it out if you work in the global environment) gives the following:

``````1-th diagonal block
computed with MPI
4×4 Matrix{Float64}:
4.14722  3.58427  4.37421  3.53798
4.52083  3.74548  4.58644  3.85746
4.65688  4.03994  4.39647  3.59721
5.31465  4.36682  5.29969  4.39872
reference
4×4 Matrix{Float64}:
4.14722  3.58427  4.37421  3.53798
4.52083  3.74548  4.58644  3.85746
4.65688  4.03994  4.39647  3.59721
5.31465  4.36682  5.29969  4.39872
2-th diagonal block
computed with MPI
4×4 Matrix{Float64}:
3.69445  4.80673  4.54436  4.58213
3.53487  4.78599  3.98521  3.64105
4.9125   6.46701  5.05266  4.9988
3.27554  3.53021  3.65839  2.91575
reference
4×4 Matrix{Float64}:
3.69445  4.80673  4.54436  4.58213
3.53487  4.78599  3.98521  3.64105
4.9125   6.46701  5.05266  4.9988
3.27554  3.53021  3.65839  2.91575
3-th diagonal block
computed with MPI
4×4 Matrix{Float64}:
4.2344   2.86953  5.0119   4.41964
4.18171  2.68049  4.20287  5.11621
4.46376  4.39696  5.56258  6.48347
4.35201  3.65179  4.92598  5.14869
reference
4×4 Matrix{Float64}:
4.2344   2.86953  5.0119   4.41964
4.18171  2.68049  4.20287  5.11621
4.46376  4.39696  5.56258  6.48347
4.35201  3.65179  4.92598  5.14869
4-th diagonal block
computed with MPI
4×4 Matrix{Float64}:
4.39141  4.41275  4.82654  4.11908
4.18137  4.63556  5.06584  4.67609
3.72779  3.84185  4.11875  3.7276
4.36732  4.56556  5.26016  4.48598
reference
4×4 Matrix{Float64}:
4.39141  4.41275  4.82654  4.11908
4.18137  4.63556  5.06584  4.67609
3.72779  3.84185  4.11875  3.7276
4.36732  4.56556  5.26016  4.48598
``````

EDIT: Replaced `MPI.Isend, MPI.Waitall` with `MPI.Send`.

IIUC then the reason for why it did not complete was that your initial version only sent something to process 0 (here `MPI.Send(A[start_row:end_row, :], i, 0, comm)`), but all the other processes where waiting and blocking here `MPI.Recv!(local_A, 0, rank, comm)` – so this was a deadlock.