Why You Should Get A Coding Cap June 5th, 2009
Patrick Stein

Way back when I was at Computer Science House I discovered coding caps. We were working on a Virtual Reality project (I told you it was way back, right?). While we were working, a company called Virtuality made a stop at R.I.T. as part of a larger tour of campuses showing off their VR game.

Guess Jeans was one of the sponsors of their tour. All of us working on the VR project ended up with black baseball-ish caps that said Guess across the front. We wore those caps all of the time we were coding.

Lately, I’ve been having trouble focusing on coding when I am gifted with some moments to spare. I thought, How about I get a coding cap? I tried this about a year ago when I was having similar trouble. The cap didn’t really work then. The cap would itch after a few hours, and before that, I would forget I was wearing it. Once you start reading email and answering the phone in your coding cap, it loses its power.

So, today, I set out looking for a new coding cap… one that I could wear for a few hours, but one that I would notice I was wearing. I tried on a few hats. None of them felt powerful enough. They didn’t have the coding cap magic.

I grabbed a pair of lace-up, fishnet, fingerless gloves. I plan to leave one by my keyboard and the other in my purse. When it’s coding time, I’ll slip one on.

So far, they seem to work. When I reach to check email, I immediately notice my glove and stop. When the phone rings, I peek at the caller-id and decide whether it’s worth it to remove the glove. Sorry, Out of Area: I’m coding right now, and I don’t want to have to take off my glove to hear about the great things you can do for my windshield/interest-rates/auto-warranty/credit-card-processing.

Do you have a coding cap? specific lighting? specific music?

Installing mpich2 for use with CL-MPI June 5th, 2009
Patrick Stein

Some time back, I began writing some OpenMPI wrappers for Lisp. I got everything that I needed working, but I hardly scratched the surface of what MPI-2 makes available.

Recently, Alex Fukunaga started up a blog about Lisp. One of the things he has done is make CFFI bindings for mpich2. Here is an introductory post about those bindings with a link to his CL-MPI site.

Today, I have been working on getting his bindings up and running under Ubuntu Linux and Mac OS X.

Read the rest of this entry ⇒

Emacs + Slime + SBCL on Windows Vista May 27th, 2009
Patrick Stein

I just finished setting up Windows Vista to run in VMWare Fusion. Then, I finally tackled setting up Emacs with Slime and SBCL under Windows Vista.

For the most part, I followed Robert Zubek’s gameplan. However, I quickly ran into a problem with swank’s temporary files not being in a writable location. I wish I had found this thread sooner. Alas, I ended up rolling my own by tweaking the temp-file-name function in swank-sbcl.lisp. The new version looks like this:

(defun temp-file-name ()
    "Return a temporary file name to compile strings into."
  #-win32 (concatenate 'string (tmpnam nil) ".lisp")
  #+win32 (concatenate 'string
                       (sb-ext:posix-getenv "TEMP")
                       "/"
                       (symbol-name (gensym "SL"))
                       ".lisp"))

Developing Lisp in Ubuntu Linux with VMWare Fusion May 27th, 2009
Patrick Stein

I am working on some lisp software that I would like to run under Linux, MacOSX, and Windows.

I have a PC that I can boot into either Ubuntu Linux or Windows Vista. Of course, I have a variety of services running under Ubuntu Linux on that box that the rest of my network would rather have around. As such, I would rather never boot that machine into Windows. So, I thought I’d give VMWare Fusion a try.

Actually, I thought I would try both VMWare Fusion and Parallels. Alas, Parallels lets me get my virtual machine set up, but will not let me run it without a license. VMWare Fusion lets me play for 30 days before buying a license. From what I’m seeing from VMWare Fusion’s performance, I can’t imagine dropping $80 on Parallels just to see if its virtual machine can outperform what I’m seeing from Fusion.

Right now, I am in the process of moving over the PC’s Windows stuff to my laptop so I can try running Vista through Fusion. While I was waiting for that, however, I installed Ubuntu under Fusion, updated a ton of packages, installed emacs, sbcl, slime, etc.

For comparison, I took some lisp code that runs in just under 11 seconds on my laptop. I ran the same code under Ubuntu in Fusion on the same laptop. It ran in just under 12 seconds. Some of that may also be that I am using an older version of SBCL under Ubuntu than I am native.

I have some more testing to do to make sure that cl-opengl will perform as well. But, I am quite pleased.

Optimizing Lisp May 24th, 2009
Patrick Stein

Paul Reiners recently posted some code to the TC Lispers mailing list. The code began from Paul Graham’s ANSI Common Lisp book. Exercise 13b has you adding declarations to some code so that the compiler can better take advantage of the types involved. Oddly, the code ran more slowly with his typing than it did without it. I had the same experience when I tried this code under SBCL 1.0.23 on Mac OS X.

Here is Paul’s original code which he made available with Creative Commons License the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

I stripped out the declarations and started adding them in one by one, trying to deal with as many compiler notes as I could figure out in the process. First, in the base case, the following took 22.5 seconds on my computer.

(time (ray-test 8))

After much tweaking, I have gotten it down to just under 11 seconds. Most of that came with declaring the types of the slots in the (defstruct …)‘s and these three declarations:

(declaim (ftype (function (long-float) long-float) sq))
(declaim (ftype (function (long-float
                           long-float
                           long-float) long-float) mag))
(declaim (ftype (function (long-float
                           long-float
                           long-float)
                          (values long-float
                                  long-float
                                  long-float)) unit-vector))

This declaration, however, shot me back up to 22 seconds.

(declaim (ftype (function (long-float
                           long-float
                           long-float)
                          long-float)) minroot))

Of course, it really should have been returning (or long-float nil). But, that didn’t help either. From the compiler notes, it seems that (min …) in SBCL doesn’t deal well with unboxed floats. I will have to look harder at that section and ask on the SBCL lists. I believe that I tried decorating the expressions there, too.

(the long-float (min (the long-float
                       (/ (the long-float (+ (the long-float (- b))
                                             discrt)
                               (the long-float (* 2L0 a)))))
                     (the long-float
                       (/ (the long-float (- (the long-float (- b))
                                             discrt)
                               (the long-float (* 2L0 a)))))))

Updates In Email

Email:

l