在 M3 Pro 上,在 Xcode 中,我想运行一个简单的 C 源文件:
#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;
}
它成功构建,但没有成功运行,在控制台上返回:
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
我错过了什么?
/opt/homebrew/opt/open-mpi/include
/opt/homebrew/opt/open-mpi/lib
-lmpi
(
brew --prefix open-mpi
返回/opt/homebrew/opt/open-mpi
)
mpicc main.c
mpiexec a.out
,正确显示:hello from process 1...12 of 12 total processes
-np 4 "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_NAME)"