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
Text that is heavier or darker than other text in the document is considered _____.
kvv77 [185]

The text that is heavier or darker than other text in a document is considered  Bold.

Hope this helped!~

7 0
3 years ago
Read 2 more answers
What would a match() property that passed the expression /^[0-9]/ check for?
lord [1]

Answer:

E

Explanation:

I took the test

7 0
2 years ago
Read 2 more answers
A computer has a pipeline with four stages. each stage takes the same time to do its work, namely, 1 nsec. how many instructions
prisoha [69]

In figuring, a pipeline, otherwise called an information pipeline, is a lot of information preparing components associated in arrangement

Further explanation:

In figuring, a pipeline, otherwise called an information pipeline, is a lot of information preparing components associated in arrangement, where the yield of one component is the contribution of the following one. The components of a pipeline are frequently executed in parallel or in time-cut style.

Instruction travelling:

999,999,997 guidelines for each second. The pipeline has 3 nsec of straightforward figurings, at that point finishes a guidance in each ensuing nsec.  

3nsec (for first guidance to go down the pipeline).10^9 ns every second. 10^9 – 3 = 999999997 directions.

Instruction per second:

MIPS - Million guidelines for each second  

Million guidelines for each second (MIPS) is a more established, outdated proportion of a PC's speed and power, MIPS measures generally the quantity of machine directions that a PC can execute in one second.

Per second:

Million directions for each second (MIPS) is a more established, old proportion of a PC's speed and power, MIPS measures generally the quantity of machine guidelines that a PC can execute in one second. Be that as it may, various directions require pretty much time than others, and there is no standard strategy for estimating MIPS. Moreover, MIPS alludes just to the CPU speed, while genuine applications are commonly constrained by different elements, for example, I/O speed

Answer Details:

Subject: Computer and technology

Level: College.

Key Words:

Further explanation:

Per second:

Instruction per second:

Instruction travelling:

For further Evaluation:

brainly.com/question/6362387

brainly.com/question/12938965

6 0
3 years ago
Read 2 more answers
_______________ provides options for getting access to your old password or resetting the account to a temporary password; users
gtnhenbr [62]

Answer:

account recovery

Explanation:

account recovery, provides options for getting access to your old password or resetting the account to a temporary password; users will change to a permanent password upon first login.

3 0
2 years ago
program that initialises a vector with the following string values: “what” “book” “is” “that” “you” “are” “reading”.
Zanzabum

A program that initializes a vector with the following string values: “what” “book” “is” “that” “you” “are” “reading” are the usage of namespace std;int main().

<h3>What is a vector software program?</h3>

Vector images software program permits customers to layout and manages pc photos the usage of geometric and mathematical commands, instead of clicks and strokes as utilized in drawing software program. Vector photos created the usage of those applications may be scaled indefinitely with out dropping quality.

  1. #include
  2. #include
  3. #include
  4. the usage of namespace std;
  5. int main()
  6. ;
  7. vector::iterator it;
  8. for (it = vs.begin(); it != vs.end(); it++)
  9. string tmp;
  10. while (cin.get()!='n')
  11. for (it = vs.begin(); it != vs.end(); it++)
  12. }

Read more about the vector :

brainly.com/question/25705666

#SPJ1

3 0
1 year ago
Other questions:
  • Given the int variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another int variable m
    13·1 answer
  • Which key must you press after you write into a cell?
    12·1 answer
  • If you see ________________________ in a cell, it means the column is not wide enough to display the cell content. Select one: a
    15·1 answer
  • Which term refers to a type of an attack in which an attacker makes his data look like it is coming from a different source addr
    10·1 answer
  • The theory of logic set the foundation for what aspect of computing today?
    11·1 answer
  • The concept of "plug and play" is demonstrated by which of the following<br> scenarios?
    13·1 answer
  • Where are methods listed in a UML class diagram showing three parts?
    8·1 answer
  • Test unit 8 edhesive answers ​
    15·1 answer
  • Which are print settings that can be modified in word 2019 choose two answers​
    8·1 answer
  • 1. How is the pronoun their used in the second sentence?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!