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)

enter image description here

and mpi lib (as in picture)

enter image description here

and, should able run well

enter image description here

to running using mpirun, make sure set: product->scheme->edit scheme. and, make sure change arguments to

enter image description here

and executable mpirun - should inside bin directory have mpi installed.

enter image description here


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -