Home > Archive > Matlab > January 2008 > Count the operations of an algorithm ... help !
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Count the operations of an algorithm ... help !
|
|
| grandfather 2008-01-23, 7:54 pm |
| hello community ;)
I would like to count the code operations take place during the code running.
Where "operations" I mean summations, subtractions, multiplications ect ...,
Due to large arrays and many many operations
I was wondering if there is any way to count all the operations automatically ...?
thanks again
| |
| Walter Roberson 2008-01-23, 7:54 pm |
| In article <20323967.1201104382249.JavaMail.jakarta@nitrogen.mathforum.org>,
grandfather <dimpallas@gmail.com> wrote:
>I would like to count the code operations take place during the code running.
>Where "operations" I mean summations, subtractions, multiplications ect ...,
>Due to large arrays and many many operations
>I was wondering if there is any way to count all the operations automatically ...?
No, there isn't.
But what would you do with the information if you had it?
The number of operations only has a loose connection to the running
time of the code. Caching, vectorization, multiprocessing,
just-in-time compiling, CPU pipelining, etc., can have very
dramatic effects on real code timing.
--
"I will speculate that [...] applications [...] could actually see a
performance boost for most users by going dual-core [...] because it
is running the adware and spyware that [...] are otherwise slowing
down the single CPU that user has today" -- Herb Sutter
| |
| Jason Brown 2008-01-23, 7:54 pm |
| I would take a look at the built in code profiler. It tracks
the amount of time spent on each line of code that you are
running in order to find bottlenecks...I do image processing
work with large multi-image tif files and it has come in handy.
-Jason
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fn7qr6$o0n$1@canopus.cc.umanitoba.ca>...
> In article
<20323967.1201104382249.JavaMail.jakarta@nitrogen.mathforum.org>,
> grandfather <dimpallas@gmail.com> wrote:
>
during the code running.[color=darkred]
multiplications ect ...,[color=darkred]
operations automatically ...?[color=darkred]
>
> No, there isn't.
>
> But what would you do with the information if you had it?
> The number of operations only has a loose connection to
the running
> time of the code. Caching, vectorization, multiprocessing,
> just-in-time compiling, CPU pipelining, etc., can have very
> dramatic effects on real code timing.
> --
> "I will speculate that [...] applications [...] could
actually see a
> performance boost for most users by going dual-core
[...] because it
> is running the adware and spyware that [...] are
otherwise slowing
> down the single CPU that user has today" --
Herb Sutter
| |
| Walter Roberson 2008-01-23, 7:54 pm |
| In article <fn7rfa$d9u$1@fred.mathworks.com>,
Jason Brown <jeb8828@rit.edu> top-posted:
Please do not post your reply at the top of what you are replying
to: it makes it more difficult to hold a conversation.
><20323967.1201104382249.JavaMail.jakarta@nitrogen.mathforum.org>,
[color=darkred]
>during the code running.
>multiplications ect ...,
>I would take a look at the built in code profiler. It tracks
>the amount of time spent on each line of code that you are
>running in order to find bottlenecks...
The code profiler will count the number of calls to sum()
and plus() [for example], but it will not measure how much
work each call did.
sum(1:1000) is counted as one call to sum();
a + b + c + d is counted as three calls to plus();
(1:1000) + (2:2:2000) + (3:3:3000) + (4:4:4000) is counted as three
calls to plus().
--
"All is vanity." -- Ecclesiastes
| |
| grandfather 2008-01-23, 7:54 pm |
| > >I was wondering if there is any way to count all
> the operations automatically ...?
>
> No, there isn't.
>
> But what would you do with the information if you had
> it?
> The number of operations only has a loose connection
> to the running
> time of the code. Caching, vectorization,
> multiprocessing,
> just-in-time compiling, CPU pipelining, etc., can
> have very
> dramatic effects on real code timing.
well, it is supposed the code runs on a processor (real time application).
So, I would like to know how many operations should be able to execute this processor.
I think to make a good choice of the processor somebody have to use,
it should be known the "work" which the processor will carry out.
The operations counting of the algorithm can give a good view of the load
that the processor should be able to carry out,
thanks again
Dim
| |
| Derek O'Connor 2008-01-24, 3:17 am |
| quote: Originally posted by grandfather
hello community ;)
I would like to count the code operations take place during the code running.
Where "operations" I mean summations, subtractions, multiplications ect ...,
Due to large arrays and many many operations
I was wondering if there is any way to count all the operations automatically ...?
thanks again
You could try the Papi software (free) at http://icl.cs.utk.edu/projects/papi/
I have used it on my old W2000, Matlab 7.0 system
but there is nothing yet for my Vista 64 Matlab 7.5 64 bit.
Below is a description from the Papi.m file.
Good luck,
Derek O'Connor
% PAPI Performance API.
% PAPI provides access to one of 8 hardware Performance Monitoring functions.
%
% ctrs = PAPI('num') - Return the number of hardware counters.
% PAPI('start', 'event', ...) -
% Begin counting the specified events.
% [val, ...] = PAPI('stop') - Stop counting and return the current values.
% [val, ...] = PAPI('read') - Read the current values of the active counters.
% [val, ...] = PAPI('accum') - Add the current values of the active counters
% to the input values.
% PAPI('ipc') - Begin counting instructions.
% ins = PAPI('ipc') - Return the number of instructions executed
% since the first call.
% [ins, ipc] = PAPI('ipc') - Return both the total number of instructions
% executed since the first call, and the
% incremental rate of instruction execution
% since the last call.
% PAPI('flips')
% PAPI('flops') - Begin counting floating point
% instructions or operations.
% ins = PAPI('flips')
% ops = PAPI('flops') - Return the number of floating point instruc-
% tions or operations since the first call.
% [ins, mflips] = PAPI('flips')
% [ops, mflops] = PAPI('flops') -
% Return both the number of floating point
% instructions or operations since the first
% call, and the incremental rate of floating
% point execution since since the last call.
%
% DESCRIPTION
% The PAPI function provides access to the PAPI Performance API.
% PAPI takes advantage of the fact that most modern microprocessors
% have built-in hardware support for counting a variety of basic operations
% or events. PAPI uses these counters to track things like instructions
% executed, cycles elapsed, floating point instructions performed and
% a variety of other events.
%
% There are 8 subfunctions within the PAPI call, as described below:
% 'num' - provides information on the number of hardware counters built
% into this platform. The result of this call specifies how many
% events can be counted at once.
% 'start' - programs the counters with the named events and begins
% counting. The names of the events can be found in the PAPI
% documentation. If a named event cannot be found, or cannot
% be mapped, an error message is displayed.
% 'stop' - stops counting and returns the values of the counters in the
% same order as events were specified in the start command.
% 'stop' also can be used to reset the counters for the ipc
% flips and flops subfunctions described below.
% 'read' - return the values of the counters without stopping them.
% 'accum' - adds the values of the counters to the input parameters and
% returns them in the output parameters. Counting is not stopped.
% 'ipc' - returns the total instructions executed since the first call
% to this subfunction, and the rate of execution of instructions
% (as instructions per cycle) since the last call.
% 'flips' - returns the total floating point instructions executed since
% the first call to this subfunction, and the rate of execution
% of floating point instructions (as mega-floating point
% instructions per second, or mflips) since the last call.
% A floating point instruction is defined as whatever this cpu
% naturally counts as floating point instructions.
% 'flops' - identical to 'flips', except it measures floating point
% operations rather than instructions. In many cases these two
% counts may be identical. In some cases 'flops' will be a
% derived value that attempts to reproduce that which is
% traditionally considered a floating point operation. For
% example, a fused multiply-add would be counted as two
% operations, even if it was only a single instruction. |
|
|
|
|