I have some rather complex and highly templated code (C++, but this may not be very relevant) of which I'd like to know the number of adds, subs, muls, divs, and sqrts at execution. Is there an automatic way to get this information (the compiler could work it out easily)? I tried to count it myself in the assembler code generated, but got confused with jp, jmp, and calls.
Automatic way to obtain the floating-point operation count for some piece of code
1k views Asked by Walter At
2
There are 2 answers
2
user2760751
On
Yes you can, but the way is a bit complex:
Try to change your "add", "sub", "mul", "div", "sqrt" in the binary to some invalid opcode. Dont forget to define an invalid opcode error handler to restore the opcode. When you program runs, the cpu will trigger the invalid opcode error at those changed "add", "sub", "mul", "div", "sqrt". By counting the times invalid opcode error being triggered, you can get the exactly what you want.
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in METRICS
- Difference between model.evaluate and metrics.accuracy_score
- Dashboard to pull data from different databases and data sources
- How to enable dotnet metric collection
- higher coefficient of determination values in the testing phase compared to the training phase
- Open telemetry integration in java
- How can I collect metrics from a Node.js application running in a Kubernetes cluster to monitor HTTP requests with status codes 5xx or 4xx?
- Spring boot 3 monitoring (observation, metrics)
- Filter input metrics in vmagent (prometheus)
- PrestaShop metrics definition
- Calculating NRI and IDI using a library-Reclassification
- How do I make the column for the metric choosable via a filter in apache superset?
- Rename metrics in Dropwizard MetricsRegistry in a Spring Boot application
- How to see order of distributed events in local Node.js dockerised microservice set up?
- differently structured data combined in superset metrics
- collectd write_http plugin failure
Related Questions in CODE-METRICS
- Can not connect dotnet metrics to docker prometheus container
- How can I store data throughout multiple builds in a continuous integration pipeline?
- Gitlab-CI: Python radon output to Open Metrics format
- How to count generated lines of code in Visual Studio?
- Non-cyclic remark paths in HIS Metrics
- How do I track daily code metrics on Visual Studio Code?
- What is 'Assignment Branch Condition Size too high' and how to fix it?
- Git: How do I calculate the number of times a line has changed?
- VS Code on Mac stopped showing dart code metrics messages in problem panel
- Rubocop complains about Metrics/AbcSize
- How to calculate code metrics in Visual Studio Code?
- Github repository statistics: Historical data on total contributors for each month for the past x months/years?
- How to extract different metrics from source code in Enterprise Architect
- Calculate code metrics as part of build pipeline in Devops
- Guidelines for permissible maximum linearly-independent cyclomatic complexity?
Related Questions in FLOPS
- Achieving More FMA3 Performance Than The Theoretical Maximum
- The Intel MKL LINPACK test indicates too big performance
- Which instructions are included in the hardware event `INST_SIMD_ALU`?
- I want to measure FLOPs! I want to measure the amount of computation of the call function set to @tf.funcion, what should I do
- find number of MAC operations in python
- How to compute the model complexity of FasterRCNNFPN pretrained from torchvision?
- How to calculate the FLOPS of a Python program?
- Counting FLOPS in tensorflow
- calculate flops in a custom pytorch model
- calculate program execution time in embedded device from python code
- why is Rpeak different from Rmax when measuring performance?
- Why do I get higher Whetstone FLOPS from SiSoft Sandra when I disable extensions (SSE, AVX, FMA)?
- Is it possible that the inference time is large while number of parameters and flops are low in pytorch?
- Difficulty understanding FLOPS in this scenario
- TensorFlow Object Detection API - determining FLOPS and number of Parameters
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I would suggest to override
+,-,*,/operators andsqrtfunction for some float-like type, in which you can count their use.Something like this: