Fat, Slim Pointers

31/07/2012

64 bits address space lets us access tons more memory than 32 bits, but with a catch: the pointers themselves are … well, yes, 64 bits. 8 bytes. Which eventually pile up to make a whole lot of memory devoted to pointers if you use pointer-rich data structures. Can we do something about this?

Well, in ye goode olde dayes of 16 bits/32 bits computing, we had some compilers that could deal with near and far pointers; the near, 16-bit pointers being relative to one of the segments, possibly the stack segment, and the far, 32-bits pointers being absolute or relative to a segment. This, of course, made programming pointlessly complicated as each pointer was to be used in its correct context to point to the right thing.

Read the rest of this entry »


Artsy Recycling

19/06/2012

Even when you actually want to recycle computer parts (especially scrap parts that do not quite work anymore) it’s quite hard to do so. One possible solution is to simply chuck everything in the usual recycling bin and hope for the best. Or you can try to find a metal reseller. Or you can use the parts in a creative way. Kind of.

I disassembled the CFM01 and got quite a lot of spare parts from the 1U Pentium III servers. The casings aren’t all that interesting since they’re fairly cheap (compared to, say, a Dell PowerEdge server) and the CPUs are useless. Nobody wants them. Even recycling the all-copper heat sink proved a problem. So I used them differently.

Read the rest of this entry »


New Way of Computing Square Roots?

17/04/2012

I sometimes have quite nerdy readings. As of late, I’ve been reading Le fabuleux destin de \sqrt{2} (The Fabulous Destiny of \sqrt{2}, one might translate) by Benoît Rittaud. This book is a treasure trove of \sqrt{2} facts, and one caught my eye more than the others so far: an iterative method to compute square roots of any (positive) number.

When the method is first presented, he leaves to the reader to find a demonstration (though he gives one much later on, several chapters later), but let’s see what we can find.

Read the rest of this entry »


UEID (Unique Enough IDs, part 2)

13/03/2012

As part of an open-source project I’m working on (right now, we are still at the technical feasibility stage where we explore and eliminate technical risks, full disclosure will come later) we have to issue session numbers. They’re not session numbers in the usual sense, but they still need to be unique, and not amenable to simple attacks.

There are a couple of ways of generating unique session numbers. RFC 4122-compliant unique IDs is one possible way.

Read the rest of this entry »


(Random Musings) On Floats and Encodings

31/01/2012

The float and double floating-point data types have been present for a long time in the C (and C++) standard. While neither the C nor C++ standards do not enforce it, virtually all implementations comply to the IEEE 754—or try very hard to. In fact, I do not know as of today of an implementation that uses something very different. But the IEEE 754-type floats are aging. GPU started to add extensions such as short floats for evident reasons. Should we start considering adding new types on both ends of the spectrum?

The next step up, the quadruple precision float, is already part of the standard, but, as far as I know, not implemented anywhere. Intel x86 does have something in between for its internal float format on 80 bits, the so-called extended precision, but it’s not really standard as it is not sanctioned by the IEEE standards, and, generally speaking, and surprisingly enough, not really supported well by the instruction set. It’s sometimes supported by the long double C type. But, anyway, what’s in a floating point number?

Read the rest of this entry »


Medians (Part III)

24/01/2012

So in the two previous parts of this series, we have looked at the selection algorithm and at sorting networks for determining efficiently the (sample) median of a series of values.

In this last installment of the series, I consider an efficient (but approximate) algorithm based on heaps to compute the median.

Read the rest of this entry »


Slow down, Keep It Cool

20/12/2011

In a previous post, I discussed how to set the default power policy with Linux (Ubuntu) by detecting the battery/power status: if you’re plugged-in, set it to on-demand, if you’re running from the battery, set it to powersave. This is rather crude, but proved effective.

But CPUs that support SpeedStep (or similar) usually support a rather long list of possible speed settings. For example, my i7 supports about 15 different speeds, and “powersave” selects the slowest of all, 1.60GHz (on my laptop, that would be 800MHz). Maybe we could leave the policy to on-demand, but cap the maximum speed to something a bit lower than maximum?

Read the rest of this entry »


(more) Mild Obfuscation

13/12/2011

In Mild Obfuscation, I proposed

a^2 \equiv 1 ~(\mathrm{mod}~n)

as a “cryptographic” primitive. For n=2^k, the only possible solutions for a are \pm{}1 and 2^{k-1}\pm{1}. But what are the solutions if n \not\sim 2^k? Are there better n than others?

Read the rest of this entry »


Keep it cool

06/12/2011

On a couple of occasions, I presented some hardware hacks, not always very elaborate, and today I add another one to the collection: a mac book power supply holder.

If you have one of those, you know that they can get rather warm—almost hot, in fact—when the computer’s running full blast, and I thought it might be cool to have some kind of holder so that the transformer remains straight up, offering most of its surface to the ambient air.

Read the rest of this entry »


Python Iterators

29/11/2011

An iterator is an essential mechanism of data structure abstraction. An iterator will allow you to walk a data structure, giving you a pointer (or a reference) to the object in the collection corresponding to the current value of the iterator, while hiding as much as possible the implementation details of the underlying data structure. In C++’s Standard Template Library, for example, all collections provide iterators (they don’t exactly all provide the same interface, but that’s another story).

Python also defines something similar to iterators, that is: iterables. But there’s more than one way of getting this done, depending on what exactly we want iterators to do.

Read the rest of this entry »