Objective: to determine the MFLOPS for floating point addition, subtraction, multiplication and division on two different machines.
I Write a very simple C++ program:
1. Create three float arrays A, B and C with 500000000 elements
2. Call a random number generator to fill up A and B with numbers. There is a function called rand() or srand() in the library cstdlib in C++. There are some examples on the following website
3. Write the code segment that will do C = A + B for all the 500000000 elements and time this segment (see the example below)
4. Write the code segment that will do C = A - B for all the 500000000 elements and time this segment (see the example below)
5. Write the code segment that will do C = A * B for all the 500000000 elements and time this segment (see the example below)
6. Write the code segment that will do C = A / B for all the 500000000 elements and time this segment (see the example below)
7. Print the MFLOPS = (500000000/(time for operation * 106)) for
a. addition (step 3)
b. subtraction (step 4)
c. multiplication (step 5)
d. division (step 6)