SlideShare a Scribd company logo
PARALLEL PROGRAMMING
in Win10 using
MS-MPI & VS
Praveen Kumar Ch
prav
We do this in Two Stages
• Stage 1: Setup Requirements
1. Understanding the Software Requirements
2. IDE & Compiler : Microsoft Visual Studio
3. Microsoft MPI
• Stage 2: MPI Programming
1. Creating Project in Visual Studio
2. Linking MS-MPI with Project for Parallel programming
3. Writing, Building and Launching “Hello World” Parallel Program
prav
prav
Create
Project
Configure MS
MPI in VS2019
Coding in
Parallel
Understand
Requirements
Install IDE
VS2019
Install
MS MPI
Stage 1
Stage 2
Stage 1: Setup Requirements
1. Understand the What is Needed…
2. Install Visual Studio..
3. Install MS-MPI…
If you are not interested in understanding the requirements
&&
If you want to directly start installing
Go to Slide 12
prav
Stage 1. Step 1:
To understand Software setup requirements
Lets see a typical Compilation Process…
( in Next Slide)
prav
Source file
(filename.c)
Intermediate code
(filename.i)
Assembly file
(filename.s)
Object file
(filename.o)
Executable
(filename.exe)
Pre-processor
Compiler
Assembler
Linker
The Code is
written in this
file
The Executable
File that we
run
MS Compiler
The build Process
Header files
(.h)
Library
(.o, .lib)
Include
Link
prav
Don’t bother
about this for
now
This is the
Compiler
prav
Now lets see what happens with the Executable file
I mean when we run the executable file…
OS
Loads the Instructions
into the processor
stack
prav
Executable File
(filename.exe)
Loader
CPU
RAM
CHIP
CORE1 CORE2
CORE3 CORE4
CORE5 CORE6
CORE7 CORE8
L3 CACHE
L2 CACHE
I/O DEVICES
DISPLAY
KEYBOARD
MOUSE
HARD DISK
The Hardware
Hard Disk
The .exe is stored here
OS
Run time
When we run / click
on the executable file
So to run a c program, We need…
• An editor to write the code
• A compiler to Build an Executable
• A Launcher to Load and Run the Executable
prav
• A Multicore Machine
• Operating System
An Integrated Development
Environment (IDE) is like
one stop shop that makes
this stuff easy
But we are trying to do some
Parallel Programming using MPI
So…
We also need an MPI implementation
For better understanding, See next slide
prav
TH
CPU
prav
IDE : VISUAL STUDIO
WINDOWS
SDK
MS VC++
Compiler
OS
Loader
MS MPI
(INC ,
LIB)
BUILDER
(Compiles and
Builds an
executable file
.exe)
LAUNCH
(Runs the
executable
file)
EDITOR
(The code is
written and
edited here)
.exe
file
.cpp
Source file
RAM
CHIP
CORE1 CORE2
CORE3 CORE4
CORE5 CORE6
CORE7 CORE8
L3 CACHE
L2 CACHE
I/O DEVICES
DISPLAY
KEYBOARD
MOUSE
HARD DISK
The Software – OS & Apps The Hardware
TH
CPU
prav
OS
Loader
RAM
CHIP
CORE1 CORE2
CORE3 CORE4
CORE5 CORE6
CORE7 CORE8
L3 CACHE
L2 CACHE
I/O DEVICES
DISPLAY
KEYBOARD
MOUSE
HARD DISK
The Software – OS & Apps The Hardware
We have a PC with a multi
core processor
We have
windows 10 OS
What We already
Have ????
Finally the requirements for Parallel
Programming…
The Hardware : A Multicore Machine
The OS : Windows 10
prav
oIDE is required : Visual Studio
oMPI : MS MPI
We should
be having
these
We need to
install and
set up this
Stage 1: Step 2 : Download and Install
the Visual Studio Community
Its free… GO here… To this Link…
https://visualstudio.microsoft.com/thank-you-downloading-visual-
studio/?sku=community&rel=16
Download starts automatically…
Download and install … Instructions available there…
prav
prav
If link doesn't work…
Just Google “Visual Studio”
Find and open Official website : https://visualstudio.microsoft.com/
Help Your self to download and install Latest Community edition
There are many YouTube videos that show
“How to install Visual Studio”
prav
https://visualstudio.microsoft.com/
prav
Download
Community
from here
After Download and installation
The resources we got now, will be
like… See next slide…
prav
TH
CPU
prav
IDE : VISUAL STUDIO
WINDOWS
SDK
MS VC++
Compiler
OS
Loader
BUILDER
(Compiles and
Builds an
executable file
.exe)
LAUNCH
(Runs the
executable
file)
EDITOR
(The code is
written and
edited here)
.exe
file
.cpp
Source file
RAM
CHIP
CORE1 CORE2
CORE3 CORE4
CORE5 CORE6
CORE7 CORE8
L3 CACHE
L2 CACHE
I/O DEVICES
DISPLAY
KEYBOARD
MOUSE
HARD DISK
The Software – OS & Apps The Hardware
We
added
this
now
Downloading and Installing MS MPI
Its free… GO here… To this Link…
https://www.microsoft.com/en-us/download/details.aspx?id=100593
prav
Check System Requirements
Follow Installation Instruction
prav
prav
Download both
msmpisetup.exe
&
msmpisdk.msi
If link doesn’t work…
Google “Microsoft MPI”
There is some YouTube content on
“How to Download and Install Microsoft – MPI”
Find and Open Official web page :
https://docs.microsoft.com/en-us/message-passing-
interface/microsoft-mpi
prav
prav
Download
from here
TH
CPU
prav
IDE : VISUAL STUDIO
WINDOWS
SDK
MS VC++
Compiler
OS
Loader
MS MPI
(INC ,
LIB)
BUILDER
(Compiles and
Builds an
executable file
.exe)
LAUNCH
(Runs the
executable
file)
EDITOR
(The code is
written and
edited here)
.exe
file
.cpp
Source file
RAM
CHIP
CORE1 CORE2
CORE3 CORE4
CORE5 CORE6
CORE7 CORE8
L3 CACHE
L2 CACHE
I/O DEVICES
DISPLAY
KEYBOARD
MOUSE
HARD DISK
The Software – OS & Apps The Hardware
We added this now
This Connection is for Including
header files (mpi.h) and linking
Library (msmpi.inc, msmpi.lib).
We will establish this link when
we are making a new MPI Project
We added this now
This Link is for running a
program in parallel using
msmpi.exe
It is established while installing
MS MPI
Ok Now we got Everything Installed …
What Next… Stage 2…
1. Open a new Visual Studio Project
2. Set up MS-MPI with VS-Project: Include files, Libraries and
dependencies
3. Write the First parallel MPI Program : To Print Hello world in parallel
using multiple processes
prav
https://www.youtube.com/watch?time_continue=518&
v=IW3SKDM_yEs&feature=emb_title
You can also learn
how to do that stuff
from this YouTube
Video and PDF file… https://www.math.ucla.edu/~mputhawala/PPT.pdf
Stage2 . Step 1 : Open Visual Studio and Create a new Project
prav
Select
Console App
Check these
Options
prav
Give a Name For
the project
Choose a
Location to save
the Project
prav
New Project Opens Like this…
Stage 2 : Step 2
Setup MS- MPI with Visual Studio Compiler
How??
By changing the Project Properties
But first check How good is MSMPI Installation …
By Using Command Prompt…
prav
prav
To check if MS –MPI is
properly installed and
default path is set
Open Command
Prompt
Give the command
“mpiexec”
If,
the command is
recognized and its
usage is displayed
Then,
MS-MPI is properly
installed and all is good
Check for MS-MPI Environment Variables
Open Command Prompt and type command “set MSMPI” and hit
return key
prav
These Variables with the respective
path strings should be displayed
These Variables contain location path for MPI,
bin, include directories and library directories.
They will be used to set up MPI in VS Project
If it looks all good then…,
Lets Go back to Visual Studio to set up MS MPI….
prav
prav
Click Here to
Change Project
Properties
prav
Add
“$(MSMPI_INC)”
in this blank
Expand and
Open these
Properties
C/C++ :General
We are actually
setting
Additional Include
Directories to
the Path of MS-MPI
Include files
directory.
Where “mpi.h” and
other related header
files are located.Note,
$(MSMPI_INC) = C:Program
Files (x86)Microsoft
SDKsMPIInclude
This window
Opens up
prav
Add
“msmpi.lib;”
to the line
• Add it before “%”
• Don’t forget “;”
Expand and
Open these
Properties
Linker: All
Options
We are actually
adding the msmpi
library to Link
prav
Expand and
Open these
Properties
Linker: All
Options
For x64 Platform,
Add
“$(MSMPI_LIB64)”
in the blank
For x32 Platform,
Add
“$(MSMPI_LIB32)”
in the blank
We are adding
the path of
MSMPI library
Directory
Where
msmpi.lib for
corresponding
platform exist
prav
Replace the command with
“$(MSMPI_BIN)mpiexec”
Replace the command arguments
with
“-n 8 $(TargetPath)”
We are actually setting the debugger to run the project in
parallel with 8 processes,
by using the following command
$(MSMPI_BIN)mpiexec.exe –n 8 $(TargetPath)
Replace ‘8’ with
‘16’ if you want to
run with 16
processes
Expand and
Open these
Properties
Debugging
Click Ok button
And close the
property
window
prav
Click Ok button
And close the
property
window
Stage 2. Step 3 : Code to Run in Parallel
prav
MPI Parallel Programming key fund
• The complete code is distributed to all Processors.
• We design the program so that it identifies the processor in which it is running
and does tasks which are relevant to it.
• Rank is a number used to identify processor.
• MPI functions are used
• MPI_Comm_rank() is used to identify the rank of current running processor.
• MPI_Comm_size() is used to identify the total number of processors.
• MPI Functions are used for communication / message passing between
processors during runtime
• MPI_Send() & MPI_Recv() to send and receive msgs between processes
prav
1. Replace the content in
source file
“Hello_Parallel.cpp” with
the code shown here
and save
2. Click this Green Arrow head to Build and Launch after editing and saving the code
prav
Note :
The code run
by processer 0
prints an
additional line
because of if
conditional
statement
Every
processor
prints Hello
message by
identifying its
number (rank)
Output after Running the code
prav
ANOTHER PROGRAM
Try this code,
It takes two numbers and
perform various operations
based on the processor in
which this code is running
prav
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv[]) {
// Defining two integer numbers
int a = 10;
int b = 20;
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// Get the total number of processes running this code
int nProc;
MPI_Comm_size(MPI_COMM_WORLD, &nProc);
// Get the rank of this process in which this code is running
int iProc;
MPI_Comm_rank(MPI_COMM_WORLD, &iProc);
// Print a text corresponding to this process
printf("nHello Parallel world from processor %d out of %d processors", iProc, nProc);
The Code contd..,
prav
// Calculating third number C as a result of various operations with a and b
int c;
if (iProc == 0) { // if Processor rank is 0 then c=a+b
c = a + b;
printf("nc=(a+b)=%d", c);
}
if (iProc == 1) { // if Processor rank is 1 then c=a-b
c = a - b;
printf("nc=(a-b)=%d", c);
}
if (iProc == 2) { // if Processor rank is 2 then c=a*b
c = a * b;
printf("nc=(a*b)=%d", c);
}
if (iProc == 3) { // if Processor rank is 3 then c=a/b
c = a / b;
printf("nc=(a/b)=%d", c);
}
if (iProc>3){
printf("nThis processor is not performing any operation on a and b");
}
// Finalize the MPI environment.
MPI_Finalize();
}
The Code Ends
prav
The output after running
the code
Additional references
https://mpitutorial.com/tutorials/
https://docs.microsoft.com/en-us/archive/blogs/windowshpc/how-to-
compile-and-run-a-simple-ms-mpi-program
prav
The End…

More Related Content

What's hot

what is LINUX ? presentation.
what is LINUX ? presentation.what is LINUX ? presentation.
what is LINUX ? presentation.
saad_khan1122
 
Container Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSFContainer Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSF
Gabor Samu
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)
Jaime Barragan
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
AYESHA JAVED
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
Saurabh Bangad
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
YourHelper1
 
Introduction to Ubuntu
Introduction to UbuntuIntroduction to Ubuntu
Introduction to Ubuntu
Khairul Aizat Kamarudzzaman
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
Stephen Ahiante
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
BugRaptors
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
Introduction to Linux Kernel
Introduction to Linux KernelIntroduction to Linux Kernel
Introduction to Linux Kernel
Stryker King
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
Dominique Cimafranca
 
Linux kernel
Linux kernelLinux kernel
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Etsuji Nakai
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
Docker, Inc.
 
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools
Brendan Gregg
 
Linux
LinuxLinux
Linux Booting Steps
Linux Booting StepsLinux Booting Steps
Linux Booting Steps
Anando Kumar Paul
 
Init of Android
Init of AndroidInit of Android
Init of Android
Tetsuyuki Kobayashi
 

What's hot (20)

what is LINUX ? presentation.
what is LINUX ? presentation.what is LINUX ? presentation.
what is LINUX ? presentation.
 
Container Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSFContainer Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSF
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
Introduction to Ubuntu
Introduction to UbuntuIntroduction to Ubuntu
Introduction to Ubuntu
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Introduction to Linux Kernel
Introduction to Linux KernelIntroduction to Linux Kernel
Introduction to Linux Kernel
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
 
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools
 
Linux
LinuxLinux
Linux
 
Linux Booting Steps
Linux Booting StepsLinux Booting Steps
Linux Booting Steps
 
Init of Android
Init of AndroidInit of Android
Init of Android
 

Similar to Parallel programming c++ win10 msmpi visual studio

C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
Mpi.net tutorial
Mpi.net tutorialMpi.net tutorial
Mpi.net tutorial
pablodutrarodrigues
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
Subramanyambharathis
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
Mohamed Abdallah
 
Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
VijayaNagarajan5
 
Visual c++ demo
Visual c++ demoVisual c++ demo
Visual c++ demo
Dr. C.V. Suresh Babu
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
Franciny Salles
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
Getachew Ganfur
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
AliEndris3
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
SUDHAKAR S
 
C# tutorial
C# tutorialC# tutorial
C# tutorial
sarangowtham_gunnam
 
Source vs object code
Source vs object codeSource vs object code
Source vs object code
Sana Ullah
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
PedramKashiani
 
Programming in c_in_7_days
Programming in c_in_7_daysProgramming in c_in_7_days
Programming in c_in_7_days
Ankit Dubey
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
sangeetaSS
 
Cp week _1.
Cp week _1.Cp week _1.
Cp week _1.
shahidullah57
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
Rai University
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
A-Tech and Software Development
 
Machine Understandable code
Machine Understandable codeMachine Understandable code
Machine Understandable code
janusathis
 

Similar to Parallel programming c++ win10 msmpi visual studio (20)

C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Mpi.net tutorial
Mpi.net tutorialMpi.net tutorial
Mpi.net tutorial
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
 
Visual c++ demo
Visual c++ demoVisual c++ demo
Visual c++ demo
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
C# tutorial
C# tutorialC# tutorial
C# tutorial
 
Source vs object code
Source vs object codeSource vs object code
Source vs object code
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
Programming in c_in_7_days
Programming in c_in_7_daysProgramming in c_in_7_days
Programming in c_in_7_days
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
 
Cp week _1.
Cp week _1.Cp week _1.
Cp week _1.
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Machine Understandable code
Machine Understandable codeMachine Understandable code
Machine Understandable code
 

Recently uploaded

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 

Recently uploaded (20)

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 

Parallel programming c++ win10 msmpi visual studio

  • 1. PARALLEL PROGRAMMING in Win10 using MS-MPI & VS Praveen Kumar Ch prav
  • 2. We do this in Two Stages • Stage 1: Setup Requirements 1. Understanding the Software Requirements 2. IDE & Compiler : Microsoft Visual Studio 3. Microsoft MPI • Stage 2: MPI Programming 1. Creating Project in Visual Studio 2. Linking MS-MPI with Project for Parallel programming 3. Writing, Building and Launching “Hello World” Parallel Program prav
  • 3. prav Create Project Configure MS MPI in VS2019 Coding in Parallel Understand Requirements Install IDE VS2019 Install MS MPI Stage 1 Stage 2
  • 4. Stage 1: Setup Requirements 1. Understand the What is Needed… 2. Install Visual Studio.. 3. Install MS-MPI… If you are not interested in understanding the requirements && If you want to directly start installing Go to Slide 12 prav
  • 5. Stage 1. Step 1: To understand Software setup requirements Lets see a typical Compilation Process… ( in Next Slide) prav
  • 6. Source file (filename.c) Intermediate code (filename.i) Assembly file (filename.s) Object file (filename.o) Executable (filename.exe) Pre-processor Compiler Assembler Linker The Code is written in this file The Executable File that we run MS Compiler The build Process Header files (.h) Library (.o, .lib) Include Link prav Don’t bother about this for now This is the Compiler
  • 7. prav Now lets see what happens with the Executable file I mean when we run the executable file…
  • 8. OS Loads the Instructions into the processor stack prav Executable File (filename.exe) Loader CPU RAM CHIP CORE1 CORE2 CORE3 CORE4 CORE5 CORE6 CORE7 CORE8 L3 CACHE L2 CACHE I/O DEVICES DISPLAY KEYBOARD MOUSE HARD DISK The Hardware Hard Disk The .exe is stored here OS Run time When we run / click on the executable file
  • 9. So to run a c program, We need… • An editor to write the code • A compiler to Build an Executable • A Launcher to Load and Run the Executable prav • A Multicore Machine • Operating System An Integrated Development Environment (IDE) is like one stop shop that makes this stuff easy
  • 10. But we are trying to do some Parallel Programming using MPI So… We also need an MPI implementation For better understanding, See next slide prav
  • 11. TH CPU prav IDE : VISUAL STUDIO WINDOWS SDK MS VC++ Compiler OS Loader MS MPI (INC , LIB) BUILDER (Compiles and Builds an executable file .exe) LAUNCH (Runs the executable file) EDITOR (The code is written and edited here) .exe file .cpp Source file RAM CHIP CORE1 CORE2 CORE3 CORE4 CORE5 CORE6 CORE7 CORE8 L3 CACHE L2 CACHE I/O DEVICES DISPLAY KEYBOARD MOUSE HARD DISK The Software – OS & Apps The Hardware
  • 12. TH CPU prav OS Loader RAM CHIP CORE1 CORE2 CORE3 CORE4 CORE5 CORE6 CORE7 CORE8 L3 CACHE L2 CACHE I/O DEVICES DISPLAY KEYBOARD MOUSE HARD DISK The Software – OS & Apps The Hardware We have a PC with a multi core processor We have windows 10 OS What We already Have ????
  • 13. Finally the requirements for Parallel Programming… The Hardware : A Multicore Machine The OS : Windows 10 prav oIDE is required : Visual Studio oMPI : MS MPI We should be having these We need to install and set up this
  • 14. Stage 1: Step 2 : Download and Install the Visual Studio Community Its free… GO here… To this Link… https://visualstudio.microsoft.com/thank-you-downloading-visual- studio/?sku=community&rel=16 Download starts automatically… Download and install … Instructions available there… prav
  • 15. prav
  • 16. If link doesn't work… Just Google “Visual Studio” Find and open Official website : https://visualstudio.microsoft.com/ Help Your self to download and install Latest Community edition There are many YouTube videos that show “How to install Visual Studio” prav
  • 18. After Download and installation The resources we got now, will be like… See next slide… prav
  • 19. TH CPU prav IDE : VISUAL STUDIO WINDOWS SDK MS VC++ Compiler OS Loader BUILDER (Compiles and Builds an executable file .exe) LAUNCH (Runs the executable file) EDITOR (The code is written and edited here) .exe file .cpp Source file RAM CHIP CORE1 CORE2 CORE3 CORE4 CORE5 CORE6 CORE7 CORE8 L3 CACHE L2 CACHE I/O DEVICES DISPLAY KEYBOARD MOUSE HARD DISK The Software – OS & Apps The Hardware We added this now
  • 20. Downloading and Installing MS MPI Its free… GO here… To this Link… https://www.microsoft.com/en-us/download/details.aspx?id=100593 prav Check System Requirements Follow Installation Instruction
  • 21. prav
  • 23. If link doesn’t work… Google “Microsoft MPI” There is some YouTube content on “How to Download and Install Microsoft – MPI” Find and Open Official web page : https://docs.microsoft.com/en-us/message-passing- interface/microsoft-mpi prav
  • 25. TH CPU prav IDE : VISUAL STUDIO WINDOWS SDK MS VC++ Compiler OS Loader MS MPI (INC , LIB) BUILDER (Compiles and Builds an executable file .exe) LAUNCH (Runs the executable file) EDITOR (The code is written and edited here) .exe file .cpp Source file RAM CHIP CORE1 CORE2 CORE3 CORE4 CORE5 CORE6 CORE7 CORE8 L3 CACHE L2 CACHE I/O DEVICES DISPLAY KEYBOARD MOUSE HARD DISK The Software – OS & Apps The Hardware We added this now This Connection is for Including header files (mpi.h) and linking Library (msmpi.inc, msmpi.lib). We will establish this link when we are making a new MPI Project We added this now This Link is for running a program in parallel using msmpi.exe It is established while installing MS MPI
  • 26. Ok Now we got Everything Installed … What Next… Stage 2… 1. Open a new Visual Studio Project 2. Set up MS-MPI with VS-Project: Include files, Libraries and dependencies 3. Write the First parallel MPI Program : To Print Hello world in parallel using multiple processes prav https://www.youtube.com/watch?time_continue=518& v=IW3SKDM_yEs&feature=emb_title You can also learn how to do that stuff from this YouTube Video and PDF file… https://www.math.ucla.edu/~mputhawala/PPT.pdf
  • 27. Stage2 . Step 1 : Open Visual Studio and Create a new Project prav Select Console App Check these Options
  • 28. prav Give a Name For the project Choose a Location to save the Project
  • 29. prav New Project Opens Like this…
  • 30. Stage 2 : Step 2 Setup MS- MPI with Visual Studio Compiler How?? By changing the Project Properties But first check How good is MSMPI Installation … By Using Command Prompt… prav
  • 31. prav To check if MS –MPI is properly installed and default path is set Open Command Prompt Give the command “mpiexec” If, the command is recognized and its usage is displayed Then, MS-MPI is properly installed and all is good
  • 32. Check for MS-MPI Environment Variables Open Command Prompt and type command “set MSMPI” and hit return key prav These Variables with the respective path strings should be displayed These Variables contain location path for MPI, bin, include directories and library directories. They will be used to set up MPI in VS Project
  • 33. If it looks all good then…, Lets Go back to Visual Studio to set up MS MPI…. prav
  • 34. prav Click Here to Change Project Properties
  • 35. prav Add “$(MSMPI_INC)” in this blank Expand and Open these Properties C/C++ :General We are actually setting Additional Include Directories to the Path of MS-MPI Include files directory. Where “mpi.h” and other related header files are located.Note, $(MSMPI_INC) = C:Program Files (x86)Microsoft SDKsMPIInclude This window Opens up
  • 36. prav Add “msmpi.lib;” to the line • Add it before “%” • Don’t forget “;” Expand and Open these Properties Linker: All Options We are actually adding the msmpi library to Link
  • 37. prav Expand and Open these Properties Linker: All Options For x64 Platform, Add “$(MSMPI_LIB64)” in the blank For x32 Platform, Add “$(MSMPI_LIB32)” in the blank We are adding the path of MSMPI library Directory Where msmpi.lib for corresponding platform exist
  • 38. prav Replace the command with “$(MSMPI_BIN)mpiexec” Replace the command arguments with “-n 8 $(TargetPath)” We are actually setting the debugger to run the project in parallel with 8 processes, by using the following command $(MSMPI_BIN)mpiexec.exe –n 8 $(TargetPath) Replace ‘8’ with ‘16’ if you want to run with 16 processes Expand and Open these Properties Debugging Click Ok button And close the property window
  • 39. prav Click Ok button And close the property window
  • 40. Stage 2. Step 3 : Code to Run in Parallel prav MPI Parallel Programming key fund • The complete code is distributed to all Processors. • We design the program so that it identifies the processor in which it is running and does tasks which are relevant to it. • Rank is a number used to identify processor. • MPI functions are used • MPI_Comm_rank() is used to identify the rank of current running processor. • MPI_Comm_size() is used to identify the total number of processors. • MPI Functions are used for communication / message passing between processors during runtime • MPI_Send() & MPI_Recv() to send and receive msgs between processes
  • 41. prav 1. Replace the content in source file “Hello_Parallel.cpp” with the code shown here and save 2. Click this Green Arrow head to Build and Launch after editing and saving the code
  • 42. prav Note : The code run by processer 0 prints an additional line because of if conditional statement Every processor prints Hello message by identifying its number (rank) Output after Running the code
  • 43. prav ANOTHER PROGRAM Try this code, It takes two numbers and perform various operations based on the processor in which this code is running
  • 44. prav #include <mpi.h> #include <stdio.h> int main(int argc, char** argv[]) { // Defining two integer numbers int a = 10; int b = 20; // Initialize the MPI environment MPI_Init(NULL, NULL); // Get the total number of processes running this code int nProc; MPI_Comm_size(MPI_COMM_WORLD, &nProc); // Get the rank of this process in which this code is running int iProc; MPI_Comm_rank(MPI_COMM_WORLD, &iProc); // Print a text corresponding to this process printf("nHello Parallel world from processor %d out of %d processors", iProc, nProc); The Code contd..,
  • 45. prav // Calculating third number C as a result of various operations with a and b int c; if (iProc == 0) { // if Processor rank is 0 then c=a+b c = a + b; printf("nc=(a+b)=%d", c); } if (iProc == 1) { // if Processor rank is 1 then c=a-b c = a - b; printf("nc=(a-b)=%d", c); } if (iProc == 2) { // if Processor rank is 2 then c=a*b c = a * b; printf("nc=(a*b)=%d", c); } if (iProc == 3) { // if Processor rank is 3 then c=a/b c = a / b; printf("nc=(a/b)=%d", c); } if (iProc>3){ printf("nThis processor is not performing any operation on a and b"); } // Finalize the MPI environment. MPI_Finalize(); } The Code Ends
  • 46. prav The output after running the code