Question: C Programming question. Here is the code that I have: #include #include #include #include #define NNN 2048 void copyij(); void copyji(); void init_mat(); int64_t time_diff();

C Programming question.

Here is the code that I have:

#include #include #include #include #define NNN 2048 void copyij(); void copyji(); void init_mat(); int64_t time_diff(); int src[NNN][NNN], dst[NNN][NNN]; int main(int argc,char **argv) { int i,j,n; long int del_sec,del_msec; struct timeval tv_s,tv_e; init_mat(); gettimeofday(&tv_s, NULL); copyij(); gettimeofday(&tv_e, NULL); /* fill here to compute elapsed time */ printf("copyji(): dim=%d: elapsed=%ld.%ld secs ",NNN,del_sec,del_msec/1000); init_mat(); gettimeofday(&tv_s, NULL); copyji(); gettimeofday(&tv_e, NULL); /* fill here to compute elapsed time */ printf("copyji(): dim=%d: elapsed=%ld.%ld secs ",NNN,del_sec,del_msec/1000); return 0; } void copyij(){ int i,j; for (i = 0; i < NNN; i++) for (j = 0; j < NNN; j++) dst[i][j] = src[i][j]; } void copyji(){ int i,j; for (j = 0; j < NNN; j++) for (i = 0; i < NNN; i++) dst[i][j] = src[i][j]; } void init_mat(){ int i,j; for (i=0;i 
 for (j=0;j 

I am unsure how to compute the elapsed time where it says to "fill here to compute elapsed time"

the output is supposed to be something like this:

copyij(): dim=2048: elapsed=0.13 secs copyji(): dim=2048: elapsed=0.97 secs 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!