samedi 11 juin 2016

How to generate set of enumerations with even number of ones [on hold]


I have an idea of how to prevent a single bit flip (due to cosmic radiation or similar externally induced event) from causing enumerations (enum) to change from one defined value to another defined value in a relatively easy way. To put it simple each value should have an even amount of ones, binary speaking. If one flips, the enum will be odd and is guaranteed not to match any other enum.

I'm not sure how to actually "generate" such a sequence so that it may be used as enum values as those values must be compile time constant. A macro function returning the n:th element in the set would do perfectly.

The first few numbers in the sequence would be 0 (000), 3 (011), 5 (101), 6 (110). I think you get the idea by now.

Non-enumeration (non-compile time) answers are appreciated as it may help me realize how to do it myself.


To make myself clear I want a macro generating the n:th number in an enum with even number of ones in the bit pattern, similar to macros generating the fibbonachi sequence. The lowest bit is essentially a parity bit.


Most of my memory is protected by hardware ECC, L1 cache being one exception. A single bit error in L1 has been measured to once every 10000h which is good enough seen from my requirements.

VRAM however is not protected. There I have mostly RGB(A) raster, a few general purpose raster (like stencil) and some geometry. RGB raster is rather unsensative to bit flips as it is only used for visualization. Erroneous geometry is in general very visible, very rare (few KB) and is by design to be resolved by user induced reboot.

For a 4096x4096x8bit stencil (~16MB) single bit error rate is in my environment about once every 8h for average cosmic radiation, more often during solar storms. It is actually not that bad in my opinion, but I'd hate filling the paper work proving to my officers why this is perfectly fine in my application and everyone elses using the stencil data without regard to how the data is used. If having a parity bit in the stencil value however I'd be able to detect most errors and if necessary re-generate the stencil hoping for better results. The stencil can be generated in less than a second so the risk of errors occuring twice in a row is considered low.

So basically, by generating a set of enumerations with parity I dodge the bullet of current and future paper work and research regarding how it may affect my app and others'.


Aucun commentaire:

Enregistrer un commentaire