scispace - formally typeset
Search or ask a question

Showing papers by "Thomas H. Cormen published in 2015"


Book ChapterDOI
01 Jan 2015
TL;DR: This chapter includes a simple analysis of the tradeoffs between sequential and parallel versions of reduction and scan operations, and uses Python for-loops to indicate which can be run in parallel and which cannot.
Abstract: Drawing heavily from Blelloch’s work on the vector model and scan operations, we work our way up to performing a parallel version of the quicksort algorithm on a shared-memory machine with p processors. We first see how to perform reduction and scan operations in parallel. We then examine parallel meld and permute operations, which lead to unsegmented partitioning in parallel. We then introduce segmented operations and modify our partitioning procedure to work with segmented operations, leading to a fully parallel version of quicksort. Python code appears for most, but not all, of the operations in this chapter. We omit Python code for partitioning and for the full parallel quicksort because these programs make for excellent exercises. The Python code we use does not itself run in parallel. To run code in parallel with Python, we would have to lock into a particular Python library. The concepts behind parallel programming are more important than the exact means to achieve parallelism. Therefore, we use Python for-loops and indicate which can be run in parallel and which cannot. An outer for-loop (i.e., a for-loop that is not nested in another for-loop) that runs for at most p iterations is parallelizable and therefore can run on the p processors concurrently. A for-loop that is nested within a parallelizable for-loop is not parallelizable; all of its iterations run sequentially on a given processor. Instructors who wish to have their students actually run the code in parallel may translate our code to their favorite Python library. For sufficiently advanced courses, this chapter includes a simple analysis of the tradeoffs between sequential and parallel versions of reduction and scan operations.

5 citations