I am starting to use the MPI library with Atom IDE. However, I am still unsucessful as by some reason the system is only considering a single thread. I know that to enable multiple threads with Atom I have to use the addprocs command.
Any ideas?
This is the code
using MPI
using Distributed
addprocs(4)
function do_hello()
comm = MPI.COMM_WORLD
println(“Hello world, I am (MPI.Comm_rank(comm)) of (MPI.Comm_size(comm))”)
MPI.Barrier(comm)
end
function main()
MPI.Init()
MPI.addprocs(4)
do_hello()
MPI.Finalize()
end
One is running with MPIClusterManager in MPIClusterManagers.jl (MPIClusterManager was previously included in MPI.jl, but it was recently moved to a new package).
# to import MPIManager
using MPIClusterManagers
# need to also import Distributed to use addprocs()
using Distributed
# specify, number of mpi workers, launch cmd, etc.
manager=MPIManager(np=4)
# start mpi workers and add them as julia workers too.
addprocs(manager)
@mpi_do manager begin
using MPI
comm=MPI.COMM_WORLD
println("Hello world, I am $(MPI.Comm_rank(comm)) of $(MPI.Comm_size(comm))")
end
This does not require a special command to run, so I think it should run on Atom IDE (I have not used Atom IDE before).
Another way is running Julia using mpirun command. First save the following code as “hello.jl”:
using MPI
MPI.Init()
comm = MPI.COMM_WORLD
print("Hello world, I am rank $(MPI.Comm_rank(comm)) of $(MPI.Comm_size(comm))\n")
MPI.Barrier(comm)
and execute it with the command mpirun -np 4 hello.jl to execute it with four processes.
Hi @Diego Great to see you here. I hope I can help a little - I use Atom also.
As @kose-y says MPI needs a ‘launcher’ - this will launch separate MPI processes on the local machine or on remote machines. Indeed in HPC there is a lot of though given to the physical layout of these processes - perhaps pinning processes to specific cores, or grouping processes on machines which are connected tot thew same network switch (to reduce latency).
One other general point about MPI. This is not aimed at the original poster!
There are many implementations of the MPI standard. For local development it is of course appropriate to use the MPI which is packaged with your Linux or Mac OS.
Just be aware that these are usually out of date. The latest versions will have more features and bug fixes. Also the other MPI implementations may perform better for you.