6 Feb 2007 johnnyb   » (Journeyer)

Stupid things to avoid when coding for the Cell BE

I just spent about 8 hours trying to diagnose these problems, so I'll try to avoid someone else similar pain:

1) DO NOT perform DMA transfers _into_ read-only memory in the PPE. And remember, string constants get put in read-only memory. Apparently, this only triggers a bus error under certain conditions, and in others it works just fine. Also, it is nearly impossible to debug, because the "-g" flag makes the string areas read-write!

2) If the contents of your DMA transfers look like you got multiple buffers crossed, look to see if you are going out-of-bounds in your buffers in the SPU. This looks very much like a DMA problem, but its not, and it produces no errors.

3) Be careful of 32-bit/64-bit discrepancies in PPE/SPE communication. Use unsigned long long for pointers that are passed to SPE code. This will make your code easier to switch between 32-bit and 64-bit mode, as the memory layout will be the same.

And, for something positive:

If you want aligned data, try memalign or posix_memalign.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!