Journal of Computer Aided Parallel Programming Volume 2 Issue 1 Optimization of Sorting Algorithm Using OpenMP C.D. Vaidya1, Ankit Manwatkar2, Ankit Pande3, Shritej Pochalwar4 Professor1 Department of Computer Science & Engineering Rajiv Gandhi College of Engineering & Research, Nagpur, Maharashtra, India\ Corresponding Author: [email protected] Abstract In today’s world, multi-core processors have become popular due to performance, and their ability to performed multiple tasks simultaneously. We are trying to explore OpenMP for parallelization of sequential program in multicore architecture to translate sequential program to parallel using Parallel Processing. So, we are working on parallelizing bubble sort to reduce execution time. OpenMP pragmas are found to be useful in parallelizing the sorting operation to reduce sorting time to a great extent. As we observed that the traditional bubble sort algorithm cannot be implemented in a parallel processing because of the iteration dependency. So, there is need of some different technique to run bubble sort in a parallel processing. Thus, we are trying to parallelize traditional bubble sort without Iteration dependency. Keywords: Serial Processing, Parallel processing, OpenMP, Sorting, Bubble Sort, Time Complexity, Multi-Threading INTRODUCTION In computes, Parallel Processing is the Serial processing is the attending to and processing of programs by dividing them processing one item at a time, while parallel into multiple segments with a unique thread memory processing is the act of attending to and this is done to reduce the execution time and processing all items simultaneously. of program. 1 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 We are focusing on the bubble sort II. LITERATURE REVIEW algorithm. Bubble sort is one of the oldest, The the simplest sorting programming interface that creates an algorithm in use having a complexity level environment in which programs could be of O(n2). Bubble sort works by comparing implemented in parallel processing. The each item with its next item in the list and bubble sort algorithm takes (n-1) iterations swapping them if they are in erroneous to sort „n‟ number of unsorted elements. order. and the slowest Repeats this process until OpenMP[1] is an application no swapping is required for items. Such a A sorting algorithm is one that puts situation means that all the items are in the elements of a list in a certain order. It makes correct order. By this way, larger values easy searching and locating the information. move to the end of the list whereas smaller values remain towards the beginning of the The most-used orders are numerical order list. It is also used in order to sort the array and lexicographical order. An efficient such like the smaller values comes after the sorting algorithm is that takes less time and larger values. In other words, all items are space complexity. In this paper, I make in the correct order. contrastive analysis of bubble sort[2] and merge sort and tried to show why required In the sorting algorithm, if you observe the some new approach to get best sorting move of the elements with higher orders, results. they are like bubbles in the water, floating slowly from the bottom to the top. Based on the analysis of the traditional bubble sort algorithm, this paper proposes Bubble sort is simple to program, but it is two bidirectional bubble sort algorithm worse than selection sort for a jumbled design ideas. After giving C language array. It will require many more module description of the three algorithms, the exchanges, and is just good for a well- paper tests the new algorithms, analyzes ordered array. More importantly bubble sort comparatively the time complexity [3] and is usually the easiest one to write correctly. space complexity of the three algorithms, and summarizes such a conclusion that the first new algorithm has the same average 2 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 time complexity and space complexity as thread assigns a specific number of threads the original algorithm, while the second is to the slave threads and a task is divided time efficient than the original one, and thus between them. Open MP is basically truly reaches the optimization purpose. designed for shared memory multiprocessors, using the SPMD model III. METHODOLOGY (Single Program, Multiple Data Stream). All Parallel processing makes a single large task the processors are able to directly access all to be executed on multiple threads, for this the shared memory in the machine, through reason the divide-and-conquer approach is a logically directed connection. usually preferred over other techniques. The main idea of the proposed method is Programs will be executed on one or more distributing the elements of the input processors that may share some or all of the datasets into many partitions according to available memory. The program is typically an analysis made on dataset elements and executed by multiple independent threads each partition is sorted with a bubble sort that share data, but may also have some algorithm using unique threads. additional private memory zones. Bubble Sort in Openmp Open MP provides a straight forward inter Open MP is a widely adopted shared face to write software that can be used for memory parallel programming interface multiple core computers. Using Open MP, providing high level programming. The the programmer can write code that will be range of Open MP applicability was able to use all cores of a multicore significantly extended recently by the computer, and will be run faster if the addition of explicit tasking features. number of cores is increased. In this section, we will execute our sequential bubble sort The idea behind Open MP is that the user as parallel by using an Open MP, in the specifies the parallelization strategy for a early stage of the program writing we program at a high-level by providing the should adapt our environment to be able to program the understand Open MP statements. It is not implementation of multithreading [9], a worthwhile just to write #include header in code. Open MP is parallel execution scheme where the master 3 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 our program but also required to include less execution time that the sorting in serial some configurations to C environment. processing, for doing this job we used parallel processing concept for optimization IV. PROPOSED METHOD in terms of time. In serial processing bubble Sorting of elements of large dataset takes sort algorithm takes countably large amount large amount of time when executed in of time. So, to reduce the execution time serial processing and whole execution done one of the option is to run this traditional using the single thread and single core, bubble sort in parallel processing, but because of this proper utilization of theoretically it is not possible to directly multicore architecture was not achieved. In parallelized this project, we proposed a technique by algorithm with multiple threads because of which proper utilization of system is done iteration dependency is shown in fig1. traditional bubble and the sorting operation is performed with Fig.1 Example of traditional Bubble sort 4 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved sort Journal of Computer Aided Parallel Programming Volume 2 Issue 1 Iteration dependency is a scenario in which dataset has been made once, on each execution of one iteration is depend on the partition separately apply bubble sort and result of previous iteration, unless execution each partition get executed with unique of one iteration is get complete later thread is shown in fig 2. iterations cannot be executed. So, we proposed a method by which we can The result of each thread is get combined in execute a bubble sort algorithm in parallel a single dataset. At this combining stage no processing without iteration dependency. additional sorting is needed because initially This can be achieved by analyzing the the partitions of a dataset are created dataset on which sorting is to be done and according to specific range of an elements. according to this analysis partitions of a Fig.2 Example of proposed Bubble sort 5 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 V. RESULT The given dataset is applied with proposed In result, we get the variation in execution method to get the desired outcome. Based time of proposed parallel bubble sort as on comparison of serial bubble sort against compare sort. parallel bubble sort (i.e. Time taken by Evaluation is done on the basis of different serial bubble sort for execution compare datasets as shown in following table. with time taken by parallel bubble sort to traditional bubble running on 4 & 16 threads) Table 1. Comparison of serial and parallel sorting Sr. No. Dataset Size Serial time (in sec) 1 threads Execution time of proposed parallel bubble sort (in sec) 4 threads 16 threads 1 25000 2.179 1.423 1.253 2 65000 18.717 9.454 8.641 3 100000 44.571 22.534 20.731 4 150000 99.995 52.32 47.253 5 175000 137.354 72.088 68.536 6 200000 178.921 92.454 83.002 6 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 Fig3. Graphical analysis CONCLUSION sort. The better performance is obvious We have implemented the bubble sort because parallel sorting algorithm take the algorithm using multithreading (Open MP). advantage of parallelism to reduce the The proposed work tested on datasets with average running time. In future, same different size taken. The effect of the analysis can be performed with parallel number of cores on the performance of sorting algorithms and parallel sorting by bubble sort has been experimentally studied. regular sampling architectures and the processors with more than two cores. It is observed that parallel sorting algorithm i.e. parallel bubble sort performs well in all respects in comparison to sequential bubble 7 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved Journal of Computer Aided Parallel Programming Volume 2 Issue 1 5) Shiying REFERENCES 1) Wang Min, “Analysis on Bubble Sort Wang, Yunxia Ren, “Diagnosability of bubble-sort graph Algorithm Optimization”, Institute of networks Electrical and Electronics Engineers, diagnosis model”, IEEE, 823 - 826, Dec. Volume 1, July 2010. 0 50 100 150 200 2015. under the comparison Execution Time (In sec) 0 50000 100000 150000 200000 Datasets 6) Monika Gurbhele, Chandu Vaidya, Graphical Analysis Serial Processing 1 “Fair share resource allocation for load threads Proposed BS 4 threads Proposed sharing” International Conference on BS 16 threads Innovations in information, Embedded and Communication Systems (ICIIECS) 2) Sehrish MunawarCheema,Nadeem 978-1-4673-8207-6 , 2016. Sarwar, Fatima Yousaf, “Contrastive Analysis of Bubble & Merge Sort 7) Prof. Chandu Vaidya, “An Approach for Proposing Hybrid Approach”, IEEE, Processor Utilization in Master Slave 371–375, Aug.2016. Environment” International Conference on Advanced Material Technologies 3) Jing-meiLi, JieZhang, “The performance analysis and research of sorting (ICAMT)December 2016. 2016. 27th and 28th Dadi Institute of algorithm based on Open MP”, IEEE, Engineering and Technology (DIET), 3281 – 3284, July 2011. Visakhapatnam, Andhra Pradesh, India. 4) Monika Gurbhele ,Chandu Vaidya and 8) C. D. Vaidya and M. B. Chandak, Hemant Turkar , “An approch for share "Efficient Parallel Process Migration resource allocation for load sharing" Algorithm Using Statistical Approach," International Computational Intelligence Communication Networks Research Journal of Innovative and in Computer and Communication Engineering DOI: 2012 Fourth International Conference 10.15680/IJIRCCE.2015. 0309001 Vol. on, Mathura, 2012, pp. 525-529.doi: 3, Issue 9, September 2015. 10.1109/CICN.2012.106. 8 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved (CICN), Journal of Computer Aided Parallel Programming Volume 2 Issue 1 9) Xiong Xiao, Shoichi Hirasaa, Hiroyuki Takizawa, and Hiroaki Kobayashi, “The Importance of Dynamic Load Balancing amongOpen MP Thread Teams for Irregular Workloads”,IEEE, 529 - 535, Nov. 2016. 10) Rohit Singhal, Gwan Choi, Rabi N. Mahapatra, “Programmable LDPC Decoder Based on the Bubble-Sort Algorithm”, IEEE,6, Jan. 2006. 11) Hadi Sutopo, “Multimedia based Instructional development: bubble sort Visualization”, IEEE, 791–794, Sept. 2015. 12) Lun-Min Shih, “Faulttolerant Connectivity Jimmy Maximal on the J.M. Tan, Local- Bubble-sort Graphs”, IEEE,564 – 569, April 2009. 9 Page 1-9 © MANTECH PUBLICATIONS 2017. All Rights Reserved
© Copyright 2025 Paperzz