Calculating FLOPS (Floating-point Operations per Seconds)
Asked Answered
T

3

9

How can I calculate FLOPS of my application? If I have the total number of executed instructions, I can divide it by the execution time. But, how to count the number of executed instructions?

My question is general and answer for any language is highly appreciated. But I am looking to find a solution for my application which is developed by C/C++ and CUDA.

I do not know whether the tags are proper, please correct me if I am wrong.

Terris answered 30/9, 2012 at 9:2 Comment(3)
possible duplicate of How to calculate Gflops of a kernelOutwardbound
I am aware of that question! My question is general. How to calculate FLOPS? Even multi-core. The answer may help my case 'CUDA' too.Terris
I posted on how NVIDIA tools can be used to gather FLOPs in Calculating Achieved Bandwidth and FLOPS .... For x86 there are several Linux libraries for calculating FLOPs. The x86 performance monitor supports counting FLOPs but you would have to read the manual to understand the specifics (speculative instructions, what is counted, ...)Lenlena
A
8

What I do if the number of floating point operations is not easily modeled is to produce two executables: One that is the production version and gives me the execution time, and an instrumented one that counts all floating point operations while performing them (surely that will be slow, but that doesn't matter for our purpose). Then I can compute the FLOP/s value by dividing the number of floating point ops from the second executable by the time from the first one.

This could probably even be automated, but I haven't had a need for this so far.

Antiquate answered 30/9, 2012 at 23:59 Comment(0)
A
9

You should mathematically model what's done with your data. Isolate one loop iteration. Then count all simple floating-point additions, multiplications, divisions, etc. For example, y = x * 2 * (y + z*w) is 4 floating-point operations. Multiply the resulting number by the number of iterations. The result will be the number of instructions you're searching for.

Anjanette answered 30/9, 2012 at 10:9 Comment(2)
Good for coherent control-flow and deterministic branches. It is not applicable in the code with input-dependent conditional branches (dynamic run-time determines how many FP are performed).Terris
do you ignore conditional statements like if (i<n)Wellintentioned
A
8

What I do if the number of floating point operations is not easily modeled is to produce two executables: One that is the production version and gives me the execution time, and an instrumented one that counts all floating point operations while performing them (surely that will be slow, but that doesn't matter for our purpose). Then I can compute the FLOP/s value by dividing the number of floating point ops from the second executable by the time from the first one.

This could probably even be automated, but I haven't had a need for this so far.

Antiquate answered 30/9, 2012 at 23:59 Comment(0)
B
0

FLOPS = Chip Operating freq. (MHz)x Number of Core x FP

GFLOPS = FLOPS/1GHz

Bedroom answered 15/1 at 12:37 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Thera

© 2022 - 2024 — McMap. All rights reserved.