Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises.

Similar presentations


Presentation on theme: "Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises."— Presentation transcript:

1 Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises

2 2-2 Lab # 2: Parallel Sort using MPAC

3 2-3 Lab 2 – Parallel Sorting Objectives To implement two parallel sorting algorithm Quick sort Bucket Sort Mechanism Generate an user defined array of random values Partition the data array using user specified algorithm Worker threads sorts the partitioned array Merge the partitioned arrays Performance measurements

4 2-4 Parallel Quick Sort The data array is partitioned into N arrays of equal length, where N = No. of threads Each partitioned array is passed to a different thread Each thread sorts its respective array All sorted partitioned arrays are passed to main thread where they are merged together The merged array is sorted

5 2-5 Parallel Quick Sort 31 23 14 26 8 36 4 21 4 7 1 43 32 12 21 7 31 23 14 26 8 36 4 21 4 7 1 43 32 12 21 7 14 23 26 31 4 8 21 36 1 4 7 43 7 12 21 32 14 23 26 31 4 8 21 36 1 4 7 43 7 12 21 32 1 4 4 7 7 8 12 14 21 23 26 31 32 36 43 Thread Function (1) (2) (3) (4)

6 2-6 Cross Compile for Target System Cross Compile on Host System Go to Cavium SDK directory and run the command host$ source env-setup (where is the model of your target board. E.g. OCTEON_CN56XX) host$ cd / /mpac_1.2 host$./configure --host=i386-redhat-linux-gnu --target=mips64-octeon-linux-gnu export CC=mips64-octeon-linux-gnu-gcc host$ make clean host$ make CC=mips64-octeon-linux-gnu-gcc

7 2-7 Run on target system Copy executable “mpac_sort_app” on target system target $./mpac_sort_app –n –s -u q For Help target$./mpac_sort_app –h

8 2-8 Parallel Bucket Sort Minimum and Maximum values are identified from the data array Range of data is identified (maximum –minimum) N buckets of equal intervals are formed, where N is no. of threads The interval length is calculated by (maximum – minimum)/no. of threads The first bucket starts with the minimum value and the last bucket ends with maximum value

9 2-9 Parallel Bucket Sort (cont…) A bucket is a dynamically allocated array Each element of the data array is stored in its corresponding bucket (the interval in which the data lies) After all elements are copied in the buckets, each bucket is sent to an individual thread Each thread sorts its respective array All sorted partitioned arrays are passed to main thread where they are merged together This merged array will be a sorted array

10 2-10 Parallel Bucket Sort 14 21 12 21 31 23 26 32 36 43 1 4 4 7 12 14 21 23 26 31 32 7 8 36 43 1 4 4 7 7 8 12 14 21 23 26 31 32 36 43 Thread Function 31 23 14 26 8 36 4 21 4 7 1 43 32 12 21 7 1 - 1112 - 2223 - 3334 - 44 8 4 4 7 1 7 (1) (2) (3) (4)

11 2-11 Cross Compile for Target System Cross Compile on Host System Go to Cavium SDK directory and run the command host$ source env-setup (where is the model of your target board. E.g. OCTEON_CN56XX) host$ cd / /mpac_1.2 host$./configure --host=i386-redhat-linux-gnu --target=mips64-octeon-linux-gnu export CC=mips64-octeon-linux-gnu-gcc host$ make clean host$ make CC=mips64-octeon-linux-gnu-gcc

12 2-12 Run on target system Copy executable “mpac_sort_app” on target system target $./mpac_sort_app –n –s -u b For Help target$./mpac_sort_app –h

13 2-13 Performance Measurement Observations Observe the decreasing elapsed time indicating increase in performance with increasing number of threads Bucker Sort is more efficient than Quick Sort algorithm (a) Bucket Sort(a) Quick Sort $./mpac_sort_app –n –s 500000 –u b –a 1 $./mpac_sort_app –n –s 500000 –u q –a 1


Download ppt "Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises."

Similar presentations


Ads by Google