{"id":72,"date":"2014-12-03T13:29:08","date_gmt":"2014-12-03T18:29:08","guid":{"rendered":"http:\/\/wordpress.cs.vt.edu\/rlogin\/?page_id=72"},"modified":"2018-10-10T10:00:51","modified_gmt":"2018-10-10T14:00:51","slug":"how-to-use-mpi","status":"publish","type":"page","link":"https:\/\/wordpress.cs.vt.edu\/rlogin\/how-to-use-mpi\/","title":{"rendered":"How to use MPI"},"content":{"rendered":"<p>This quick tutorial will show you how to use MPI on the rlogin nodes &#8211; either OpenMPI or mpich.\u00a0 MPI (message passing\u00a0 interface) is primarily used to parrallelize applications.\u00a0 To use MPI on rlogin you will need to set up the environment.\u00a0 You can do this by loading modules.<\/p>\n<p>Use the following command to list available modules:<\/p>\n<pre>module avail<\/pre>\n<p>Use the following command to assign a module:<\/p>\n<pre>module add &lt;name&gt;<\/pre>\n<p>You will likely want to add this command to your .bashrc file so it is run during non-interactive shell processes.<\/p>\n<p>Example with 64 parallel processes on the local machine:<\/p>\n<pre>$ module add mpi\/openmpi-x86_64\r\n$ mpicc program.c \r\n$ mpiexec -np 64 a.out\r\nSend\/Recv with 64 processes:\r\nCount,Mintime\r\n       1,7.734e-05\r\n       2,4.558e-05\r\n       4,4.998e-05\r\n       8,4.872e-05\r\n      16,5.183e-05\r\n      32,4.664e-05\r\n      64,6.570e-05\r\n     128,7.245e-05\r\n     256,8.883e-05\r\n     512,1.126e-04\r\n    1024,6.448e-04\r\n    2048,9.037e-04\r\n    4096,1.149e-03\r\n    8192,1.396e-03\r\n   16384,1.767e-03\r\n   32768,2.495e-03\r\n   65536,4.006e-03\r\n  131072,7.112e-03\r\n  262144,1.502e-02\r\n  524288,2.938e-02\r\nComplete\r\n$<\/pre>\n<p>To run MPI on multiple nodes, you will need to do the following:<\/p>\n<p>Set up SSH key login:<\/p>\n<pre>$ ssh-keygen -t rsa\r\n.\r\n.\r\n.\r\n$ cat .ssh\/id_rsa.pub &gt;&gt; .ssh\/authorized_keys\r\n$<\/pre>\n<p>Add the module command to your .bashrc file:<\/p>\n<pre>$ echo \"module add mpi\/openmpi-x86_64\" &gt;&gt; ~\/.bashrc\r\n$<\/pre>\n<p>Create a text file with the hostnames you want to run MPI on:<\/p>\n<pre>$ echo $'birch.rlogin\\nmaple.rlogin\\nhackberry.rlogin' &gt; hosts.txt\r\n$<\/pre>\n<p>Run MPI:<\/p>\n<pre>$ mpiexec -np 3 --hostfile hosts.txt a.out\r\nSend\/Recv with 3 processes:\r\nCount,Mintime\r\n       1,4.588e-06\r\n       2,3.211e-06\r\n       4,2.995e-06\r\n       8,3.070e-06\r\n      16,3.280e-06\r\n      32,3.807e-06\r\n      64,4.789e-06\r\n     128,6.596e-06\r\n     256,9.447e-06\r\n     512,9.391e-06\r\n    1024,2.140e-05\r\n    2048,3.866e-05\r\n    4096,5.744e-05\r\n    8192,1.063e-04\r\n   16384,1.657e-04\r\n   32768,2.829e-04\r\n   65536,5.118e-04\r\n  131072,9.384e-04\r\n  262144,1.794e-03\r\n  524288,3.517e-03\r\nComplete\r\n$<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This quick tutorial will show you how to use MPI on the rlogin nodes &#8211; either OpenMPI or mpich.\u00a0 MPI (message passing\u00a0 interface) is primarily used to parrallelize applications.\u00a0 To use MPI on rlogin you will need to set up the environment.\u00a0 You can do this by loading modules. Use the following command to list &hellip; <a href=\"https:\/\/wordpress.cs.vt.edu\/rlogin\/how-to-use-mpi\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to use MPI<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-72","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/pages\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":13,"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/pages\/72\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/pages\/72\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/wordpress.cs.vt.edu\/rlogin\/wp-json\/wp\/v2\/media?parent=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}