Sign in to follow this  

Parallel processing in multi-core arquitectures

This topic is 4091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering, how can a program take control of what instructions are processed in one core or the other? There are mechanisms in place to try to make the most of the available processing power, by making a good distribution between the cores, but of course the programmer is in a better position to make assumptions and say what code can be parallel to what (assuming a programming language with such capabilities). I hope this question does not show that I'm grossly uninformed or whatever, but I would like to know if direct methods of controlling this distribution are available as assembly opcodes (or something else for that matter).

Share this post


Link to post
Share on other sites
It's dependent upon the operating system/platform really.

If you're working on a console which has multiple cores you can set exactly which processor the thread runs on.

In Windows you can tell a thread which processors it is allowed to run on by setting it's affinity mask, but that simply limits the processors which Windows can give the thread a timeslice to. As there are usually many competing threads in windows you are much better off just letting windows decide the best place to let the thread run as the operating system has a much better idea of how to balance the threads it needs to execute.

Share this post


Link to post
Share on other sites
When people were using single core CPU, they assumed they shouldn't stay in the way of OS scheduler (and expect preemptive multithreading). Assuming the scheduler isn't completely retarded, it's better to don't stay in the way.
There is also a problem called other programs on the OS, basically user might do sensitive rendering OS wouldn't be normally a retard and schedule both programs correctly, however programmer would change rules and rendering would get hickups.

As for your questions about assembly, current thread distribution is done mainly in software, thus aside a limited SSE3 instruction, there is pretty much lack of support for this (if you don't count ability of ASM programmers to write without cache into the memory).

Share this post


Link to post
Share on other sites
The affinity mask setting is used when you have more than one thread that each operate on fairly independent data and would rather avoid cache misses than get maximum CPU time. In other words, setting the affinity mask can sometimes be used to improve efficiency - which may improve or degrade performance for the app depending on other issues. Particularly I have seen people sucessfully use affinity mask to set 2 threads which have slightly high mutex contention to both run only on the first processor, which basically means - for those two threads it is a single core computer. But the other thread which are more free running the remaining computing slices will be allocated however the OS wants.

Share this post


Link to post
Share on other sites

This topic is 4091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this