0

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:
  • Build Settings -> Header Search Paths = /opt/homebrew/opt/open-mpi/include
  • Build Settings -> Library Search Paths = /opt/homebrew/opt/open-mpi/lib
  • Build Settings -> Other Linker Flags = -lmpi

(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

1 Answer 1

0

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)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.