应用程序缓冲区和系统缓冲区之间有什么区别 [英] What is difference between Application Buffer and System Buffer
问题描述
许多MPI教程中有一些术语含糊不清,例如应用程序缓冲区"和系统缓冲区".我不明白他们之间的区别.我也想知道他们在哪里?我认为应用程序缓冲区是接收或发送节点内部的内存.那么,如果是,系统缓冲区是什么?
There are some terms in many MPI tutorials which have vague meaning such as "Application Buffer" and "System Buffer". I don't understand the difference between them. I also wonder where they are located? I think application buffer is a memory inside the receiving or sending node. So if it is, what is the system buffer?
推荐答案
在MPI的上下文中,应用程序缓冲区(通常称为用户缓冲区)是保存以下内容的缓冲区要发送的信息或要接收信息的位置.应用程序缓冲区是传递给MPI通信调用的缓冲区,例如
In the context of MPI, application buffer (often called user buffer) is the buffer that holds information to be sent or the place where information is to be received. Applications buffers are what one passes to MPI communication calls, e.g.
MPI_Send(buf, len, type, ...);
// ^^^
// app. buffer
一旦调用MPI_Send
,就会构造一条消息,并根据各种标准通过互连发送该消息,该互连可以是任何类型的连接机制,例如InfiniBand,Internet套接字,共享内存等,以及实际的连接机制.传输可能涉及许多中间步骤,或在内部进行缓冲以备后用. 内部缓冲区(也称为系统缓冲区)是MPI运行时系统的一部分,由MPI运行时系统管理,并且对应用程序代码不可见.不必在内核或应用程序空间之外的其他位置分配系统缓冲区.相反,在许多MPI实现和互连中,这些缓冲区是在程序地址空间中分配的,并计入程序内存的使用情况.
Once MPI_Send
is called, a message is constructed and depending on various criteria is either sent via the interconnect, which could be any kind of connecting mechanism, for example InfiniBand, Internet sockets, shared memory, etc. and the actual transmission might involve many intermediate steps, or buffered internally for later delivery. Internal buffers (also system buffers) are part of and managed by the MPI runtime system and are invisible to the application code. It is not necessarily the case that system buffers are allocated in the kernel or somewhere else outside the application space. On the contrary, with many MPI implementations and interconnects those buffers are allocated in the program address space and count towards the program memory usage.
也可以在MPI_Bsend
调用或其非阻塞变量MPI_Ibsend
中使用显式分配的中间缓冲区.它要求用户首先分配一个缓冲区,然后通过调用MPI_Buffer_attach
将其提供给MPI运行时.从那时起,该缓冲区的内容仅由MPI运行时系统管理.
It is also possible to utilise explicitly allocated intermediate buffers with the MPI_Bsend
call or its non-blocking variant MPI_Ibsend
. It requires that the user first allocate a buffer and then give it to the MPI runtime by calling MPI_Buffer_attach
. From that moment on, the content of this buffer is solely managed by the MPI runtime system.
应用程序和系统缓冲区之间的区别对于操作完成的概念很重要.然后,当MPI不再需要访问应用程序缓冲区时,则认为MPI操作已完成.例如:
The distinction between application and system buffers is important for the concept of operation completion. MPI operations are considered complete then, when MPI no longer needs access to the application buffer. For example:
buf[] = some content;
MPI_Send(buf, len, ...);
// once MPI_Send returns, the buffer can be reused
buf[0] = 1;
MPI_Send(buf, 1, ...);
对于非阻塞调用,该操作在后台继续进行,必须注意不要在异步操作完成之前修改应用程序缓冲区:
With non-blocking calls the operation continues in the background and one has to be careful not to modify the application buffer before the asynchronous operation has completed:
MPI_Request req;
buf[] = some content;
MPI_Isend(buf, len, ..., &req);
buf[0] = 1; // DATA RACE: buf might still be in use by
MPI_Send(buf, 1, ...); // the operation initiated by MPI_Isend
在这种情况下正确使用buf
可能是这样的:
A correct use of buf
in that case would be something like:
MPI_Request req;
buf[] = some content;
MPI_Isend(buf, len, ..., &req);
// Do something that does not involve changing buf
// ...
// ...
// Make sure the operation is complete before continuing
MPI_Wait(&req, MPI_STATUS_IGNORE);
// buf is now free for reuse
buf[0] = 1;
MPI_Send(buf, 1, ...);
这篇关于应用程序缓冲区和系统缓冲区之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!