Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago