Programming for multi-Core environments…
In day-to-day programming, we do not pay enough attention to the fact that we may not using the power of multi-core architectures optimally. We usually assign the total workload to a single thread. You might wonder that why I am blogging about the very basics of Concurrency. Yes, I am. But I am trying to show the power of concurrency in multi-core environments using some statistics that I collected for an assignment for the module “Concurrent Programming”.
Sorting of an integer array using Quick Sort is the task that was used to collect the statistics. Quick Sort was implemented both sequentially and in parallel. And the elapsed time to sort the array was measured for different array sizes.
In the parallel approach, after breaking down the original array into two sub arrays based on the pivot element, two tasks are created for sorting these two sub arrays and assigned these tasks to the Java Executor Framework. (I used Java Executor Framework for managing threads, because it is not necessary to undertake the burden of creating, synchronizing, managing and terminating the threads manually.)
Following is the summary of the results obtained.
For the sequential approach following graph is resulted.
For the parallel approach, following is the graph obtained.
It is quite interesting to see both cores becomes busy at the sametime while resulting with the inproved performance.
Why use single core, leaving others idle.. ? 🙂
About this entry
You’re currently reading “Programming for multi-Core environments…,” an entry on thilina's blog
- January 6, 2009 / 1:43 pm