HOMEWORK 1 Solution

$29.99 $18.99

(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 <Your Name>’s first parallel program There are currently n threads running Implement your program so that…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product
  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 <Your Name>’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.

  1. (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

  • 10 11 12 13

  • 1 101112

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 in-put/output examples will be provided to help you debug your code.

  1. (20 pts.) Use OpenMP to implement a parallel version of the program that you imple-mented 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.