CS 4000 Homework # 1 OpenMP solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

1. (10 pts.) Implement a “hello-world” program using OpenMP. Your program should create as many threads as their are processors/cores on your current machine. From each thread that you create, your program should print: Hello from thread i. This is ’s first parallel program There are currently n threads running Implement your program so that the text given above is printed in one block for each thread. 2. (10 pts.) Consider the following problem. Given an n×n matrix of numbers, an integer m, and a modulus q, find the largest product of m modulo q numbers in a row, either vertically, horizontally, or diagonally. Write a program that outputs the value of the largest product on a line by itself. For example, consider the following 5 × 5 matrix of values with the value m = 4 and q = 1000000 : 10 1 1 1 1 1 10 11 12 13 1 1 10 11 12 1 1 1 10 1 1 1 1 1 10 Your program should produce the answer “17160” (10 × 11 × 12 × 13). When m = 5, your program should answer “100000” Implement your program in C++ and provide adequate documentation. Test input/output examples will be provided to help you debug your code. 3. (20 pts.) Use OpenMP to implement a parallel version of the program that you implemented in problem #2. Implement your program using #pragma omp parallel. Compare your program’s running time to your original program. Your program should be at least 75% efficient on a four core machine on put of a 1000 x 1000 array with m = 500. Implement your program in C++ and provide adequate documentation.