|
-
Apr 29th, 2024, 12:02 PM
#1
[RESOLVED] Core Affinity
I am working on a program that could be considered embarrassingly parallel, in that a series of actions is repeated many times, and the actions do not have to be performed sequentially. The program is a genetic algorithm, so there is a population, and each member is evaluated in what amounts to a long series of calculations. Each member of the population could be evaluated independently of one another, but there is no waiting around during an evaluation, as it is just a calculation, albeit a long one.
The bulk of the actual work done is the calculation, so I initially set this up as each evaluation being a Task. I felt that I could launch an evaluation of each member of the population in a different Task, and they would get processed across all available CPU cores. That doesn't appear to be what happened, though, because evaluating each one sequentially was no slower, and seemed slightly faster (it's very hard to measure that) than doing each evaluation in a Task. That would make sense if all the Tasks were queueing on a single core, as the overhead of queuing up the tasks would make the Task approach slightly slower.
I have a different approach that I am considering, though it's probably not worth doing, which is to divide the problem at a much more granular level and spawn a series of Tasks or Threads that would each be an entire genetic algorithm evaluating an entire population. There is no advantage to this, either, unless the threads can take advantage of multiple cores. Such a program would actually be worse in a couple ways, since it would be far more complex and would make it impossible to take reasonable snapshots of the process, but if multiple cores could be used simultaneously, it could be considerably faster. That might be worthwhile, as the program takes four hours to run to completion, so cutting that in half, or more, would save significant time.
What I can't figure out is whether or not it would work, and it seems likely that it would not. I see that there is some means to set the affinity of a process to a single core, but that's kind of the opposite of what I am looking for. I'd like the multiple threads to take advantage of all the cores on the system, not restrict them to a single core, which is what the program is currently doing.
Is that even possible? I see that processes could be assigned to specific cores, but is it possible for Tasks or threads to be assigned to, "whatever is available"?
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|