{"id":369,"date":"2014-09-05T18:17:47","date_gmt":"2014-09-05T10:17:47","guid":{"rendered":"http:\/\/yjxiong-blog.azurewebsites.net\/?p=369"},"modified":"2014-09-05T18:17:47","modified_gmt":"2014-09-05T10:17:47","slug":"mpi-broadcast","status":"publish","type":"post","link":"https:\/\/yjxiong.me\/blogs\/index.php\/2014\/09\/05\/mpi-broadcast\/","title":{"rendered":"MPI Broadcast"},"content":{"rendered":"<p>One interesting answer I saw on Stack Overflow.<\/p>\n<p>Someone asked how he can receive the msg send by `MPI_Bcast`.<\/p>\n<p>The answer is<\/p>\n<blockquote><p>This is a common source of confusion for people new to MPI. You don&#8217;t use\u00a0<a href=\"http:\/\/www.mcs.anl.gov\/research\/projects\/mpi\/www\/www3\/MPI_Recv.html\"><code>MPI_Recv()<\/code><\/a>\u00a0to receive data sent by a broadcast; you use\u00a0<a href=\"http:\/\/www.mcs.anl.gov\/research\/projects\/mpi\/www\/www3\/MPI_Bcast.html\"><code>MPI_Bcast()<\/code><\/a>.<\/p>\n<p>For MPI collective communications,\u00a0<em>everyone<\/em>\u00a0has to particpate; everyone has to call the Bcast, or the Allreduce, or what have you. (That&#8217;s why the Bcast routine has a parameter that specifies the &#8220;root&#8221;, or who is doing the sending; if only the sender called bcast, you wouldn&#8217;t need this.) Everyone calls the broadcast, including the receivers; the receviers don&#8217;t just post a receive.<\/p>\n<p>The reason for this is that the collective operations can involve everyone in the communication, so that you state what you want to happen (everyone gets one processes&#8217; data) rather than\u00a0<em>how<\/em>\u00a0it happens (eg, root processor loops over all other ranks and does a send), so that there is scope for optimizing the communication patterns (eg, a tree-based hierarchical communication that takes\u00a0<code>log(P)<\/code>\u00a0steps rather than\u00a0<code>P<\/code>\u00a0steps for P processes).<\/p><\/blockquote>\n<p>Good point for how to understand collective operations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One interesting answer I saw on Stack Overflow. Someone asked how he can receive the msg send by `MPI_Bcast`. The answer is This is a common source of confusion for people new to MPI. You don&#8217;t use\u00a0MPI_Recv()\u00a0to receive data sent by a broadcast; you use\u00a0MPI_Bcast(). For MPI collective communications,\u00a0everyone\u00a0has to particpate; everyone has to call [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"class_list":["post-369","post","type-post","status-publish","format-standard","hentry","category-programming","category-small-tips"],"_links":{"self":[{"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/posts\/369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":0,"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/posts\/369\/revisions"}],"wp:attachment":[{"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/media?parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/categories?post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yjxiong.me\/blogs\/index.php\/wp-json\/wp\/v2\/tags?post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}