Thursday, September 14, 2006

Truly parallel

Today it has become common with multicore CPU's. Much discussion has erupted about the average users benefits from this and if it's just a hype. An obstacle in they way of making use of all the cores is that the majority of the programs today is not meant to be running on machines like this, they can't themselves make use of the extra power. This is a quest for the operating system which also have a hard time achieving this as the programs are written in languages which has not been designed for the issue. Sure, Java supports threads and Unix systems allow C programs to fork but it is up to the programmer of every program to design how this is going to be used. As these systems also should be able to run on platforms with only one CPU, it is thus hard for a programmer to make use of the power, the programmer does not know how many cores the system will run on, the operating system will decide how and when the code will run.

I would like to see a new programming paradigm. A paradigm more similar to how nature makes use of parallelism. Take a human cell for example. Every cell contains the exact same program(the DNA) but still the cells can form a complex being out of a single cell. Why does not the human cells act like bacteria that just multiply, making copies of itself.

The secret is that when a human cell divides the program counter, the DNA decoding device, is not placed at the beginning of the code. The child cells will run another part of the code even thought it contains the exact same code. Tom Ray made some initial promising studies on this in his Tierra project. Also he added another piece of the puzzle to his evolving code snippets. He designed a computer language that was very robust to random changes, something the CPU in your computer in front of you is not. Make a random change to a PC program and the program will break.

But isn't this exactly what a fork in a C program does, dividing the code in two and setting the program counter to a new place for the child? Yes, it is, the difference is how the processes communicate. In a PC one process writes to memory and another reads, this has to be controlled very strictly, every process knows what the other processes are supposed to do, and who will listen to a specific message. In a living being the child processes are on their own, no message(chemical) is meant for a specific cell. This approach adds hugely to the evolvability of a system. An interesting thing is that there is nothing in the computers design that keeps us from doing it in natures way, it is just very hard to write programs like these with the languages and operating systems we have today. Ask a Linux kernel developer what he thinks about inter process communication, I think he would welcome something new.

No comments: