First update

Well, that was fast. Only a few days since I’ve uploaded the 0.8 version of the simulator and here’s an update.

As it turns out, the IOS uses the size of the COS image to determine the location to upload the PARAMETER file during boot. If I get the COS image file size wrong (which is what happened) than IOS loads the PARAMETER file to the wrong location and consequently COS will not find it.

The new, v-0.81 release fixes this problem so now the parameter file settings are effective. Here’s the update on the boot process:

Once you’ve logged in to the Cray Station console (see the previous article on how to get there), type in:

STMSG

This gives you an ‘interactive’ communication channel with the booting COS. Eventually you should get the following message:

image

Here, you reply by typing in:

REPLY,0,GO

Some time after, you get another message:

image

This message is telling you that your PARAMETER file works and you will be performing an ‘install’ operation, which is what you want. So, reply again:

REPLY,1,GO

The next message you get is this:

image

And, well, this is where I get stuck now. I’m not sure what’s going wrong, but something obviously does. Curiously, I also get a lot of errors on the IOP3 (XIOP) console:

image

This is almost certainly because of my next to non-existent BMX channel and device simulation – COS is most likely trying to talk to the IBM tape drives here. But are the two problems correlated? Who knows. I guess I’ll have to square up my BMX simulation before I will.

Till then, the newest release is here:
http://www.modularcircuits.com/download/cray_files/cray_xmp_sim-0.81.zip

On Function Call Inlining

I’ve heard so many people claim that the main benefit of inlining is that the compiler can save the call and return instructions. Some examples:

http://stackoverflow.com/questions/145838/benefits-of-inline-functions-in-c
http://www.exforsys.com/tutorials/c-plus-plus/inline-functions.html

That’s all well and nice, but that’s not even scratching the surface of the benefit of inlining.

The main reason inlining is a powerful optimization tool is that, once the function is inlined, the compiler can optimize it with the call-site. Constants can be propagated into the function body. Loops can be more efficiently re-arranged, code can be hoisted, registers can be (more) optimally allocated, essentially all the heavy artillery that an optimizing compiler has can be deployed on the merged function. Furthermore, since the compiler has full information of what’s going on inside the function that was called, it doesn’t have to make conservative assumptions about side-effects, subsequent function calls, etc.

The effects of all the above are way more impactful than the saved call and return – even if you take the potential branch-misprediction penalty and parameter save operations into consideration.

Some get it right. Some make a note on this and move on.

The down-side of course is that it could increase code-size. Over-use of inlining might generate more (instruction) cache-misses, which can hurt your performance quite a bit. My personal guidelines:

  • Small functions should be inlined
  • Large functions with only a few call-sites could be inlined
  • Large functions, called from a number of places should not be inlined – though a few specific call-sites could be inlined

Of course most of these decisions are made by your compiler already, but checking the results, and on occasion forcing the compiler to bend your way can be beneficial: unless you use profile-guided optimization, the compiler has to make inlining decisions based on a static view of the code, so it can’t take for example execution frequency into consideration.

Finally, the biggest enemies of inlining (in C++) are virtual functions: it’s very hard for the compiler to see through a virtual function call and realize that you always (or most of the time) call the same virtual function. Providing non-virtual variants and manually calling them in cases when inlining is expected is probably the best way around this problem.

Welcome

Welcome to the newly re-designed Modular Circuits site. I’ve finally taken the time to move the content over to a new blog-based system, where I can keep the site more up-to-date, and where most importantly you, dear reader, can comment and help me improve the content as well.

It will take some time to get all the kinks out, so please bear with me and report any issues you may find.

And now that I grabbed your attention, may I direct it to the whole-new ‘Articles’ section above, where you can find new (and as of now still incomplete) content on H-bridges and electro-mechanical systems.