Will LINQ’s parallel extensions automatically detect the number of cores and utilize them all? Conversely, if the code is run on a single core machine, will it still work or do I have to detect the number of cores and tell PLINQ how many to run across?
Sadly, I don’t have access to any single core machines to test my code on so I can’t even test this for myself and I haven’t been able to find any useful info elsewhere…
Also, while it might at first seem obvious when to use parallelism, are there any rules of thumb regarding where it should and as importantly should not be used?
Side Note: I don’t necessarily program in a specific environment. I tend to divide my time somewhat equally (depending on project) between web, client/server apps, windows apps, windows service and console utilities depending on the task at hand.
Yes, it handles the core count itself, and is fine on single core, pseudo-multi-core (HT), right up to stupid numbers of cores – but you do need to code against
Parallelyourself; it doesn’t simply seize control over your existing code.For when to use parallelism… that is a huge topic. Actually, if you are doing web programming – I’d forget it and simply let IIS use different parallel threads for different requests (rather than letting one request hog the machine).
It is mainly useful for big number crunching / data gathering – either on a dedicated app-server, or at the client.