Multithreading question

BlitzMax Forums/BlitzMax Programming/Multithreading question

JBR(Posted 2010) [#1]
Is there a way to limit the number of cores used within the program.

Just for testing - one core vs two cores etc.

I could use the set affinity but it's a hastle.

Thanks
Jim


ImaginaryHuman(Posted 2010) [#2]
It's kinda up to the o/s to distribute threads across cores... might be some specific api calls you can make though?


BlitzSupport(Posted 2010) [#3]
This will let you set processor affinity programmatically (on Windows)...




JBR(Posted 2010) [#4]
Many Thanks
Jim


JBR(Posted 2010) [#5]
What does Extern "win32" do?

Where are the functions from?

Jim

Forgot to ask, I've got the i7 quad core and it comes with hyperthreading which shows up as 8 cores. 0 to 7. What are the numbers of the real cores?

Last edited 2010


byo(Posted 2010) [#6]
It's there to show Blitzmax you're going to declare and use Windows API functions from DLLs that comes with Windows.

Google "Windows API" to learn more about the functions used.


BlitzSupport(Posted 2010) [#7]
Yeah, you can also Google msdn SetProcessAffinityMask (or any of the other functions) to find the docs for these Windows calls.

In terms of finding the number of 'real' cores, it's possible, but takes quite a bit of effort -- and for what? Windows is still going to treat it as an 8-core processor no matter what!

You could probably use the GetNumaProcessorNodeEx function to work out which of the 8 cores relate to each 'real' core, but I don't think it's worth bothering with, since the information is (practically) useless.


Scaremonger(Posted 2014) [#8]
Cheers James.. :)


ImaginaryHuman(Posted 2014) [#9]
That was a slightly overdue thankyou, lol