Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program One: Parallel Prefix Sum Write a C or C++ program to calculate Prefix Su

ID: 3573280 • Letter: P

Question

Program One: Parallel Prefix Sum Write a C or C++ program to calculate Prefix Sum Use P Threads Use standard reduction algorithm Compile on head node SSH into amdquad01 and execute Compare to serial version Run serial program for different input sizes 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 Run parellel version for the same input sizes as serial 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 Run parellel version using number of threads to match the input size ie N/2 Deliverables to dropox on D2L Source Code Graph of results A plot of Input Size VS SpeedUp

Explanation / Answer

#include<iostream>

#include<math.h>                                        //Library for Pfunc

int main()

{

        int x[12] = {2,4,8,16,32,64,128,256,512,1024,2048,4096 };                     //declares the size of array

        int n = sizeof(x) / sizeof(int);

        //int i = 0;

        for (int j = 1; j <= n - 1; j++) {

                x[j] = x[j] + x[j - 1];

        }

        std::cout << "The Prefix Sum of int input[12] = {2 4 8 16 32 64 128 256 512 1024 2048 4096} is: ";

        std::cout << "{";

        for (int i = 0; i < n - 1; i++)

                std:cout << x[i] << ",";             //Loop only read the 1st line after execution

        std::cout << x[n-1] << "}";

return 0;

//system("pause");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote