Productivity

June 16th, 2009

I did two things today to help me be more productive.

1. I read out loud some writing I’ve been doing. As a result I found that some things I assumed to be awful, sounded pretty good. Other things that I though were good needed a lot of work.
2. I’m keeping track of my time minute by minute. I’ve wasted quite a bit of time today, but keeping track forces me to be accountable and helps get me back on trask.
I’m waiting for a build right now so I thought I’d take a couple of minutes to write a short blog post.

Yes its been a while.

malloc(sizeof(struct mything *))

November 18th, 2008

malloc(sizeof(struct mything *)).

Cut and paste error.

That little star after mything can be dangerous when your are trying to allocate a mything and not a pointer to a mything. It gets worse when mything has a child that you subsequently allocate and zero out.
By zeroing out the allocated child you zero out the parents pointer to the child because sizeof(struct mything*) is only 4 bytes on a 32 bit platform. so the child gets allocated at the next malloc allocation chunk, which is usually <= 16 bytes, after the 4 bytes. Zaaamooo, you’ve nulled the parent pointer to the child that you know you’ve allocated.

Gotta Love C’s memory model.
A million and one ways to shoot yourself in the foot.

Batch Conversion of Visual Studio 2005 Solutions to Visual Studio 2008 Solutions

October 20th, 2008

I do a lot of cross platform portable work.
That means I have to work on WIN32 with WIN32 programmers.

There are a lot of things about visual studio that are warm and fuzzy. Having to go through the solution/project conversion wizard for each solution in a large multi-solution projects isn’t one of them.

Batch Conversion of Visual Studio 2005 Solutions to Visual Studio 2008 Solutions

I now have a perl script that runs devenv /Upgrade SOLUTION.sln for me over a large code base.

I knew /Upgrade had to exist, I finally found it this morning

Deliberately Do Things Wrong When Learning a New Language

October 6th, 2008

I read Is learning Perl the hard way the easy way? recently.

Andy Lester links to Learning Perl the Hard Way.

Reading the PDF, Allen B. Downey makes a great suggestion when learning new languages.
He says, “As you are experimenting with a new language, I suggest that you make deliberate errors in order to get familiar
with the most common error messages
.”

That is some of the simplest, best advice I’ve heard in a while.

Not seeing the code right in front of your eyes

July 24th, 2008

I’m in the process of making PLT Scheme multiprocessor/multi os thread aware.
Everyone knows that globals are the arch enemy of multiprocessor code. Needless to say, PLT Scheme has plenty of globals from is origin as a single processor/single os thread app.

One such global is called kernel_modidx ( the plt scheme kernel module index )
There is some init code that sets these globals.


REGISTER_SO(kernel_symbol);
REGISTER_SO(kernel_modname);
REGISTER_SO(kernel_modidx);
kernel_symbol = scheme_intern_symbol("#%kernel");
kernel_modname = scheme_intern_resolved_module_path(kernel_symbol);
kernel_modidx = scheme_make_modidx(scheme_make_pair(quote_symbol, scheme_make_pair(kernel_symbol, scheme_null)), scheme_false, kernel_modname);

As you can see kernel_modname includes the kernel_symbol, kernel_modidx includes the kernel_symbol and the kernel_modname. This is very important for things to work later.

You would think that calling this init code twice would work the same way the second time as it did the first. It took me two days to hunt down why it doesn’t.

Taking a look at scheme_make_modidx you will see the special case that if kernel_modidx is defined that scheme_make_modidx will not make a new modidx, but will return the old one.

Its not that obfuscated, I just missed it the first thousand times I stepped through the code.


Scheme_Object *scheme_make_modidx(Scheme_Object *path,
Scheme_Object *base_modidx,
Scheme_Object *resolved)
{
Scheme_Modidx *modidx;

if (SCHEME_MODNAMEP(path))
return path;

if (SCHEME_PAIRP(path)
&& SAME_OBJ(SCHEME_CAR(path), quote_symbol)
&& SCHEME_PAIRP(SCHEME_CDR(path))
&& SAME_OBJ(SCHEME_CADR(path), kernel_symbol)
&& SCHEME_NULLP(SCHEME_CDR(SCHEME_CDR(path)))
&& kernel_modidx)
return kernel_modidx;

My Hourly Earthquakes

May 19th, 2008

I live close to the University of Utah.

Life Flight and AirMed helicopters pass over my apartment complex all day long ferrying people to and from the several hospitals that are part of the University Medical Complex. They often pass low enough that they literally shake the apartment. I can feel the shaking, especially when I’m lying down in bed. It must be the air pressure generated by the rotors.

There is also a large construction project next door that has a bulldozer that constantly pushes dirt around. When the dozer is hard at work the apartment building likewise shakes. I’ve experienced real earthquakes in California and Chile. My current environment feels like one never ending earthquake.

Apt-get make it easy

March 25th, 2008

Had this latex error this morning.


(/usr/share/texmf-texlive/tex/latex/base/ts1cmr.fd)kpathsea: Running mktextfm tcrm1095
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input tcrm1095
This is METAFONT, Version 2.71828 (Web2C 7.5.6)

kpathsea: Running mktexmf tcrm1095
! I can't find file `tcrm1095'.
<*> ...ljfour; mag:=1; nonstopmode; input tcrm1095

Please type another input file name
! Emergency stop.
<*> ...ljfour; mag:=1; nonstopmode; input tcrm1095

Transcript written on mfput.log.
grep: tcrm1095.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input tcrm1095' failed to make tcrm1095.tfm.
kpathsea: Appending font creation commands to missfont.log.

! Font TS1/cmr/m/n/10.95=tcrm1095 at 10.95pt not loadable: Metric (TFM) file no
t found.

relax
l.76 \item {
\bf (Important)} Read Chapters 15-17 over the break. I will lect…

apt-get install cm-super fixed it.

You gotta love debian(ubuntu).

Organick Memorial Lecture 2008: Fran Allen Turing Award Winner

February 21st, 2008

Organick Lecture 2008
High Performance Programs and Programmers: A Personal Perspective
Fran Allen

IBM Fellow Emerita
IBM T. J. Watson Research Center

University of Utah School of Computing
Wednesday, February 20, 2008 7:30 p.m.
Turing Award Winner

Fran calls supercomputers one of the miracles of our time.

“In the beginning there was Fortran.” Jim Gray

Fran’s first assignment was to teach the scientist of IBM Research Fortran which had just been released.
Up till then the scientists had written their code by hand in assembly.

John Backus set goals, stuck with them, and achieved them.

Fortran had two objectives:
Increase the productivity of programmers.
Be almost as efficient and hand crafted code.

Fran’s next project was the IBM Stretch 1956-1961
Fred Brooks
The stretch was announced to be 100x faster than any existing machine
Memory Access Time was the main performance limitation
The stretch had up to 6 overlapping storage references at one time.
Had up to 11 instructions in flight at a time in the processor.
The stretch was built for solving engineering and scientific problems

HARVEST
built for the NSA, delivered in 1962
Used for code breaking.
The HARVEST was a streaming data computation model.
It had eight instructions.
IO, memory, and computational where all balanced and synced to a clock.
Only machine that maintained this balanced.
The machines language ALPHA was designed for the NSA problem and the machine.

The stretch, when deliver to Los Alamos, missed its performance target by 50%.
The stretch was an attempt to do what was beyond the capabilities of the people and the technology of the time.
The stretch had huge influence on IBM future systems, particularly the IBM 360.
We don’t take risks developing new systems like we use too. The strech was taking a risk and eventually winning because of it.

The IBM 360 unified the business and scientific product roles.
This was a goal, particularly a unified instruction set, was set by Fred Brooks.
There were competitions of competing ideas to find the best solutions.

John Cocke was a engineer who “never wrote a “paper” or “gave a talk”".
John Cocke build the most difficult part of the machine, the look ahead.
John Cocke was in charge of the ACS project that was eventually cancelled in 1968.

The ACS compiler did many pioneering things in the area of compilers.

John Cocke decided to stop trying to create the worlds fastest computer, (the ACS machine), and decided to create the best performance/cost machine which resulted in the Power PC.

Ideas in our field come from problems.

Good an useful results come from problems that result from building something.

It takes twenty years from the appearance of a problem to it being totally solved in a product.

The new thing will be simpler, slower, cooler multicore processors.

The real challenge is to organize tasks to execute in parallel.
How do we use these multicores and get performance out of them?
Fran says we are not ready to do parallel yet. Maybe after 20 years we will be ready.

Everyone will have multicores, not just the high end scientific community.

How these cores will be used is a big question for the software and application people.
We now have a parallel hammer, how will we use it?

Parallelism
“The biggest problem Computer Science has ever faced.” John Hennessy
“The best opportunity Computer Science has to improve user productivity, application performance, and system integrity.” Fran Allen

Coming back to Elliot Organick
The things that succeed best are those that have complete clarity about what the problem is and what the solutions are.
Writing things down and engaging communication is the key to success.

Questions:
What have we learned from the transputer.
The CSP work done for the transputer I think is interesting.

Is the problem in conceptualization or in finding a language to describe our conceptualizations?
Tony Hoard wrote a paper called “Toward the understanding of parallel computers”.
John Nash had some ideas about a parallel machine while working for RAND.

Could you expand on your ideas system integrity?
Language integrity could be a second order effect of better languages.

Users still have to know about the raw details of the machine to get great performance.

Parallelism will increase and the hardware will get easier.
The complexity of hardware will move to parallelism in software.

We have a lot of work in front us and it will be interesting to see

You mentioned that you would like to see caches disappear.
Scratchpad memories may be a better solution than caches.
But being responsible for the memory hierarchy whether you want to or not can be as much a curse as a blessing.

Beating my head with PLT Scheme

February 21st, 2008

I’ve been trying to communicate with a perl process from PLT Scheme using the process library call from scheme/system.

I’ve been a good systems boy making sure that I call flush-output after every string I write to the perl process. But the perl process never gets any input unless I close the output side of the pipe connected to perl’s stdin filehandle.

After hours of no progress I found this

http://pre.plt-scheme.org/plt/doc/release-notes/mzscheme/MzScheme_300.txt

* File-stream output ports (including file ports, the initial output
port, and ports created by `subprocess’) are now block-buffered by
default, instead of line-buffered. The exception is when an output
port corresponds to a terminal, in which case it is line-buffered
by default. Also, the initial error port remains unbuffered.

TCP output ports are block buffered (instead of unbuffered) by
default.

The file-stream changes are especially likely to affect stdio-based
communication among OS-level processes. For example, when
communicating with an ispell subprocess, adding a newline at the
end of a command previously would have been enough to send the
command to ispell. Now, the output must be flushed explicitly
(using `flush-output’) or the buffer mode must be explicitly
changed to by-line (using `file-stream-buffer-mode’).

The TCP changes affect most TCP-based communication. Explicitly
flush output using `flush-output’ or change the buffer mode using
`file-stream-buffer-mode’.

So I said what the heck, I’ll just add a (file-stream-buffer-mode outp ‘line)
call for grins.

And it started working.

Hardy Heron Rocks, but…

February 19th, 2008

Yes, I’m a alpha geek and and early adopter.

Hardy Heron is working great, but the Firefox 3.0 packaging is still undergoing some revision.
I use three applications extensively, Firefox, Thunderbird, and Konsole.
I can’t deal with the extra large fonts that display by default in Firefox 3.0 in Hardy Heron.
So I used this set of instructions to temporarily downgrade the firefox package.

http://www.nowhere.dk/archives/2008/02/14/firefox_3_0_is_now_the_default_browser_in_ubuntu/index.php