フィルターのクリア

How to calculate number of clock cycles utilized in MATLAB?

4 ビュー (過去 30 日間)
krishna sravani
krishna sravani 2016 年 12 月 8 日
コメント済み: Walter Roberson 2017 年 3 月 21 日
I want to know the power consumption of any image compression technique. For the reason I want to know how to calculate number of clock cycles used. Which means performance in clock cycles.
  2 件のコメント
Debayan
Debayan 2017 年 3 月 21 日
Hi Krishna, Were you able to calculate the number of cycles in matlab?
Thanks, Debayan
Walter Roberson
Walter Roberson 2017 年 3 月 21 日

サインインしてコメントする。

採用された回答

Jan
Jan 2016 年 12 月 9 日
編集済み: Jan 2016 年 12 月 9 日
You cannot count the processor cycles on modern architectures reliably anymore. The commands are pipelined inside the processor which can process several instruction simulataneously. The processor sometimes idles while it waits for data from the slow RAM or even slower harddisk. Sometimes threads are moved between cores, which takes some time also, but allows for a higher clock rate due to the reduction of the maximum temperature over all cores. If the processor runs faster in turbo mode or throttle down at overheating the total runtime of the program is affected.
So how would you define "the number of clock cycles" uniquely? What if the number of cycles is higher, but the runtime is smaller because the internal processor caches are used more efficiently? Is a code better, which uses less "cycles", but does not let the CPU run in turbo mode? What about parallelization? Is the overhead fpr distributing the work to multiple cores a disadvantage, because it increases the total number of instructions? Or do you count the "cycles" over all cores (which can run with different frequencies...)?
Even a single tic toc measurement is not reliable, because other threads have an influence on the required times for a program. A program with a high disk usage will suffer from a diligent virus scanner, if the user forgot to include Matlab in the list of excluded programs.
Counting cycles has been useful in the 90th in the times of single core processors with a fixed frequency, with tiny caches and single-threaded operating systems. Today it matters, if a multi-threaded algorithm avoids to write data to the same cacheline of 64 bytes. You cannot count this in ticks, but the code might run slower than on a single core.
After the "clock cycles" are known as a weak measurement of the performance, the power consumption is even worse: It depends on the temperature of the CPU and the efficiency of the power-supply and cooling system.
  2 件のコメント
krishna sravani
krishna sravani 2016 年 12 月 9 日
Then How can I know the power consumed by any image compression technique written in MATLAB without knowing number of clock cycles utilized by Matlab code?

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 12 月 8 日
You cannot really calculate that except in the case where you are using Simulink and generating VHDL (or possibly FPGA could be handled.)
  2 件のコメント
krishna sravani
krishna sravani 2016 年 12 月 9 日
If we use tic and toc ,then it is displaying elapsed time..Is there any way(predefined functions) to get number of cycles utilized by matlab code.
Walter Roberson
Walter Roberson 2016 年 12 月 9 日
No.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeClocks and Timers についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by