User:WillWare/Playing with CUDA

http://willware.blogspot.com/2009/07/building-gpu-machine.html

So I've downloaded a bunch of CUDA stuff from the NVIDIA website. (Hmm, just noticed how easy it is to mistype "NCIDIA", it's almost insidious.) And I'm giving it a very small fraction of my attention because the machine is at work, where I need to attend to work stuff. So my rate of absorption is very low.

Code wiki
The big temptation is to play with some kind of source code mark-up thing, write some kind of "code wiki", and that's a tempting idea that I've thought about before, but I don't want to waste huge time on that and never get around to learning CUDA. So I only want to work on that if it ends up helping me learn CUDA faster, and I'm afraid of being enchanted by a diversion and never getting back.

I guess one thing I could do is print pieces of the CUDA code and stick them in a paper notebook, and annotate them with yellow stickies, so I'm not having to invent anything.

import os, sys, re headerBoilerplate = """ %(filename)s   """ jscriptBoilerplate= """ function open_window_%(linenum)d { new_window_%(linenum)d = open("","hoverwindow","width=300,height=200,left=10,top=10"); new_window_%(linenum)d.document.open; new_window_%(linenum)d.document.write(" Line %(linenum)d "); new_window_%(linenum)d.document.write(""); new_window_%(linenum)d.document.write("%(text)s"); new_window_%(linenum)d.document.write("  "); new_window_%(linenum)d.document.close; } function close_window_%(linenum)d { new_window_%(linenum)d.close; } """ class Comments: def __init__(self, filename, d=None): self.filename = filename if d is not None: self.commentary = d        else: self.commentary = { } self.lines = open(filename).readlines def html(self, outfname): ss = sys.stdout outf = open(outfname, "w") class MyFile: def write(self, x): outf.write(x) sys.stdout = MyFile print headerBoilerplate % {"filename": self.filename} if len(self.commentary) > 0: print "" print " " print "&lt;pre>" i = 1 for L in c.lines: L = "%8d" % i + " " + L.rstrip if self.commentary.has_key(i): L = (("") %                     {"linenum": i} +                      L + "") print L            i += 1 print "&lt;/pre> " sys.stdout = ss f = "/home/wware/NVIDIA_CUDA_SDK_hack/projects/scan/scan.cu" c = Comments(f, {       176: "Invoke a kernel, use the GPUs"        # There needs to be a way to refer to another file, and give        # the option of opening a new tab for it (if not open)        # NVIDIA_CUDA_SDK_hack/projects/scan/scan_best_kernel.cu line 78        }) c.html("tryit.html") import webbrowser webbrowser.open("tryit.html")
 * 1) !/usr/bin/python
 * 2) Add commentary to some code

That's what I've got so far.