Dana Vrajitoru
B424/B524 Parallel and Distributed Programming

B424/B524 Class Exercise 1

Date: Thursday, September 17, 2020.

Ex. 1 Examining tje Bernstein Conditions

Open the following file (in a browser) and examine the code.

palindrome.cc

If you open a terminal, you can copy the file with the command

cp /home/dvrajito/b4/palindrome.cc ./

You can compile it with the command

g++ palindrome.cc -o runpal

Then you can run it with the command runpal. This file contains functions to check if a string entered by the user is a palindrome.

a. Examine each of the 3 for loops in the different functions, keeping in mind a model where we might want to assign a different thread to each iteration (fine grain model) and another one where we have less threads and assign a bigger chunk of the string to each thresd (coarse grain model). For each of the loops, determine if the Bernstein's conditions for each iteration with respect to the next one are satisfied to do be able to apply the fine grain or coarse grain models.

b. If they are not, is there a way to modify the code so that the conditions are satisfied and we can do the loop in parallel? Consider the question for the fine grain and for the coarse grains models separately.

c. Would you add any barriers in this program if it was implemented in parallel? If so, where?

Upload to Canvas:

Upload a file with the answers to points a, b, and c to Canvas, Assignments, Exercise 1, or type it directly in the submission input box.