Basics Concepts of Parallel Programming. What is parallel computing It’s a form of computation where many calculations can be carried out simultaneously.

Slides:



Advertisements
Présentations similaires
Clique Percolation Method (CPM)
Advertisements

Making PowerPoint Slides Avoiding the Pitfalls of Bad Slides.
PERFORMANCE One important issue in networking is the performance of the network—how good is it? We discuss quality of service, an overall measurement.
PIPE SUPPORTS 1 Pipe supports inside the compression station and pumping stations AUGUST 2014.
1 Case Study 1: UNIX and LINUX Chapter History of unix 10.2 Overview of unix 10.3 Processes in unix 10.4 Memory management in unix 10.5 Input/output.
An Introduction To Two – Port Networks The University of Tennessee Electrical and Computer Engineering Knoxville, TN wlg.
Traffic Sign Recognition Jacob Carlson Sean St. Onge Advisor: Dr. Thomas L. Stewart.
 Components have ratings  Ratings can be Voltage, Current or Power (Volts, Amps or Watts  If a Current of Power rating is exceeded the component overheats.
IP Multicast Text available on
Update on Edge BI pricing January ©2011 SAP AG. All rights reserved.2 Confidential What you told us about the new Edge BI pricing Full Web Intelligence.
CNC Turning Module 1: Introduction to CNC Turning.
UNEP / ICCA Workshop TEMA June DG and GHS Classification System.
Subject: CMS(Content Management System) Université Alioune DIOP de Bambey UFR Sciences Appliquées et Technologies de l’Information et de la Communication.
jeudi, le quatorze septembre
CONJUGAISON.
Formules en 2 étapes 1MPES4
Infinitive There are 3 groups of REGULAR verbs in French: verbs ending with -ER = 1st group verbs ending with -IR = 2nd group verbs ending with -RE = 3rd.
Qu’est-ce qu’ils aiment faire?
mardi, le douze septembre
IDL_IDL bridge The IDL_IDLBridge object class allows an IDL session to create and control other IDL sessions, each of which runs as a separate process.
l y a which we have already learned means “there is/are l y a which we have already learned means “there is/are.” When we put a measure of time.
1 Chapter 1 An Introduction to Structured Program Design in COBOL.
Le Corps.
Francais 4 Chapter 4 Grammar 1
Reflective verbs or Pronominal verbs
Quantum Computer A New Era of Future Computing Ahmed WAFDI ??????
Statistics & Econometrics Statistics & Econometrics Statistics & Econometrics Statistics & Econometrics Statistics & Econometrics Statistics & Econometrics.
Français I – Leçon 6A Structures
Conditional Clauses By Mª Mercedes Sánchez Year
There are so many types of sports. For example-: Basketball,volleyball, cricket, badminton, table tennis, football, lawn tennis etc.
NFPA-12 Edition 2005 What “IMPACT” will the changes to NFPA-12 have on the design and installation of a CO 2 system?
© 2004 Prentice-Hall, Inc.Chap 4-1 Basic Business Statistics (9 th Edition) Chapter 4 Basic Probability.
F RIENDS AND FRIENDSHIP Project by: POPA BIANCA IONELA.
Phase-Locked Loop Design S emiconducto r S imulation L aboratory Phase-locked loops: Building blocks in receivers and other communication electronics Main.
P&ID SYMBOLS. P&IDs Piping and Instrumentation Diagrams or simply P&IDs are the “schematics” used in the field of instrumentation and control (Automation)
G. Peter Zhang Neurocomputing 50 (2003) 159–175 link Time series forecasting using a hybrid ARIMA and neural network model Presented by Trent Goughnour.
Lect12EEE 2021 Differential Equation Solutions of Transient Circuits Dr. Holbert March 3, 2008.
Essai
Introduction to Computational Journalism: Thinking Computationally JOUR479V/779V – Computational Journalism University of Maryland, College Park Nick Diakopoulos,
High-Availability Linux Services And Newtork Administration Bourbita Mahdi 2016.
Français - couleurs - pays - drapeaux
The Passé Composé In the previous lesson we looked at the formation of the passé composé (perfect tense) with Avoir verbs. In this lesson we will further.
Le soir Objectifs: Talking about what you do in the evening
La famille ER conjugaison
Qu’est-ce que tu as dans ta trousse?
Qu’est-ce que tu as dans ta trousse?
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
Definition Division of labour (or specialisation) takes place when a worker specialises in producing a good or a part of a good.
Roots of a Polynomial: Root of a polynomial is the value of the independent variable at which the polynomial intersects the horizontal axis (the function.
Standards Certification Education & Training Publishing Conferences & Exhibits Automation Connections ISA EXPO 2006 Wed, 1:00 Oct 18.
Manometer lower pressure higher pressure P1P1 PaPa height 750 mm Hg 130 mm higher pressure 880 mm Hg P a = h = +- lower pressure 620 mm Hg.
WRITING A PROS AND CONS ESSAY. Instructions 1. Begin your essay by introducing your topic Explaining that you are exploring the advantages and disadvantages.
Making PowerPoint Slides Avoiding the Pitfalls of Bad Slides.
POWERPOINT PRESENTATION FOR INTRODUCTION TO THE USE OF SPSS SOFTWARE FOR STATISTICAL ANALISYS BY AMINOU Faozyath UIL/PG2018/1866 JANUARY 2019.
© by Vista Higher Learning, Inc. All rights reserved.4A.1-1 Point de départ In Leçon 1A, you saw a form of the verb aller (to go) in the expression ça.
By : HOUSNA hebbaz Computer NetWork. Plane What is Computer Network? Type of Network Protocols Topology.
les instructions Bonjour la classe, sortez vos affaires
5S Methodology How to implement "5S" and get extraordinary results.
1 Sensitivity Analysis Introduction to Sensitivity Analysis Introduction to Sensitivity Analysis Graphical Sensitivity Analysis Graphical Sensitivity Analysis.
Avoiding the Pitfalls of Bad Slides Tips to be Covered Outlines Slide Structure Fonts Colour Background Graphs Spelling and Grammar Conclusions Questions.
Le Passé Composé (Perfect Tense)
Les Mots Intérrogatifs
University : Ammar Telidji Laghouat Faculty : Technology Department : Electronics 3rd year Telecommunications Professor : S.Benghouini Student: Tadj Souad.
Les opinions Les opinions = Opinions. In this lesson pupils will learn to understand and give their own opinions about singular items.
L’orchestre des animaux
Direct and Indirect Object Pronouns in French
Over Sampling methods IMBLEARN Package Realised by : Rida benbouziane.
IMPROVING PF’s M&E APPROACH AND LEARNING STRATEGY Sylvain N’CHO M&E Manager IPA-Cote d’Ivoire.
M’SILA University Information Communication Sciences and technology
Transcription de la présentation:

Basics Concepts of Parallel Programming

What is parallel computing It’s a form of computation where many calculations can be carried out simultaneously. In parallel computing we can divide large programs into smaller one and perform computation simultaneously.

3/24/20193

4

Save time and/or money Solve larger problems Provide concurrency 3/24/20195

Physics - applied, nuclear, particle, condensed matter, high pressure, fusion, photonics Bioscience, Biotechnology, Genetics Chemistry, Molecular Sciences Geology, Seismology Mechanical Engineering - from prosthetics to spacecraft Electrical Engineering, Circuit Design, Microelectronics Computer Science, Mathematics 3/24/20196

Threads “ A Thread is single stream of control in the flow of a program” Example 1: Consider the following code which computes product of 2 dense matrice of size n x n. for(row=0;row<n;row++) for(column=0;column<n;column++) c[row][column]=dot_product(get_row(a,row), get_col(b,col));

 The for loop in this code fragment has n 2 Iteration, each which can be executed independently. Such independent sequence of instructions is referred as thread.  In above example there are n 2 threads one for each iteration of for loop. Since each thread can be executed independently of others, they can be scheduled concurrently on multi processors. Example 2:here we are using function called create_thread to provide mechanism for specifying c function as thread for(row=0;row<n;row++) for(column=0;column<n;column++) c[row][column]=create_thread(dot_product(get_r ow(a,row),get_col(b,col)));

Thread –Basic Unit of execution –Light weight process –Process can have multiple thread Why thread –To improve the CPU Utilization Note: all threads share same shared memory. 3/24/20199

An Application Program Interface (API) that may be used to explicitly direct multi-threaded, shared memory parallelism. OpenMP is an API that can be used with FORTRAN, C and C++ for programming shared address space machines. OpenMP directives provides support for concurrency, synchronization and data handling. The OpenMP directives in C and C++ are based on the #pragma compiler directives. 3/24/201910

OpenMP programs execute serially until they encounter the parallel directive. This directive is responsible of creating group of threads. The main thread that encounters the parallel directive becomes the Master of this group of thread and the thread is assigned with ID 0 within this group

Fork - Join Model: –OpenMP uses the fork-join model of parallel execution: –All OpenMP programs begin as a single process: the master thread 3/24/201912

Format: Ex: –#pragma omp parallel default(shared) private(beta,pi) 3/24/ #pragma ompdirective-name[clause,...]newline Required for all OpenMP C/C++ directives. A valid OpenMP directive. Must appear after the pragma and before any clauses. Optional. Clauses can be in any order, and repeated as necessary unless otherwise restricted. Required. Precedes the structured block which is enclosed by this directive.

A parallel region is a block of code that will be executed by multiple threads When a thread reaches a PARALLEL directive –It creates a team of threads –Becomes the master of the team. –Master thread ID is 0. Starting from the beginning of the parallel region, –the code is duplicated –all threads will execute that code If any thread terminates within a parallel region, all threads in the team will terminate 3/24/201914

The number of threads in a parallel region is determined by the following factors –Setting of the NUM_THREADS clause –Use of the omp_set_num_threads() library function –Setting of the OMP_NUM_THREADS environment variable –Implementation default - usually the number of CPUs on a node 3/24/201915

#pragma omp parallel It’s a parallel directive that creates groupp of threads. Using this we can compute operations parallelly.

tid=omp_get_thread_num() Used to give unique ID for each thread created.

L11.Design, develop and execute a parallel program in C to add, element wise, two one- dimensional arrays A and B of N integer elements and store the result in another one- dimensional array C of N integer elements.

#include int main() { int a[10],b[10],c[10],i, n; printf("\nenter the number of elements"); scanf("%d",&n); printf("\nEnter the element of 1st array"); for(i=0;i<n;i++) scanf("%d",&a[i]);

printf("enter the elements of 2nd array"); for(i=0;i<n;i++) scanf("%d",&b[i]); printf("\nthe contents of array A\n"); for(i=0;i<n;i++) { printf("\na[%d]=%d",i,a[i]); }

printf("\nthe contents of array B\n"); for(i=0;i<n;i++) { printf("\nb[%d]=%d",i,b[i]); }

#pragma omp parallel for shared(c) for(i=0;i<n;i++) { #pragma omp critical (c_lock) c[i]=a[i]+b[i]; printf("\nc[%d]=%d,thread id=%d\n",i,c[i],omp_get_thread_num()); }

printf("\nthe new array is===="); for(i=0;i<n;i++) { printf("%d ", c[i]); }

L14.Design, develop and execute a parallel program in C to determine and print the prime numbers which are less than 100 making use of algorithm of the Sieve of Eratosthenes.

#include int main() { int num[100], i, j; #pragma omp parallel for for(i=0;i<=99;i++) /*Fill num with the first 100 numbers*/ { num[i]=i+1; printf("\nnum[%d]=%d,thread id=%d\n",i,num[i],omp_get_thread_num()); }

#pragma omp parallel for for(i=1;i<=99;i++) { if(num[i]!=0) { #pragma omp parallel for for(j=(i+1);j<=99;j++) { if(num[j]!=0) { if((num[j]%num[i])==0) num[j]=0; } } } }

for(i=0;i<=99;i++) { if(num[i]!=0) /*Print all non zero numbers (prime numbers)*/ printf(" %d",num[i]); } getch(); }