c++ - How do I use the mpi.h in XCode? -
i have installed mpich3.2 following direction in given website
http://mpitutorial.com/tutorials/installing-mpich2/
i downloaded tar file , in downloads/ directory , installed using terminal.i wanted test if program works on local machine before submit remote machine.
the problem when write header #include "mpi.h" xcode doesn't recognize it. how add mpich library xcode ? or how make xcode compiles using mpi?
i, personally, go (please note never compile mpi code in xcode - via makefile, cmake).
i have got mpi installed in location (from sources) - take here how it: running open mpi on macos
then, i'd have created supper simple mpi code (e.g. this)
#include <stdio.h> #include "mpi.h" int main(int argc, char * argv[]){ int my_rank, p, n; mpi_init(&argc, &argv); mpi_comm_size(mpi_comm_world, &p); mpi_comm_rank(mpi_comm_world, &my_rank); printf("size: %d rank: %d\n", p, my_rank); mpi_finalize(); }
then, i'd have compiled using mpicc (as mentioned @gilles).
> mpicc -v -o mpi ./mpi.c > mpirun -np 4 ./mpi size: 4 rank: 1 size: 4 rank: 2 size: 4 rank: 0 size: 4 rank: 3
option -v
give locations need. then, i'd have taken these options xcode.
you can use mpicc -show
flags required build mpi based code.
in fact, should work out of box. take here:
you need set includes (as @ picture)
and mpi lib (as in picture)
and, should able run well
to running using mpirun
, make sure set: product->scheme->edit scheme
. and, make sure change arguments
to
and executable
mpirun
- should inside bin
directory have mpi installed.
Comments
Post a Comment