# MPI.jl: Functions for cartesian process topology

**URL:** https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437
**Category:** Julia at Scale
**Tags:** question
**Created:** [January 9, 2019, 4:09pm UTC](https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437 "2019-01-09T16:09:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)
#### Post date: [January 9, 2019, 4:09pm UTC](https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437/1 "2019-01-09T16:09:05Z")

</div>

Hi all,

I cannot find any functions to create and use a cartesian process topology on the [list of supported functions on the github page of MPI.jl](https://github.com/JuliaParallel/MPI.jl#currently-wrapped-mpi-functions). In particular, I am missing the functions:

- MPI\_Dims\_create
- MPI\_Cart\_create
- MPI\_Cart\_coords
- MPI\_Cart\_shift

Are these functions not wrapped or am I missing something? If they are missing, could they be added?

Thanks!

Sam

---

<div class="post-metadata">

### Author: ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)
#### Post date: [January 9, 2019, 5:38pm UTC](https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437/2 "2019-01-09T17:38:12Z")

</div>

You are correct that they have not been wrapped. I shouldn’t be too difficult to add them, but I don’t know if anyone has the right combination of time and motivation to do so. If you want to add them yourself and submit a pull request, the general procedure is:

1. Add the function name to [gen\_functions.c](https://github.com/JuliaParallel/MPI.jl/blob/master/deps/gen_functions.c).
2. Run `deps/build.jl`. This will update the list of function names. The purpose of the `printf` statements in `gen_functions.c` is to create global constants in Julia (the name following the colon).
3. In [mpi-base.jl](https://github.com/JuliaParallel/MPI.jl/blob/master/src/mpi-base.jl), add a Julia function containing a `ccall`, using the global constants created in steps 1 and 2. This function should have exactly the same arguments at the MPI function. Note that MPI.jl uses the Fortran MPI interface, so scalar arguments need an extra `Ref` around them.
4. If you want, create higher-level functions that call the function written in step 3. For example, `MPI_Dims_create` takes an array and an integer argument specifying the array length. You could create a function that takes the array but not the length argument, and call `length` on the array.
5. Add a test. The test need to be just enough to make sure the arguments are getting passed through the `ccall` correctly.

---

<div class="post-metadata">

### Author: ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)
#### Post date: [January 10, 2019, 8:05am UTC](https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437/3 "2019-01-10T08:05:24Z")

</div>

Thanks for the explanation @JaredCrean2! It looks pretty straightforward, even for a Julia-newcomer like me. I will do a PR.

---

<div class="post-metadata">

### Author: ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)
#### Post date: [January 21, 2019, 8:20am UTC](https://discourse.julialang.org/t/mpi-jl-functions-for-cartesian-process-topology/19437/4 "2019-01-21T08:20:21Z")

</div>

This is then solved now. Here is my PR: [Add functions for Cartesian process topology by samo-lin · Pull Request #227 · JuliaParallel/MPI.jl · GitHub](https://github.com/JuliaParallel/MPI.jl/pull/227)
