Evidently I am a Windows Pirate

May I rant?

I have a Macbook Pro, which I like, well, quite a lot.  When I first got it, I gave it to my wife to run Windows XP, using Boot Camp.  Why? Because I love her more than the Mac.

It turned out that she doesn’t like the trackpad having only one button, so I got it back, and I happily run MacOS.

The copy of Windows XP on the Mac is an OEM copy for computer builders, which I think is fine, since I replaced the hard drive.

Last night I had to run Windows in order to run Turbotax Business, which unaccountably is only available for Windows.  I fired up Vmware Fusion and had it boot the boot camp partition… and Windows refused to run because it had been installed on a different computer.

Um, no, Microsoft, this is NOT a different computer. I added a layer of emulation, but every transistor and wire is identical to before.  I am not sure how this behavior is supposed to benefit Microsoft shareholders.

And yes, by rebooting directly into Windows, it works fine.

Unclear on the concept

I am so mad at myself for forgetting to take a photograph of this.

Earlier this week I spent a few days at the famed Claremont Resort and Spa in Berkeley, California.  I was there for the Hot Topics in Parallelism workshop, but that isn’t the point.

It used to be that in bathrooms, one had a “heat lamp.” This was a dull red PAR type bulb in a ceiling fixture, typically with a twist knob timer.  You turn it on and it runs for 10 minutes or whatever while you take a shower and dry off.

Now I know that California is Eco-Groovy, and Berkeley is about the epicenter of Eco Groovyness, but at the Claremont, they have replaced the bathroom heat lamps with, … wait for it… compact fluorescent bulbs.

They still have the 10 minute twist knob timers and everything.

Fun with the C Preprocessor

Recently I’ve been writing an implementation of OpenSHMEM for the SiCortex platform. OpenSHMEM is a communications API that lets you write PGAS programs in C or FORTRAN.  PGAS stands for “partitioned global address space.”  A PGAS program is a parallel program that can run on a lot of cores or cluster nodes simultaneously. Each processing element (PE) can read and write the address spaces of the other PEs, but the program “knows” that the global address space is partitioned into a bunch of local address spaces. This is either taken care of by the language, like in UPC (unified parallel C) or by the programmer explicitly using something like OpenSHMEM.

All this is just introduction.  OpenSHMEM derives from the Cray/SGI SHMEM API, and one of the things it has are a lot of API calls that differ only in the datatypes of their arguments.

For example, OpenSHMEM has

extern void shmem_short_wait(short *var, short value);
extern void shmem_int_wait(int *var, int value);
extern void shmem_long_wait(long *var, long value);
extern void shmem_longlong_wait(longlong *var, longlong value);

all of which wait for a local variable to be set by some remote PE.

I am a lazy programmer.  I should write the same routine four times?  Instead, I used some C preprocessor magic and wrote this:

#define EmitWait(type)
void shmem_##type##_wait(type *var, type value)
{
while (*((volatile type *) var) == value) shmem_progress();
}

EmitWait(short);
EmitWait(int);
EmitWait(long);
EmitWait(longlong);

This uses the “token pasting” feature of CPP to write the proper function names for the different versions of the routine.

A bit later, I learned of the Global Address Space Performance initiative, a project at the University of Florida. By putting the performance analyzer library in front of the OpenSHMEM library on your search path, you can instrument the communications functions in your program without recompilation. This works via dynamic linking. The program calls shmem_long_wait, which is intercepted by the performance library. The library does whatever it does, then passes the call to pshmem_long_wait, which is provided by the OpenSHMEM implementation.

You can do this by providing two OpenSHMEM implementations, one with the names like shmem_long_wait, which is used when not profiling, and one with names like pshmem_long_wait, which is used when you are.  Alternatively, you can use the “weak symbol” feature of the GNU runtime. A weak symbol defines something, but it doesn’t complain if an alternative definition is present in the address space.  To make this work, you write all the functions as pshmem_long_wait, then add a weak symbol definition for the standard versions, like this:

#pragma “weak shmem_long_wait=pshmem_long_wait”

Now everything is in one library, and there is no performance penalty when you aren’t using the instrumentation library.

Well the obvious way for the lazy programmer to do this is like this:

#define EmitWait(type)
#pragma “weak shmem_##type##_wait=pshmem_##type##_wait”
void shmem_##type##_wait(type *var, type value)
{
while (*((volatile type *) var) == value) shmem_progress();
}

but this fails because you can’t use the C preprocessor to write C preprocessor items like #pragma. No problem! C99 provides an alternate version of pragma exactly for this reason. The GNU info file says:

C99 introduces the `_Pragma’ operator.  This feature addresses a major problem with `#pragma’: being a directive, it cannot be produced as the result of macro expansion.  `_Pragma’ is an operator, much like `sizeof’ or `defined’, and can be embedded in a macro.

Now I can write my macro with

_Pragma(“weak shmem_##type##_wait=pshmem_##type##_wait”)

right? Well, no. token pasting doesn’t work inside strings!  You can’t build up string constants this way. No problem! GCC automatically concatenates adjacent string constants into a single longer string. This was originally done so you can avoid line wrapping, but whatever. I can write this

_Pragma(“weak shmem_” #type “_wait=pshmem_” #type “_wait”)

This is using a different preprocessor feature, called “stringification” in which #type is expanded and turned into a string constant.

Unfortunately, this doesn’t work either, because _Pragma is processed earlier in the compiler than other uses of string constants, and before the string concatenation happens.  _Pragma has to have exactly one string constant as an argument.

How much time have I spent on this?  How many cases of _Pragma do I have to write by hand?  I give up.  The final version is

#define EmitWait(type)
void pshmem_##type##_wait(type *var, type value)
{
while (*((volatile type *) var) == value) shmem_progress();
}

_Pragma(“weak shmem_short_wait=pshmem_short_wait”)
_Pragma(“weak shmem_int_wait=pshmem_int_wait”)
_Pragma(“weak shmem_long_wait=pshmem_long_wait”)
_Pragma(“weak shmem_longlong_wait=pshmem_longlong_wait”)
_Pragma(“weak shmem_wait=pshmem_wait”)

EmitWait(short);
EmitWait(int);
EmitWait(long);
EmitWait(longlong);

It has more typing than ought to be necessary, but I got over it.

Hotel WiFi

Internet access is free at cheap hotels and costly at expensive hotels.  Costly in money or inconvenience.  What I want from hotels is a friction free experience, and mostly that is easier at mid-range hotels like, say, Hampton Inn, than it is at “better” hotels.

Case in point – the Omni Austin.  I stayed there during the Supercomputing 2008 conference, and internet access is $9.99 per day or free for members of the frequent sleepers club. The system intercepts your web access until you log in by entering your frequest guest number or agreeing to the charge.  The user experience is hideous.

Here’s what I wrote to the hotel:

The WiFi service at the Austin downtown is dreadful.
  • Slow, poor reception on 10th floor
  • Horrible signin system – The wifi being slow, but the web pages you go through to log in display very slowly
  • The promise of “returning you to the page you wanted” is a lie, you get sent to the Hotel home page. I do not want to look at your slow home page!
  • Daily login is incredibly annoying. After leaving my laptop on the desk, running, I get back and all of the network services and email have stopped working, due to your wifi cutting me off in the middle of my session.
  • The registration stuff makes it impossible to use my iPhone via wifi, because the login pages are too slow and too complicated and too tiny fonts to work on the small screen.
The design is just wrong anyway, because other net services like email simply fail to work, rather than giving any explanation. Then I have to guess that I have to use the web browser to click through your slow pages before I can read my mail. Personally, I think having paid wifi is counterproductive – much cheaper hotels just have free wifi. The cost to you is negligible, and the annoyance to your customers (me) is just stupid. I would rather stay in a Hampton Inn than an Omni. Instead, you raise your cost structure by having all this registration crap, and irritate the paying guests.
I got a letter back, from Gene McMenamin, General Manager of the Omni Austin Downtown
He offers his sincere apologies and says they are currently upgrading this service “to improve our connectivity to better accommodate the needs of our guests.”
I hope you get it right, Mr McMenamin.  
Let’s go over it, step by step.
  • Internet access is not quite too cheap to meter, but it is close.  ANY impediment to access in the name of cost recovery will reflect negatively on the hotel.
  • People who don’t use web email services, but use POP or IMAP email services, cannot use the network access until they remember that it won’t work until you use the web to click through.
  • Don’t charge or intercept, but if you must, test it yourself to see how fast it is.  A slow set of hard to read pages will just reflect negatively on you.
  • My iPhone will try to use your “free” wifi, but it will fail silently. Even if I try, the signon pages are hopeless on a handheld device.
In contrast, just putting in a free system has many benefits:
  • It is painless for the guests.  Put the hotel name in the wifi ID, leave it at that.
  • It works for all devices
  • It works for all services, web or not
  • It works for business meetings
  • It works for visitors to your coffee shop and bar

Internet access that is really friction free as well as free as in beer, leaves me a happy customer.  What I remember about hotels with bad internet experience is the same as what I remember about restaurants with slow service.  The bad experience has destroyed every other good thing you’ve done.

Why do hotels shoot themselves in the foot like this?
Sometimes it is because they were forward looking, and installed wired internet years ago. All that stuff still isn’t paid for, while hotels who waited just dropped in a few access points. In a way this is the same story as cell phones – the US was early, and as a consequence, we have a junky system by world standards.  These sunk costs are really an accounting problem, but instead of just writing them off, operators are driven by the bean counters to keep bad systems in place until their erroneous estimates of useful life are used up.
Another reason is corporate. The management fell victim to a slick salesman from a wifi accesspoint company, so they signed  a contract for paid service, and they are stuck with it. 
The worst reason is marketing, and I think that is the problem at the Omni. It is $10 a day, which they think is cheap, so they make it free for frequent guests.  Well, it isn’t free, it takes minutes of inconvenience for every user every day, and whose name is on the page they didn’t want?  Why “Omni”! Good going.   At least this is the easiest problem to fix.

Tax ideas

Is anyone not offended by the complexity of tax forms?

The tax code is Congress’ fault.  Congress is our fault.  Therefore the tax code is our fault.  We should all choose to elect a congress to fix it, but in the meantime, here are some modest proposals.

  • Congressmen must do their own taxes.  On paper.
  • All congressmen will be audited. Their mistakes get put on a web site.
  • Tax law must be delivered in source code form

And yes, I was recently trying to figure out whether I owe any estimated taxes.

(Ideas from conversations with Win.)

Leaf Peeping

This is New England. It’s fall. That means it is time for the annual trek to New Hampshire to look at the trees.

Or you can just step out the front door.

Here’s the Great Wall of Flame out back:

Fall Foliage

Here’s the Lesser Wall of Flame out front:

img_0064.JPG

Here’s the Maple we put in outside the living room window:

img_0065.JPG

And here are the three Maples in front.  Someday these will hold up some hammocks.  Don’t expect me to get up after that.

img_0063.JPG

This area has seasons. I enjoy them.

Almost Perfect

Sometimes Apple Computer seems perfect. Their design and execution are so far above that of other computer companies that it seems they are playing an entirely different game. Consequently the subtle imperfections in execution just stand out.

A month or so ago, I got an iPhone 3G.  Yeah yeah, I don’t like the battery life, but  it is so beautiful, the curved corners, the screen, the perfect physics of thescrolling flic…  I digress.

Apple has recalled the USB power adapter.  Evidently sometimes the pins break off when you unplug it.  One time I built my own spot welder… I digress.

Anyway, one can trade it in at the Apple Store, of which one is conveniently nearby, or order a new one over the web.  My first reaction was that here’s an excuse to go see the new MacBooks, but then I thought “I can use the iPhone to order its own replacement parts!”  This is so right.  I used Safari on the iPhone to fill out the form.  Apple did not anticipate me!  The form did not autofill with the iPhone serial number. The Apple ID did not autofill.  Then, when I got a confirmation screen, it advised me to print or save the screen as a pdf as there would be no confirming email.  Um, guys, iPhone Safari can’t print OR save as pdf.

So close.