Professional Documents
Culture Documents
Group A
p a ra lle l a lg o r ith m s .
Prerequisite:
1 . B a s ic o f p ro g ra m m in g la n g u a g e
2. C o n c ep t o f M e rg e S o rt
3. C o n c ep t o f P a r alle lis m
2. E x a m p le o f M e rg e s o rt?
3. C o n c ep t o f O p e n M P
4. H o w P a ra lle l M e rg e S o rt W o rk
o u tp u t.
T h e m er g e s o rt a lg o rith m c a n b e b ro k e n d o w n in to th e fo llo w in g s te p s :
1 . D ivid e th e in p u t a rra y in to tw o ha lv e s .
2 . R e c u rs ive ly s o rt th e le ft h a lf o f th e a rra y.
● T h e m e rg in g s te p is w h e re th e b u lk o f th e w o rk h a p p e n s in m e rg e s o rt. T h e
lim ite d m e m o ry re s o u rc es .
● In s im p le te rm s , w e c a n s a y th a t th e p ro c e s s o f m e rg e s o rt is to d ivid e th e a r ra y in to
p r o c e s s is re p ea te d u n til th e e n tire ar ra y is s o r te d .
s o r t.
ro utin e .
m e rg e s o rt v ia a n e x a m p le . L e t th e e le m e n ts o f a rra y a re -
M M IT , L o h g a o n , P u n e - 4 7
2
D e p a r tm e n t o f C o m p u te r C o u r s e : La b o r a to r y
● N o w , a g a in d iv id e th e s e tw o a rra y s in to h a lv e s . A s th e y a re o f s ize 4 , d iv id e th e m
in to n e w a rra ys o f s ize 2.
● N o w , c o m b in e th e m in th e s a m e m a n n e r th e y w er e b ro k en .
a n o th e r a rra y in s o rte d o rd e r.
● S o , firs t c o m p a re 1 2 a n d 3 1 , b o th a re in s o r te d p o s itio n s . T h e n c o m p a re 2 5 a n d 8 ,
s o r t th e m a n d p u t 17 f irs t fo llo w e d b y 3 2 . A f te r th a t, c o m p a re 4 0 a n d 4 2 , an d
p la c e th e m s e q u e n tially .
m e rg e th e m in to a n ar ra y o f fo u n d v a lu e s in s o rte d o rd e r.
M M IT , L o h g a o n , P u n e - 4 7
3
D e p a r tm e n t o f C o m p u te r C o u r s e : La b o r a to r y
Concept of OpenMP
● O p e nM P p ro g ra m s a re d e s ig n e d to ta k e a d v a n ta g e o f th e s h a re d - m e m o ry
a rc hite c tu r e o f m o d e rn p ro c e s s o rs , w h e re m u ltip le p ro c e s s o r c o re s c an a c c e s s
th e s a m e m e m o ry . O p e n M P us e s a fo rk - jo in m o d e l o f p a ra lle l e x e c u tio n , w h e re a
m a s te r th re a d fo rk s m u ltip le w o r k er th re a d s to e x e c u te a p a ra lle l r e g io n o f th e
s e q u e n tial p a rt o f th e c o d e .
to g e th e r in p a ra lle l to p ro d u c e th e fin a l s o r te d o u tp u t.
● A s s ig n e a c h s u b a rra y to a s e p a ra te p ro c e s s o r o r c o re fo r s o rting .
● T h e m e rg in g s te p in p a ra lle l m er g e s o rt is p e r fo rm e d in a s im ila r w a y to th e
p r o c e s s o rs o r c o re s . H o w e ve r, it a ls o re q u ire s a d d itio n a l o v e rh e a d to m a n a g e th e
M M IT , L o h g a o n , P u n e - 4 7
4
D e p a r tm e n t o f C o m p u te r C o u r s e : La b o r a to r y
c a p a b ilitie s .
a n d p a ra lle l m e rg e s o rt a lg o rith m s :
a lg o rith m .
e x p e rim e n ts o n d iff e re n t in p ut s iz e s a n d n u m b e rs o f p ro c e s s o r s o r c o re s . B y
Conclusion- In th is w a y w e c a n im p le m e n t M er g e S o rt in p a ra lle l w a y u s in g
O p e nM P a ls o c o m e to k n o w h o w to h o w to m e a s u re p e rf o rm a n c e o f s e r ia l a n d
p a ra lle l a lg o r ith m
FAQs:
1. W h a t is p a ra lle l M e rg e S o rt?
2 . H o w d o e s P a ra lle l M er g e S o rt w o rk ?
M M IT , L o h g a o n , P u n e - 4 7
5
D e p a r tm e n t o f C o m p u te r C o u r s e : La b o r a to r y
3 . H o w d o yo u im p le m e n t P a ra lle l M e r g e S o rt u s in g O p e n M P ?
4 . W h a t a re th e a d v a n ta g e s o f P a ra lle l M e rg e S o rt?
Reference link
● h ttps:/ /w w w .ge e ksforge ek s.org/m e rge -so rt/
M M IT , L o h g a o n , P u n e - 4 7
6