Archive for the ‘Development’ Category.

My New Heroes

http://fastra.ua.ac.be/en/index.html

What a beast! It puts our single 8800 GTX machine to shame. I want one!!

How to Use Constant Memory in CUDA

So the other day I wanted to store a lookup table in constant memory because of its decent sized cache (compared to global memory with no cache). After trying to get it working, I just could not get the syntax correct. At first there was no speed up at all, so the global memory must have been incorrectly used. Eventually I stumbled across a code sample that used the constant memory in the way I wanted to, and got my code using constant memory correctly! Heres how I did it:

Step 1: Global declaration (ie. not inside a function) of the constant array
extern __constant__ int d_nLookup[1<<13];

Step 2: Copy the data to the constant memory in a host running function
CUDA_SAFE_CALL(cudaMemcpyToSymbol(d_nlookup, h_nlookup, 1<<13 * sizeof(int), 0, cudaMemcpyHostToDevice));

Step 3: Use array in __device__ or __global__ functions directly (no need to pass array reference as a parameter)
fTemp += d_idata[d_nLookup[i]]; // use only loop map

As the array is defined as extern, it can be referenced in any __device__ or __global__ function without needing a reference to be passed to the function. Unfortunately, the size of the array has to be set at compile time (although I didn’t try dynamic allocation, it might just work). It’s important to note the use of cudaMemcpyToSymbol instead of cudaMemcpy; this fact was not emphasized anywhere and really had me stumped! Also, there is no need to cudaMalloc or cudaFree constant memory.

I suspect that the constant memory is simply a wrapped up version of 1D texturing. The constant memory array is used inside a loop, so theoretically with a hit and miss cache setup the first call to each position of the array should be a miss (meaning global memory latency). However this is not the case, so I suspect the compiler has detected the usage and fills up the 8KB cache on the first call.

Outlook freezes with 100% CPU when printing

Encountered this bug today at work, and it kept me stumped for (too many) hours! The symptoms where that Microsoft Outlook 2003 would freeze when printing an e-mail, showing the unresponsive “Printing…” status dialog in the middle of the screen. Now that Outlook was frozen, any new e-mails that were opened would spawn a new OUTLOOK.EXE process and wait for the busy process to finish.

After terminating the busy process, all the e-mails would open immediately! Major pain in the a-hole. It turns out that Quick View Plus had installed an addon into Outlook which made printing a bit screwy. Disabling it was easy; from Outlooks main window, Tools > Options > Other > Advanced Options > Add-in Manager, and uncheck the Quick View Plus add-in. Save those settings and restart Outlook.

Update: If restarting Outlook doesn’t work, try ending via Task Manager any OUTLOOK.EXE and OLADDIN.EXE processes that may be running, then starting Outlook again.

Missing URL in BibTex Bibliography

This is some stupid thing that cost me several hours of tinkering tonight. By default, URLs and last access time/date are not part of any style in LaTeX. How freaking ancient is that?!!?!

So heres a fix. Its been tested under OS X 10.5, so it should work for anyone running Linux too.

  1. Download urlbst from http://nxg.me.uk/dist/urlbst/. For me the current version is 0.6.
  2. Extract the archive anywhere, just so happened to be my Downloads folder.
  3. Open a terminal window, and navigate to the newly created directly. For me it was ~/Downloads/urlbst-0.6/
  4. Run ‘./configure’ without the ‘ and ‘
  5. I have to use the acm bibliography style, so i will be playing around with acm.bst
  6. Run ’sudo mv /usr/local/texlive/2007/texmf-dist/bibtex/bst/base/acm.bst /usr/local/texlive/2007/texmf-dist/bibtex/bst/base/oldacm.bst’. This moves the original style file to a safe place.
  7. Run ‘./urlbst /usr/local/texlive/2007/texmf-dist/bibtex/bst/base/acm.bst newacm.bst’. This adds the URL information to the style.
  8. Run ’sudo cp newacm.bst /usr/local/texlive/2007/texmf-dist/bibtex/bst/base/acm.bst. This moves the new style file to a directly where LaTeX can find it.

Now all your webpages and sources with online references & cite dates will look right! Woot! Sleepy time now!!!

AJAX in ASP.NET 2.0 - Introduction To The Basics

AJAX has become quite the buzzword lately when it comes to Web 2.0. Luckily, AJAX is really easy to integrate into new and existing ASP.NET application; it’s just a matter of adding some simple controls here and there. The best thing about AJAX in ASP.NET is that no complex coding is required; all the postbacks and Javascript is abstracted away.

In this article I want to provide a quick introduction to AJAX in ASP.NET, highlighting core ideas and useful hints, aimed for existing developers who want to dabble with AJAX. I’m going to start with installing ASP.NET AJAX and configuring Visual Studio 2005 (which takes no time at all). Then its onto a description of 3 of the main controls that utilise AJAX; the ScriptManager, UpdatePanel and Timer. Finally, I will create a small project that combines these controls to perform a simple task.

Continue reading ‘AJAX in ASP.NET 2.0 - Introduction To The Basics’ »

Enhanced Calendar with Next/Previous Year Buttons

This is a copy of my first blog post, originally posted here. After writing this post, a very comprehensive calendar was added to the AJAX Control Toolkit.

By default, Visual Studio 2005 includes a useful range of components for building ASP.NET web applications. Unfortunately these components are usually very basic and have restricted usability, but with a small amount of customisation become highly usable.

Enter the world of User Controls. A User Control uses regular ASP.NET components as building blocks to construct a more complex control that can be used in the same way as a regular component. User Controls can be assigned their own methods, properties, events, and be drag-and-dropped into ASP pages.

Continue reading ‘Enhanced Calendar with Next/Previous Year Buttons’ »