# Unable to use multiple threads with MPI using Atom IDE

**URL:** <https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995>\
**Category:** New to Julia\
**Tags:** parallel, mpi\
**Created:** [July 30, 2019, 8:59pm UTC](https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995 "2019-07-30T20:59:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@Diego](https://discourse.julialang.org/u/Diego)\
**Post date:** [July 30, 2019, 8:59pm UTC](https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995/1 "2019-07-30T20:59:43Z")

</div>

Team,

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

main()

**This is what I get**

Hello world, I am 0 of 1

I would expect to get four lines as this one.

Thank you!

---

<div class="post-metadata">

**Author:** ![kose-y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kose-y/32/10085_2.png) [@kose-y](https://discourse.julialang.org/u/kose-y)\
**Post date:** [August 20, 2019, 5:25am UTC](https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995/2 "2019-08-20T05:25:13Z")

</div>

There are two simple ways to run MPI on Julia.

One is running with `MPIClusterManager` in [MPIClusterManagers.jl](https://github.com/JuliaParallel/MPIClusterManagers.jl) (MPIClusterManager was previously included in MPI.jl, but it was recently moved to a new package).

```julia
# 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”:

```julia
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.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [August 20, 2019, 7:37am UTC](https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995/3 "2019-08-20T07:37:16Z")

</div>

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).

I normally would have said to look at  
[https://github.com/JuliaParallel/ClusterManagers.jl](https://github.com/JuliaParallel/ClusterManagers.jl)  
This package has not been updated for several months. Does anyone know the status of this package?

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [August 20, 2019, 7:39am UTC](https://discourse.julialang.org/t/unable-to-use-multiple-threads-with-mpi-using-atom-ide/26995/4 "2019-08-20T07:39:27Z")

</div>

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.
