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
PLEASE HELP I WILL REWARD YOU
xxMikexx [17]
What what what what what what
5 0
3 years ago
Francis has applied for admission to a computer science program, and one of the requirements for admission is the completion of
Nataly_w [17]

Answer:

an aptitude test.

Explanation:

Based on the scenario being described it can be said that the test that Francis is scheduled to take would be classified as an aptitude test. This is a test that tries to determine an individual's innate ability at a particular competency. These are abilities such as sequencing skills and abstract reasoning skills, and are the results of these tests are used in order to see where a candidate can best be placed within a program/company to best perform.

8 0
3 years ago
Read 2 more answers
What does a computer use long-term memory, or ROM, for?
AysviL [449]
The answer is B

Explanation: In contrast, a computer's hard disk or SDD is its long-term memory, where things are stored more or less permanently. ... Nearly all computers also have some way to store information for longer-term access, too.

5 0
2 years ago
In your own words, what does Hypertext Markup Language [HTML] do?
nexus9112 [7]

Answer:

HTML dictates how the browser presents images and text on a webpage.

Explanation:

3 0
3 years ago
Read 2 more answers
Keyword stuffing is considered to be a black hat technique for SEO and is highly suggested today by Google.
klemol [59]

Answer:

False

Explanation:

Keyword stuffing is a practice to insert an unusual large number of tag in a website to increase the page ranking in search results. This is considered an unethical Search Engine Optimization (SEO).

Google consider Keyword stuffing as unethical and it doesn't help to boost the rank of a website. More advanced algorithms are being used to filter those of the meta tags which are irrelevant or excessively out of context in a website.

3 0
3 years ago
Other questions:
  • When you save a drawing using paint, it's automatically stored as a?
    15·1 answer
  • What weight pencil is recommended for darkening lines and for lettering? *
    7·2 answers
  • Which of the following is NOT true about variables?
    13·1 answer
  • Consider a network of 8 routers connected together to provide more than one path of connectivity between host A and host B at tw
    8·1 answer
  • How does an individual's access to a wide range of online services affects their ability to operate safely in the digital world.
    5·1 answer
  • Which elements are visible when a user opens a new PowerPoint presentation?
    7·2 answers
  • Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
    9·1 answer
  • A common hardware component found in electronic devices including desktop computers, laptops, tablets and smartphones. The amoun
    5·1 answer
  • Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged par
    14·1 answer
  • Which type of measurement would you use to determine the mass of sugar?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!