c - 如何使用openMP为MPI程序制作makefile?

标签 c makefile mpi openmp

我完全没有使用 OpenMP 进行 MPI 程序的 makefile 的经验。我通常在命令提示符下运行

mpicc main.c -fopenmp -o Out
mpirun -np 4 Out

所以现在我需要利用 makefile,我的理解是我们使用 makefile 以更方便的方式运行命令,所以从逻辑上讲我们应该在 makefile 中键入相同的命令,对吧?所以我的 makefile 现在看起来像这样

all: 
    mpicc main.c -fopenmp -o Out
    mpirun -np 4 Out

是否有关于如何为绝对初学者创建 makefile 的分步指南?

最佳答案

Makefile 通常用于构建/编译、测试、安装和卸载程序和代码片段。使用它来实际运行程序并不常见,但是是的,您可以做到。您可以为其创建特定规则,例如 run

CC=mpicc
CFLAGS=-fopenmp
EXE=./Out
SRCS=main.c

all:
    $(CC) $(CFLAGS) $(SRCS) -o $(EXE)

run:
    mpirun -np 4 $(EXE)

因此,您可以仅使用 make 编译它,然后使用 make run 调用它

注意:规则内命令前面的空格必须是制表符

Is there a step by step guide on how to create a makefile for absolute beginner?

您可以查看this page from University of Oxford

关于c - 如何使用openMP为MPI程序制作makefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58432560/

相关文章:

c - 如何在 defconfig 中包含 c#ifdef 变量

function - 初级产业部。在函数中运行 mpi

C: 编译器警告 "return discards qualifiers from pointer target type"

c - 在没有运行合成器的情况下使用 x11 协议(protocol)获取覆盖窗口需要什么?

linux - 如何从构建目录中的 src 目录制作?

python - 如何使用horovod对正常值进行allreduce运算?

parallel-processing - MPI 内部 : Communication implementation between processes

c++ - C 中的逻辑运算符和位操作

c - printf(s) 和 printf ("%s", s) 之间的根本区别是什么?

python - 将 <Python.h> 包含到 makefile.am