Identical operations on large arrays of numbers

Assignment Help C/C++ Programming
Reference no: EM131445906

Project

Simple OpenMP Experiment

Introduction

A great use for parallel programming is identical operations on large arrays of numbers.

Requirements

1. Pick an array size to do the arithmetic on. Don't pick something too huge, as your machine may not allow you to use that much memory. Don't pick something too small, as the overhead of using threading might dominate the parallelism gains.

2. Using OpenMP, add up two large floating-point arrays, putting the results in another array.

3. Do this for one thread and do this for four threads. (I.e.,
#define NUMT 1 and
#define NUMT 4

4. Time the two runs. Convert the timing results into "Mega-Multiplies per Second".

5. Review the Project Notes pages on "How Reliable is the Timing?"

6. What speedup are you seeing when you move from 1 thread to 4 threads? S = (Execution time with one thread) / (Execution time with four threads)

7. If your 4-thread-to-one-thread speedup is S (S > 1.), compute the parallel fraction:

8. float Fp = (4./3.)*( 1. - (1./S) );

Don't worry what this means just yet. This will become more meaningful soon.

9. Your commentary write-up (turned in as a PDF file) should include:

1. Tell what machine you ran this on

2. What performance results did you get?

3. What was your 4-thread-to-one-thread speedup?

4. Why do you think it is behaving this way?

5. What was your Parallel Fraction, Fp?

The main Program

Your main program would then look something like this:

#include <omp.h>
#include <stdio.h>
#include <math.h>
#define NUMT 4
#define ARRAYSIZE ??
#define NUMTRIES ??

int main( )
{
#ifndef _OPENMP
fprintf( stderr, "OpenMP is not supported here -- sorry.\n" ); return 1;
#endif

float *A = new float[ARRAYSIZE]; float *B = new float[ARRAYSIZE]; float *C = new float[ARRAYSIZE];

omp_set_num_threads( NUMT );
fprintf( stderr, "Using %d threads\n", NUMT );

double maxMegaMults = 0.; double sumMegaMults = 0.;

for( int t = 0; t < NUMTRIES; t++ )
{
double time0 = omp_get_wtime( );

#pragma omp parallel for
for( int i = 0; i < ARRAYSIZE; i++ )
{
C[i] = A[i] * B[i];
}

double time1 = omp_get_wtime( );
double megaMults = (double)ARRAYSIZE/(time1-time0)/1000000.; sumMegaMults += megaMults;
if( megaMults > maxMegaMults ) maxMegaMults = megaMults;
}

double avgMegaMults = sumMegaMults/(double)NUMTRIES );
printf( " Peak Performance = %8.2lf MegaMults/Sec\n", maxMegaMults
);

printf( "Average Performance = %8.2lf MegaMults/Sec\n", avgMegaMults
);

// note: %lf stands for "long float", which is what printf calls a "double"
// %d stands for "decimal integer", not "double"

return 0;
}

Project Turn-In Procedures
- Your project turnins will all be electronic.
- Your electronic turnin will be done at https://engr.oregonstate.edu/teach and will consist of:

1. Source files of everything (.cpp, .cl)

2. A Linux or Windows executable file, if needed.

3. A report in PDF format.

Electronic submissions are due at 23:59:59 on the listed due date.

- Your PDF report will include:

1. A title area, including your name, project number, and project name.

2. Any tables or graphs to show your results.

3. An explanation of what you did and why it worked the way it did. Your submission will not be considered valid unless you at least attempt to explain why it works the way it does.

You can turn in all of your files, if you want, in a .zip file except the PDF report. Please leave the PDF report out of the .zip file. (I have a script that vacuums up all your PDF files so I can read them as one big PDF. I can get your project grades back to you faster this way.)

- Your project will be graded and the score posted to the class web page.

If you want to know why you did not receive full credit, send me an email asking about it, or see me during Office Hours.

Verified Expert

The project code is written in C++.In this project, I have tried to parallelize the code of adding two large floating point arrays and storing the result in third array. To accomplish this, I have used “openmp” library as it has an API to set number of threads that would be running the parallel piece of code. Here, in this project, I have calculated the execution time of the code running on a single thread and compared it with the execution time obtained by running the same code using 4 threads. This comparison is done to compute speed up and is stored in variable, s. Further, I have calculated the parallel fraction using this value.

Reference no: EM131445906

Questions Cloud

What are the compositions of the two phases : Aniline is used to extract methylcyclohexane (MCH) from a binary solution with 70% heptane by a single-stage extractor: If enough aniline is added to dilute the heptane by a factor of 7, what are the compositions of the two phases resulting from the..
Define shaplry value : The formula for the Shapley value is where i is the set of all coalitions S ⊂ N containing i as a member (i.e., i ∈ S). Show that an equivalent formula is
Understanding the unique challenges facing leaders today : Learning Activity 1 Theme One: Understanding the unique challenges facing leaders today, and the skills needed to meet them, will help you as a leader to act decisively and proactively.
What basis might the court hold that hemmerling wan : Conflicts of interest. Oxy Corp. is a negotiating with Wick Construction Co. for renovation of Oxy's corporate headquarters. Wick, the owner of Wick Construction Co. is also one of the five members of Oxy's board of directors. The contract terms a..
Identical operations on large arrays of numbers : CS 475/575 -- Spring Quarter 2017 - Pick an array size to do the arithmetic on. Don't pick something too huge, as your machine may not allow you to use that much memory. Don't pick something too small, as the overhead of using threading might domi..
Service technicians for the upcoming week : One day, Edwin gives Jackie the stack of work tickets for the service technicians for the upcoming week.  The technicians are to take whatever ticket is on top once they finish their prior service ticket job.
What major cpus were made during that time : What major CPU's were made during that time? What kind of software did these cpus ran on? What kind of performance did they had? What was the first AMD made? How was it different from Intel?
Who should be promoted to a team leader position : 1. What form of bonuses/ benefits can be offered to work team members and what decision style would be appropriate. (20-40 words) 2. Who should be promoted to a team leader position? (20-40 words) 3. Whether to work longer hours over the Christm..
Describe how your research builds upon the base of knowledge : The arrangement, analysis, and conclusions must be original. Specifically, you will evaluate criminal justice data, interpret published research findings, and apply scientific methodology to answer a criminal justice research question.

Reviews

inf1445906

4/11/2017 5:47:54 AM

The task was done in time yet did not have all that it should alongside sentence structure mistakes. Presently I am sticking to this team only, its really worth to deal with.

inf1445906

4/11/2017 5:47:28 AM

There is a point in the assignment, point no.5, saying review the project notes for checking the time reliability. Due to security concerns, gmail doesn't let you send executable over mail. However, the executable for this project is a simple batch file. The contents of bat file are: @echo off C:\TDM-GCC-64\bin\g++ -fopenmp C:\Users\ragichug\Documents\compute.cpp -o compute compute pause You can copy these contents in a notepad document and save it as "script.bat" where the file type should be all files. With these simple steps, the executable,named script.bat would be created.

len1445906

3/31/2017 3:28:46 AM

Grading: Feature Points Execution time results for 1 thread 5 Execution time results for 4 threads 5 Four-thread-to-one-thread Speedup 5 Parallel Fraction 10 Commentary 5 Potential Total 30 • Your project will be graded and the score posted to the class web page. If you want to know why you did not receive full credit, send me an email asking about it, or see me during Office Hours.

len1445906

3/31/2017 3:28:31 AM

1. Pick an array size to do the arithmetic on. Don't pick something too huge, as your machine may not allow you to use that much memory. Don't pick something too small, as the overhead of using threading might dominate the parallelism gains. 2. Using OpenMP, add up two large floating-point arrays, putting the results in another array. 3. Do this for one thread and do this for four threads. (I.e., #define NUMT 1 and #define NUMT 4 4. Time the two runs. Convert the timing results into "Mega-Multiplies per Second". 5. Review the Project Notes pages on "How Reliable is the Timing?" 6. What speedup are you seeing when you move from 1 thread to 4 threads? S = (Execution time with one thread) / (Execution time with four threads) 7. If your 4-thread-to-one-thread speedup is S (S > 1.), compute the parallel fraction: 8. float Fp = (4./3.)*( 1. - (1./S) ); Don't worry what this means just yet. This will become more meaningful soon. 9. Your commentary write-up (turned in as a PDF file) should include: 1. Tell what machine you ran this on 2. What performance results did you get? 3. What was your 4-thread-to-one-thread speedup?

Write a Review

C/C++ Programming Questions & Answers

  A hierarchical jpeg encode decoder for greyscale images

This project is to develop a program that implements a hierarchical JPEG encoder/decoder for greyscale images.

  Write a c++ program that reads a set of integers

Write a c++ program that reads a set of integers and then finds and prints the sums of the even and odd numbers.

  Draw a two-dimensional house seen from the front

Draw a two-dimensional house seen from the front, the way a child would: with a dor, two windows, and a roof with a chimney

  A used car dealership maintains an inventory

Submit the completed program (all 4 parts) including all class definitions/implementations in a single .cpp source file (i.e., do not construct separate files for class headers and implementation).

  Define a relation rf by the rule

Consider three sets A, B, and C, where A has 7 elements, B has 5 elements, and C has 2 elements. How many (ternary) relations are there on the sets A, B, C?

  Logic in main and modularize

Classes (use hiding, getters and setters, multiple constructors and methods). Use functions - make your main very short. Try not to use any long detailed logic in main and modularize your application.

  Create a file, shared.txt

When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

  Program prompts the user to input the height and the radius

Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Format the output to two decimal places.

  Sorting the students based on the graduation date

Sorting the students based on the graduation date - Sorting the students based on GPA - Your program should also compile and run. The user of the program should not notice any difference when running the program with any of your implementations for..

  Write a c++ program which will calculate the monthly balance

Write a C++ program which will calculate the monthly balance of a debt. Each month a payment is made on the balance, and interest is added to the balance using a fixed percentage rate.

  Using opengl to create a cube

Write a program in C/C++ using OpenGL to create (without using built in function) a cube by implementing translation algorithm by translating along 1. X-axis, 2.Y-axis and 3. X and Y plane

  Which of these sorting algorithms only works on integers

What is the third value in the postorder traversal of this binary search tree? What is the third value in the preorder traversal of this binary search tree?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd