
2 Feb
2009
2 Feb
'09
7:02 p.m.
Howdy,
If you don't care to customize, no problem! Just write:
parallel_sort<2>(v.begin(), v.end()); // sort with 2 threads
Does templating on the number of threads produce a large gain, as opposed to making it a run-time option? Having to compile separate executables for different numbers of cores seems a bit limiting.
You can write a runtime wrapper if needed: parallel_runtime(Iterator first, Iterator last, int threads) { switch(threads) { case 2: parallel_sort<2>(first, last); break; // etc. } } I haven't benchmarked against a runtime option, I did a template parameter as it felt more natural to me to make this a compile time parameter rather than a runtime parameter. -- EA