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]
include_string at ./loading.jl:1864
_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 ./loading.jl:1924
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
[5] mpiexec(f::var"#3#4"; adjust_PATH::Bool, adjust_LIBPATH::Bool)
@ 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