抑制来自 MPI 的消息

Suppress Messages from MPI

我有一个简单的问题(在我心里),我找不到答案。如何抑制 mpirun 的输出消息?

例如,我有一个基于 MPI 的程序,它接受输入文件名。如果文件名错误,程序会生成一个日志文件,例如:

Beginning initialization...
*****************************

Reading topology file...
Error: Topology file mysample.top was not found.

--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD 
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun has exited due to process rank 0 with PID 21581 on
node newton-compute-2-25.local exiting improperly. There are two reasons this could occur:

1. this process did not call "init" before exiting, but others in
the job did. This can cause a job to hang indefinitely while it waits
for all processes to call "init". By rule, if one process calls "init",
then ALL processes must call "init" prior to termination.

2. this process called "init", but exited without calling "finalize".
By rule, all processes that call "init" MUST call "finalize" prior to
exiting or it will be considered an "abnormal termination"

This may have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------

行为正确;程序终止执行(通过调用 MPI_Abort)并显示输入文件错误的消息。来自 MPI 的消息不是必需的,这些是我想抑制的。

我确实尝试将 -q 和 --quiet 选项添加到 mpirun 调用中,但它们似乎对这个特定问题没有任何作用。如果实施很重要,我也在使用 OpenMPI。

编辑:我应该提到 MPI 消息转到 stderr,不一定是 stdout。很好,但我仍然不想看到它们带有程序的错误消息。

由于 MPI 必须能够处理来自它 运行 所在的所有节点的错误,我相信您不能将 MPI 错误流和进程错误流分开。您可以使用 2>/dev/null 删除所有 stderr 或使用 2> err.log 删除错误日志,但同样,我不相信您可以拆分错误。