Octave, GNU Octave, Matlab, Scientific Computing, Language, Interpreter, Compiler, C++, LAPACK, Fortran, Fun , GNU

Monday, May 28, 2007

Octave is fun!

Just struck me, how much fun these guys have, creating and maintaining a
scientific computation platform.

A peek into a recent message on the Octave mailing list.


Paul Kienzle
to Red, help-octave

show details
7:50 pm (1½ hours ago)

On May 28, 2007, at 7:16 PM, Red Crow wrote:

> Hello:
>
> Anybody knows how normalize a distribution, to make mean=0
> and sd=0.

Easy --- replace every value with 0. 8-)

I suspect you want mean=0, sd=1. The function to
do that is zscore(), which subtracts the mean from every
data point and divides by the standard deviation.

- Paul


Do we have fun? You betcha.
-Muthu

Friday, May 18, 2007

Missing Link: Profiling-AST for Octave

The Octave profiler was developed to provide
  1. Flat-profiler with average function performance.
  2. Profile anonymous and complete functions.
  3. Call-Graph profiler to show caller-callee statistics.


I have implemented a rudimentary "flat-profiler" that can just give
statistics of the cpu-time of the functions (only), self & total average
runtimes, and frequency of call to each function.

This code is a C++ rewrite of the Ruby's flat-profiler from
$(Ruby-Install-Path)/lib/profiler.rb authored by 'Matz' (Yukihiro
Matsumoto).

Sample output of profile command testcase 'testprofile.m' (attached)
looks like:

% cumulative self self total
time seconds seconds calls ms/call ms/call name
2.41 0.00 0.00 4 0.06 0.06 anonymous1
2.57 0.00 0.00 4 0.06 0.06 anonymous2
0.00 0.00 0.00 1 0.00 9.71 #toplevel
ans = info


I have also added some elementary support for 'event-based' profiler ,
from the Octave side, that notifies the routines for 'calls', and
'returns' from functions. Exception handling is not implemented.
The API support touches the 4 files mentioned in the previous post.

>From this point, a simple call-graph profiler can also be implemented
with the present infrastructure. The python profiler ('import profiler')
does something like this, and serves as a good template.

[Profiler API Support]
Many design decisions remain to be made, which I must leave it to better
experienced. I would personally prefer a 'event-based' profiler API like
the JAVA's JVMPI (JVM Profiler Interface) which lets people build/use a
sophisticated or simple profiler based on the application.
Please see JVM-PI design at
http://java.sun.com/j2se/1.4.2/docs/guide/jvmpi/jvmpi.html.


There are following good points about the code,

1. It recognizes anonymous functions
2. Does CPU times with least overhead.
3. Can write a basic call-graph profiler
4. Works in rudimentary Matlab syntax

Caveats of the present code,

0. Cannot lookinto execution times of specific lines-of-code
1. Not Matlab compatible
2. Cannot handle exceptions in profiler gracefully.
3. Regular caveats of a flat-profiler in not knowing context
of the function calls; (call-graph based profilers help here,
sort-of)
4. No event filtering
5. Sub-Optimal API design

For compatibility with Matlab, it suffices to provide an API to reach
the level of a event-based, call-graph profiler with access to
individual lines.

I am posting the diffs against the files, and the 2 new files for
octave/src/profile.cc & octave/src/profile.h

Please comment.

Thanks,

-Muthiah


You can look at the whole thread here.

What remains to be done is to write the hooks of the profiler
function into a separate AST walker in the Octave interpreter,
and make the evaluation-AST changeable at runtime using
the profile() function, when it is set. This AST type evaluation
is required, as there will be a performance hit of about 2x compared to the non-profiling interpreter.

Making a AST type evaluator with the hooks for the interpreter
is a non-trivial task; but that involves working on making the event hook mechanism delivery on function-call and return events. This however, does not affect the design of the profiler itself. So this is the missing-link in the profiler game.

Once the profiling infrastructure is in place using the separate AST, then we can profile fine-grained events including

  1. Source code line , enter-leave events,
  2. Variable watch/change events,
  3. Regular function-call return events, and
  4. Exceptions or Non-local exits.

This profiling-event-generator AST we need to put in place for the people to write profilers of their choice. I have provided a Flat and Call-Graph AST's. You can also contribute your mite!

Cheers,
Muthu

Tuesday, May 15, 2007

fucnrdthsucngtagdjb !!!

The following is an email from John Eaton, principal author explaining a 'curious' variable name in Octave manual. LOL.
Cheers,
Muthu


Message: 4
Date: Mon, 14 May 2007 21:17:03 -0400
From: "John W. Eaton" <jwe@bevo.che.wisc.edu>
Subject: LOL
To: S?ren Hauberg <soren@hauberg.org>
Cc: octave bug mailing list <bug@octave.org>
Message-ID: <17993.2575.632481.664491@segfault.lan>
Content-Type: text/plain; charset=iso-8859-1

On 15-May-2007, S?ren Hauberg wrote:

| I just saw the following in vars.txi
|
| @cindex job hunting
| @cindex getting a good job
| @cindex flying high and fast
|
| I have no idea why these lines are there, but it sure is funny. I'm not
| attaching a patch to remove them since I find them quite amusing. I'm
| just curious, if there's a story behind these lines?

The example that follows has the (valid) variable name

fucnrdthsucngtagdjb

It's an old joke.

jwe

Creative Commons License