SlideShare a Scribd company logo
1 of 47
Download to read offline
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

makefiles tutorial
makefiles tutorialmakefiles tutorial
makefiles tutorialvsubhashini
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecturehugo lu
 
2011年度 新3年生向け
2011年度 新3年生向け2011年度 新3年生向け
2011年度 新3年生向けYuki Takahashi
 
CMAF Live Ingest Uplink Protocol
CMAF Live Ingest Uplink ProtocolCMAF Live Ingest Uplink Protocol
CMAF Live Ingest Uplink ProtocolRufael Mekuria
 
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...Igalia
 
嵌入式IPMI遠端監控系統
嵌入式IPMI遠端監控系統 嵌入式IPMI遠端監控系統
嵌入式IPMI遠端監控系統 艾鍗科技
 
Pythonとパッケージングと私
Pythonとパッケージングと私Pythonとパッケージングと私
Pythonとパッケージングと私Atsushi Odagiri
 
BeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOSBeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOSDeveler S.r.l.
 
YoctoをつかったDistroの作り方とハマり方
YoctoをつかったDistroの作り方とハマり方YoctoをつかったDistroの作り方とハマり方
YoctoをつかったDistroの作り方とハマり方wata2ki
 
Binderのはじめの一歩とAndroid
Binderのはじめの一歩とAndroidBinderのはじめの一歩とAndroid
Binderのはじめの一歩とAndroidl_b__
 
Yocto bspを作ってみた
Yocto bspを作ってみたYocto bspを作ってみた
Yocto bspを作ってみたwata2ki
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識shigeya
 
Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編OESF Education
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectYen-Chin Lee
 
作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)Ying wei (Joe) Chou
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded trainingH Ming
 
DockerでWordPressサイトを開発してみよう
DockerでWordPressサイトを開発してみようDockerでWordPressサイトを開発してみよう
DockerでWordPressサイトを開発してみようmookjp
 
ランサムウェアのおはなし
ランサムウェアのおはなしランサムウェアのおはなし
ランサムウェアのおはなしShiojiri Ohhara
 

What's hot (20)

makefiles tutorial
makefiles tutorialmakefiles tutorial
makefiles tutorial
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Docker超入門
Docker超入門Docker超入門
Docker超入門
 
エクストリーム ネットワークス レイヤ2/3スイッチ基本設定ガイド
エクストリーム ネットワークス レイヤ2/3スイッチ基本設定ガイドエクストリーム ネットワークス レイヤ2/3スイッチ基本設定ガイド
エクストリーム ネットワークス レイヤ2/3スイッチ基本設定ガイド
 
2011年度 新3年生向け
2011年度 新3年生向け2011年度 新3年生向け
2011年度 新3年生向け
 
CMAF Live Ingest Uplink Protocol
CMAF Live Ingest Uplink ProtocolCMAF Live Ingest Uplink Protocol
CMAF Live Ingest Uplink Protocol
 
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
 
嵌入式IPMI遠端監控系統
嵌入式IPMI遠端監控系統 嵌入式IPMI遠端監控系統
嵌入式IPMI遠端監控系統
 
Pythonとパッケージングと私
Pythonとパッケージングと私Pythonとパッケージングと私
Pythonとパッケージングと私
 
BeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOSBeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOS
 
YoctoをつかったDistroの作り方とハマり方
YoctoをつかったDistroの作り方とハマり方YoctoをつかったDistroの作り方とハマり方
YoctoをつかったDistroの作り方とハマり方
 
Binderのはじめの一歩とAndroid
Binderのはじめの一歩とAndroidBinderのはじめの一歩とAndroid
Binderのはじめの一歩とAndroid
 
Yocto bspを作ってみた
Yocto bspを作ってみたYocto bspを作ってみた
Yocto bspを作ってみた
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識
 
Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded training
 
DockerでWordPressサイトを開発してみよう
DockerでWordPressサイトを開発してみようDockerでWordPressサイトを開発してみよう
DockerでWordPressサイトを開発してみよう
 
ランサムウェアのおはなし
ランサムウェアのおはなしランサムウェアのおはなし
ランサムウェアのおはなし
 

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.pptxMugilvannan11
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01Getachew 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).pdfAliEndris3
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptxSUDHAKAR S
 
Source vs object code
Source vs object codeSource vs object code
Source vs object codeSana Ullah
 
Programming in c_in_7_days
Programming in c_in_7_daysProgramming in c_in_7_days
Programming in c_in_7_daysAnkit Dubey
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxsangeetaSS
 
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 languageRai University
 
Machine Understandable code
Machine Understandable codeMachine Understandable code
Machine Understandable codejanusathis
 

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

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

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