FueledByPizza
FueledByPizza

Reputation: 55

Xcode problem while executing C OpenMPI project

On an M3 Pro, in Xcode, I want to run a simple C source file:

#include <mpi.h>
#include <stdio.h>

int main(int argc, char** argv) {
    MPI_Init(&argc, &argv);

    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    printf("hello from process %d of %d total processes\n", world_rank, world_size);

    MPI_Finalize();
    return 0;
}

It successfully builds, but it doesn't run successfully, returning on console:

NSBundle file:///System/Library/PrivateFrameworks/MetalTools.framework/ principal class is nil because all fallbacks have failed
[Mac.station:03539] shmem: mmap: an error occurred while determining whether or not /var/folders/0j/hwf25cd97w1916m2vcbz833r0000gn/T//ompi.Mac.501/jf.0/1294860288/sm_segment.Mac.501.4d2e0000.0 could be created.
hello from process 0 of 1 total processes
Program ended with exit code: 0


What am I missing?

  1. In order to build, I've configured the Xcode project in this way:

(brew --prefix open-mpi returns /opt/homebrew/opt/open-mpi)

  1. The project builds successfully on terminal by executing:
    mpicc main.c
    and runs successfully by executing:
    mpiexec a.out, showing correctly: hello from process 1...12 of 12 total processes

Upvotes: 0

Views: 273

Answers (1)

FueledByPizza
FueledByPizza

Reputation: 55

Solved

I changed the way Xcode runs my program, it was just executing ./a.out instead of executing something like mpiexec a.out

  1. Edit Scheme -> Run -> Info -> Executable -> Other... -> </path/to/mpiexec>
  2. Edit Scheme -> Run -> Arguments -> Arguments Passed on Launch -> -np 4 "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_NAME)"

Upvotes: 0

Related Questions