How to setup VS Code for MPI based on C | Parallel Programming in VS Code | MS-MPI setup in Windows

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to my channel skm tutorials  hub in this video I will show you how to set up vs   code so that we can compile and run MPI based on  C which is basically used for parallel programming   but before going to the video if you are new  on this channel then hit the Subscribe button   and press the Bell icon for the latest updates at  first we have to download and install vs code and   set up mingw compiler in order to execute  C and C plus plus programs within vs code   we have already made a video on how to set a vs  code for executing C and C plus plus programs   I will put the link of that video in the  description box as well as in the pinned comment   at first watch that video and complete the vs  code setup and then continue watching this video   open any browser and search  for MPI download on Google   click on the first link of Microsoft then come down  to the download section and click on download  we have to download both these files so I am  selecting both the files and click on next   so here you can see both the  files have been downloaded   now we have to install both the files one by  one first I will install the msmpisetup.exe file   after clicking on the icon one dialog box  will appear where we have to click on yes   then click on next and then accept the license  agreement and click on next now here you can keep   the default installation path but I am going  to change it because when I tried to install   in the default path I got an error which I  will share in the later part of the video after changing the path click on OK  and click next then click on install   the installation will take some time after the installation is complete click on finish   now I am going to install the  other file that is msmpisdk.msi click on run then click next accept the terms and  click on next here again I am going to change the   path for the same reason after changing the path  click on OK and click next then click on install   in between one dialog box will appear where you  have to click on yes after the installation is   complete click on finish so both the installation  has been done it's time to set up the VS code but   before going to vs code open the command  prompt and type set msmpi and press enter   these are the five environment variables that has  been already set keep this tab open because we   will need these later here comes the final part of  the setup I have written a very basic MPI program   I am coming to the program later but  let's focus on the line number two   here I have used hash include mpi.h mpi.h is the  header file which contains the functions of MPI   but you can see on error is showing if I  move the cursor over this line you can see   the error message says hash include errors  detected which means vs code is not identifying   mpi.h is a valid header file now click on quick  fix and then click edit include path setting   a new tab will open of C C plus plus configuration  scroll down until you find include path   here we have to add the environment variable of  the include folder as shown above the format is   dollar and then within curly braces we have to  add the workspace folder from the command prompt   I will copy the environment variable name and  paste it here then close the c c++ configuration   tab here you can see the error is gone that is yes  code is identifying mpi.h as a valid header file   click on the terminal menu and select the last  option that is configured default build task and   then click on the build active file option a new  file will be generated that is tasks.json in   the tasks.json file come to the args part here we  have to add three things come to line number 11.   where it is written dollar file and press enter   then type minus capital I within double  quotes and put a comma and press enter   then within double quotes type  dollar then within curly braces   copy paste the environment variable of  the include folder from the command prompt and put a comma at the end and press enter then type minus capital L within double quotes and put a comma   and press enter in the next line open the double  quotes type dollar and then within curly braces   copy paste the environment variable of the lib  folder you can see there are two environment   variable of lib folder you can choose either of  them depending on your machine if your machine   is 32-bit then choose the second last one and  if your machine is 64-bit then choose the last one then put a comma at the end and press enter   in the next line type minus lmsmpi within  double quotes and put a comma then save this file and close the tab now go to the  terminal menu and select run build task   here you can see one error is showing  you can see I have used a function strcpy   but I have missed the header file  string.h which is needed for it so I will add the line hash include string.h   I will again go to the terminal menu and select  run build task this time the build is successful   one warning is showing though it is not an  error it is just saying that as I have not   given any return type of the main function it is  automatically converted to integer return type   now coming to the program what the program will  do is that the processors with rank greater than   0 will send a message hello participants and the  rank 0 processor will receive the messages and   print it if you remember when we set up the VS  code for c c plus plus program we configured it   such a way that when we click on the Run button it  will do both compile and execute in a single step   but in this program we have command line  arguments so we have to execute manually   with command line arguments now we have to go  to the terminal menu and select new terminal   in the terminal we have to type mpiexec  space minus n space the number of processors   here I am giving 4 again space and type  the file name without any extension   so here is the output you can see we have  received the message hello participants from   the three processors that is one two and three  that is how you can set up vs code to compile   and execute MPI programs based on C now let's talk  about the error which I mentioned at the starting   of the video so when I installed the setups in  the default locations these errors were swing   so you can see the compiler is not able  to identify the file path because it has   divided the file path after the spaces to avoid  this error install the setups in a different   location and make sure that the folder names  don't have spaces also try to avoid long names   so I have shown you the process how to set  up vs code to compile and run MPI programs   based on C if you have any doubt then tell  me in the comments if you find this video   helpful then like and share the video and don't  forget to subscribe to the channel thank you
Info
Channel: SKM Tutorials Hub
Views: 29,342
Rating: undefined out of 5
Keywords: SKM Tutorials Hub, skm tutorials, education, cse, it, tutorial video, mpi, parallel programming, mpich, msmpi, sal.h dependency
Id: bkfCrj-rBjU
Channel Id: undefined
Length: 10min 51sec (651 seconds)
Published: Mon Oct 31 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.