Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include const int dimension = 2 5 6 ; struct timeval tv; double timestamp ( ) { double t; gettimeofday ( &tv ,

#include
#include
#include
const int dimension =256;
struct timeval tv;
double timestamp()
{
double t;
gettimeofday(&tv, NULL);
t = tv.tv_sec +(tv.tv_usec/1000000.0);
return t;
}
int main(int argc, char *argv[])
{
int i, j, k;
double *A,*B,*C, start, end;
A =(double*)malloc(dimension*dimension*sizeof(double));
B =(double*)malloc(dimension*dimension*sizeof(double));
C =(double*)malloc(dimension*dimension*sizeof(double));
srand(292);
for(i =0; i < dimension; i++)
for(j =0; j < dimension; j++)
{
A[dimension*i+j]=(rand()/(RAND_MAX +1.0));
B[dimension*i+j]=(rand()/(RAND_MAX +1.0));
C[dimension*i+j]=0.0;
}
start = timestamp();
//ijk form
for(i =0; i < dimension; i++)
for(j =0; j < dimension; j++)
for(k =0; k < dimension; k++)
C[dimension*i+j]+= A[dimension*i+k]* B[dimension*k+j];
end = timestamp();
printf("
secs:%f
", end-start);
free(A);
free(B);
free(C);
return 0;
} L1: 320 kb, theoretically calculate the cache hit and miss rates at the L1 level.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Identify several ways to make better decisions about retirement.

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago