Question
Convert the following psuedo code to C/C++: double precision, dimension(N) :: A,B,C,D double precision :: S,E,MFLOPS do i=1,N // fill arrays with data A(i) =
Convert the following psuedo code to C/C++:
double precision, dimension(N) :: A,B,C,D
double precision :: S,E,MFLOPS
do i=1,N // fill arrays with data
A(i) = 0.d0;B(i) = 1.d0
C(i) = 2.d0; D(i) = 3.d0
enddo
call get_walltime(S) // get start time
do j=1,R
do i=1,N
A(i) = B(i) + C(i) * D(i) // 3 loads, 1 store
enddo
if(A(2).lt.0) call dummy(A,B,C,D) // prevent loop interchange
enddo
call get_walltime(E) // get end time stamp
MFLOPS = R*N*2.d0/((E-S)*1.d6) // calculate MFLOPS
Use the following routine for get_wall_time()
#include
void get_walltime(double* wcTime) {
struct timeval tp;
gettimeofday(&tp, NULL);
*wcTime = (double)(tp.tv_sec + tp.tv_usec/1000000.0);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started