Question: Calculating MFLOPS Calculating MFLOPS ( Million Floating Point Operations Per Second ) directly on an Arduino can be challenging due to its limited computational capabilities

Calculating MFLOPS
Calculating MFLOPS (Million Floating Point Operations Per Second) directly on an Arduino can be
challenging due to its limited computational capabilities and lack of native floating-point hardware
support. However, we can approximate MFLOPS by performing a large number of floating-point
operations and measuring the time it takes to execute them.
By dividing the total number of floating-point operations by the execution time (in seconds), we can
obtain an approximation of MFLOPS.
#define NUM_OPERATIONS 1000// Number of floating-point operations to perform
#define NUM_ITERATIONS 100// Number of iterations to measure execution time
void setup(){
Serial.begin(9600);
}
void loop(){
unsigned long startTime, endTime;
float result =0;
startTime = micros();
// Perform floating-point operations
for (int i =0; i < NUM_ITERATIONS; i++){
for (int j =0; j < NUM_OPERATIONS; j++){
// Perform a simple floating-point operation (e.g., addition)
result +=1.123456*2.0;
}
}
endTime = micros();
/ Calculate execution time in seconds
float executionTimeSec =(endTime - startTime)/1000000.0;
// Calculate MFLOPS
float mflops =(NUM_OPERATIONS * NUM_ITERATIONS)/(executionTimeSec *1000000.0);
// Print results
Serial.print("Execution Time (seconds): ");
Serial.println(executionTimeSec,6);
Serial.print("MFLOPS: ");
Serial.println(mflops,2);
delay(1000); // Delay before next iteration
}
Questions:
1. What is the approximation of MFLOPS measured on your Arduino?
2. The actual MFLOPS value obtained from this program may vary. List at least 2 reasons why the
results may vary?

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 Accounting Questions!