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
Im trying to figure out how to write a program that finds prime factors of a number. I have the following but it only works for
Paladinen [302]
The reason your program isn't working is because you put the n=12 now when you put the other n's in the code it causes it to only work with the number 12
7 0
4 years ago
Where can the greatest depths be found in the ocean?
34kurt

The answer is C: In ocean trenches.

Since the deepest part of the ocean lies in the Mariana Trench.

I hope this answered your question! :D

7 0
3 years ago
A desktop computer is not able to connect to a wireless network (WLAN). What are the step-by-step troubleshooting steps and proc
lara [203]

Answer:

  1. you should first check your hotspot connection and then if your pc is not connected so you can replace an aeroplane mode on your pc.
8 0
3 years ago
Which statements about viruses are true? select the four statements that are true. select the four statements that are true. all
navik [9.2K]
<span>A) All viral genomes contain both DNA and RNA. FALSE. Viruses contain the smallest necessary amount of genetic information packaged in a capsule composed of proteins. Containing both DNA and RNA would be a redundancy that would unnecessarily increase the size of the virus and make it more difficult for the virus to penetrate a cell. B) A retrovirus contains RNA. TRUE. By definition a retrovirus contains single-stranded positive-sense RNA instead of DNA. C) HIV contains two identical strands of DNA. FALSE. HIV is a retrovirus and, therefore, contains RNA instead of DNA. D) HIV contains reverse transcriptase. TRUE. HIV is a retrovirus that contains an RNA genome. All retroviruses require reverse transcriptase to convert their genome from RNA to DNA once the virus has been entered the cell. E) The capsid enters the host cell if the virus is enveloped. TRUE. Viruses are to large to enter a cell by passive diffusion or active transport. The only remaining major form a transport into the cell is endocytosis, or being enveloped. F) All RNA-containing viruses are retroviruses. FALSE. By definition a retrovirus contains single-stranded positive-sense RNA. Viruses can contain RNA in other forms (ie double-stranded) and would, therefore, not be considered a retrovirus. G) Enveloped viruses bud from the host cell. TRUE. Viruses are to large to enter a cell by passive diffusion or active transport. The only remaining major form a transport into the cell is exocytosis. For a virus to exit the host cell and infect other cells, they must exit by exocytosis, or budding.</span>
4 0
3 years ago
The smaller RAM a computer has, the more software you can have open without impacting the speed of your computer
dsp73
False, forsure mates but gotta love the question:)
4 0
3 years ago
Other questions:
  • When you compile your program, the compiler identifies the logic errors and suggests how to correct them?
    14·1 answer
  • What makes Group Policy such a powerful tool is its ability to enable security administrators to:_________.
    8·1 answer
  • List 5 major steps to make a bank deposit
    6·1 answer
  • Microsoft access does not create n:m relationships because microsoft access creates databases based on
    7·1 answer
  • Knowledge management software helps companies preserve the knowledge gained through the use of information so that future users
    15·2 answers
  • Your boss has asked you to create a customized letterhead for the business, "Boyne Mountain Ski Shop". Explain how to create the
    6·1 answer
  • In which area is composing for games similar to composing for
    14·1 answer
  • What does a motherboard legacy BIOS do?
    11·1 answer
  • Is a MODEM required for Internet Connectivity ?<br> Yes<br> No
    9·2 answers
  • In Adobe illustrator cc 2017 which of the following export file ​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!