By ad-hoc I mean that new Pi's that join the network may add their resources into it. Maybe a cluster is not the best solution so any input will be appreciated
Webpage, with instructions: http://www.southampton.ac.uk/~sjc/raspberrypi/
If you mean more of a distributed network, where the pis are not all in one place, I would recommend looking into the source or techniques employed by projects like Folding@Home. That project is open source, and there are other similar projects that may be good resources for this kind of project.
Folding@Home open source link: http://folding.stanford.edu/home/faq/faq-opensource