1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anit [1.1K]
3 years ago
11

(3 points) Write a program to process two large chunks of data (e.g., a large 3D array and an array of self-defined structures w

ith each structure at least 256 Bytes) respectively. The array elements can be random. The process can be incrementing every element by 1 or others. Try different ways (e.g., stride-k reference, the loop orders or others) to traverse the array elements and simulate the program performance (i.e., running time). Note that you should record the time just before and after the data processing program, not including the data generation or other initiation programs. And you should calculate an average time of at least 5 experiments for each program.

Computers and Technology
2 answers:
QveST [7]3 years ago
6 0

Answer:

Check the explanation

Explanation:

#include <iostream> #include <chrono> using namespace std::chrono; using namespace std; struct X{ int a,b,c,d,e,f,g,h; }; int main(){ // 3D Array of integers 1000 x 1000 x 1000 int data1[10][10][10]; //Array of struct X struct X data2[10000] ; auto start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 1: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[i][j][k]; } } } auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 2 access data 1 Loop order 1: for(int i=0;i<1000;i+=2){ for(int j=0;j<1000;j+=2){ for(int k=0;k<1000;k+=2){ data1[i][j][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 2 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 2: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[j][i][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 2"<<duration.count()<<endl; start = high_resolution_clock::now(); for(int i=0;i<10000;i++){ data2[i]; } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"Struct Array "<<duration.count()<<endl; }

Some Observations on the order:

<em><u>Stride 1 goes over all the elements of the array Hence takes more time than stride 2 which goes over alternate elements. </u></em>

<em><u>Loop order in the row major form takes leads time than column major form! </u></em>

<em><u>Struct array takes no time to execute because the structs are not being accessed.</u></em>

Check the code screenshot and code output in the attached image below.

anzhelika [568]3 years ago
3 0

Answer:

See explaination

Explanation:

#include <iostream> #include <chrono> using namespace std::chrono; using namespace std; struct X{ int a,b,c,d,e,f,g,h; }; int main(){ // 3D Array of integers 1000 x 1000 x 1000 int data1[10][10][10]; //Array of struct X struct X data2[10000] ; auto start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 1: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[i][j][k]; } } } auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 2 access data 1 Loop order 1: for(int i=0;i<1000;i+=2){ for(int j=0;j<1000;j+=2){ for(int k=0;k<1000;k+=2){ data1[i][j][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 2 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 2: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[j][i][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 2"<<duration.count()<<endl; start = high_resolution_clock::now(); for(int i=0;i<10000;i++){ data2[i]; } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"Struct Array "<<duration.count()<<endl; }

Kindly check attachment for screenshot of the source code for proper indentation.

You might be interested in
How do you change the top and bottom margins of an entire document?
Firdavs [7]

Answer:

Click the Page Layout tab and then the Margins button.

Choice D is correct

Explanation:

In order to change the top and bottom margins of an entire document, simply

Click the Page Layout tab and then the Margins button.

I hope this helps..

Great Day ahead

4 0
3 years ago
Read 2 more answers
opearating system protection refers to a mechanism for controling access by programs, processes, or users to both system and use
Alekssandra [29.7K]

Answer:

The operating system must by the use of policies define access to and the use of all computer resources.

Policies are usually defined during the design of the system. These are usually default in settings. Others are defined and or modified during installation of the addon and or third-party software.

Computer Security Policies are used to exact the nature and use of an organisations computers systems. IT Policies are divided into 5 classes namely:

  1. General Policies
  2. Server Policies
  3. VPN Policies
  4. Back-Up Policies
  5. Firewall Access and Configuration Policies

Cheers!

5 0
3 years ago
The New option is found in the ...............tab.​
morpeh [17]

in your notes books and in your vopy

3 0
3 years ago
Read 2 more answers
How does naming affect a variable’s creation and use?
Evgen [1.6K]

Answer:

Each variable is named so it is clear which variable is being used at any time. It is important to use meaningful names for variables: ... The name given to each variable is up to the programmer, but ideally a variable name should have meaning, ie it should reflect the value that it is holding.

Variables make code more than a static set of instructions. They allow logic to occur, enabling developers to measure time, analyze data, and customize the program to the user. Variables are so important to the code that they deserve a good name that accurately describes their purpose

Explanation:

4 0
2 years ago
A sequence of repetitive operations performed to evaluate the ability of a PC to operate at peak efficiency for a defined time p
iragen [17]

Answer:

False.

Explanation:

The description provided matches better with Software performance testing, and shouldn't be confused with a benchmark.

In computing, a benchmark is a tool or software designed to measure the average performance of another program, by running several tests and trials against it.

A performance testing is designed to measure the performance and responsiveness of a computer system (not a program) under a heavy workload.

8 0
3 years ago
Other questions:
  • Why is timbre an important musical element?
    7·2 answers
  • is a specific system for gathering information from a single group of respondents by continuously monitoring the advertising, pr
    13·1 answer
  • Which of the following variable declarations is a correct assignment?
    14·1 answer
  • Explain the role of the domain name system
    15·1 answer
  • Assume that a variable variable, number Of Sides has been initialized. Write a statement that assigns the value True to the vari
    8·1 answer
  • Using the employment websites, search for part-time jobs that relate to the career fields you are interested in pursuing or to y
    12·2 answers
  • 50 POINTS!!!
    14·1 answer
  • Ano ang ibig sabihin ng tanka<br>​
    5·1 answer
  • You are interested in buying a laptop computer. Your list of considerations include the computer's speed in processing data, its
    11·1 answer
  • How are keyboards applied in the real world
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!