flat assembler
Message board for the users of flat assembler.
Index
> Windows > Programming for multicore CPU's |
Author |
|
JohnFound 06 May 2014, 16:00
IMHO, the first approach. Actually the OS should probably dispatch the tasks better. Or even better (if possible) you can think of algorithm that will do the calculations faster.
|
|||
06 May 2014, 16:00 |
|
tthsqe 06 May 2014, 16:32
Why don't you try both and see which is faster.
I usually use SetThreadAffinityMask when the tasks for each core are the same and the cache is important.. |
|||
06 May 2014, 16:32 |
|
revolution 06 May 2014, 16:51
There is no general answer that is right for all situations. Just try them and see which works for your particular case. But there is one overriding factor to avoid; and that is to make sure you don't issue more threads than you have cores. And there is another more minor factor; and that is to consider hyperthreading (SMT). There are some cases where using all logical cores can hurt performance, and changing to using only as many threads as you have physical cores (and also using affinity settings to force physical core locking) can boost performance.
ETA: I hope your cooling system is in good condition. Your system will likely get hot. |
|||
06 May 2014, 16:51 |
|
SokilOff 09 May 2014, 12:53
Thanks, guys. I'll try both variants and see, which could give better results.
tthsqe wrote: I usually use SetThreadAffinityMask when the tasks for each core are the same and the cache is important.. The problem here is that you can assign a thread to already heavily loaded core. revolution wrote:
Also good point. Thank you. |
|||
09 May 2014, 12:53 |
|
sinsi 09 May 2014, 13:28
SokilOff wrote: The problem here is that you can assign a thread to already heavily loaded core. Maybe a hint using SetThreadIdealProcessor might be better than limiting to one core with SetThreadAffinityMask. |
|||
09 May 2014, 13:28 |
|
SokilOff 10 May 2014, 13:33
sinsi wrote: Maybe a hint using SetThreadIdealProcessor might be better than limiting to one core with SetThreadAffinityMask. One more question. If all threads have one common counter, is it enough to do something like lock inc [CommonCounter] in all these threads to be sure they don't modify counter at the same time without knowing that value has already been changed by another thread (for example in other core's cache but not yet written back to RAM) ? And the same story with something like: mov eax, [valueToCompare] mov ecx, [newValue] mov esi, requiredAddress lock cmpxchg [esi], ecx ; <---- this one Will just be enough to use prefix 'lock' in all threads to be sure that content of [requiredAddress] won't be changed more than once ? In theory it should be (atomic operations are used in both cases). But maybe I missed something... edit: typo |
|||
10 May 2014, 13:33 |
|
revolution 11 May 2014, 11:37
SokilOff wrote: If all threads have one common counter, is it enough to do something like SokilOff wrote: And the same story with something like: |
|||
11 May 2014, 11:37 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.