Activate multi-core
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Activate multi-core
Hello!
Is there a command or option that AUTOMATICALLY makes my code use all the machine's cores?
I have been using mum's i7 4-core to produce data using my PhD project but it is still slow as hell...
I am also using my dual-core Celeron (netbook) but it takes around 18-19 hours.
Thanks!
Is there a command or option that AUTOMATICALLY makes my code use all the machine's cores?
I have been using mum's i7 4-core to produce data using my PhD project but it is still slow as hell...
I am also using my dual-core Celeron (netbook) but it takes around 18-19 hours.
Thanks!
Re: Activate multi-core
Your code must support this ...
The use of threads is required. The distribution of the threads on the processors then the operating system for you
The use of threads is required. The distribution of the threads on the processors then the operating system for you
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Activate multi-core
What do you do ? Does your code would take advantage of parallel processing your data ?
If you want to use all your core you need Pb's thread commands.
If you want to use all your core you need Pb's thread commands.
There are 2 methods to program bugless.
But only the third works fine.
Win10, Pb x64 5.71 LTS
But only the third works fine.
Win10, Pb x64 5.71 LTS
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: Activate multi-core
why can't it work out of the box?
Re: Activate multi-core
Another proven way, which I sometimes use, is simply launching several instances of your executable, each doing separate portions of the job. The processes will nicely spread over all cores. But of course this would only work for relatively simple things.Fig wrote:What do you do ? Does your code would take advantage of parallel processing your data ?
If you want to use all your core you need Pb's thread commands.
I call it the lazy and poor man's approach to parallel processing
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: Activate multi-core
[17:41] <marcoagpinto> red=0
[17:41] <marcoagpinto> for f=1 to 100
[17:41] <marcoagpinto> red+1
[17:41] <marcoagpinto> next f
[17:41] <marcoagpinto> -------
[17:41] <marcoagpinto> blue=0
[17:42] <marcoagpinto> for f=1 to 100
[17:42] <marcoagpinto> blue+1
[17:42] <marcoagpinto> next f
[17:42] <marcoagpinto> ----
[17:42] <marcoagpinto>
[17:42] <marcoagpinto> is it dangerous and hard to do?
[17:42] <marcoagpinto> :p
[17:41] <marcoagpinto> for f=1 to 100
[17:41] <marcoagpinto> red+1
[17:41] <marcoagpinto> next f
[17:41] <marcoagpinto> -------
[17:41] <marcoagpinto> blue=0
[17:42] <marcoagpinto> for f=1 to 100
[17:42] <marcoagpinto> blue+1
[17:42] <marcoagpinto> next f
[17:42] <marcoagpinto> ----
[17:42] <marcoagpinto>
[17:42] <marcoagpinto> is it dangerous and hard to do?
[17:42] <marcoagpinto> :p
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Activate multi-core
marcoagpinto
What, exactly, takes 18-19 hours?I am also using my dual-core Celeron (netbook) but it takes around 18-19 hours.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Activate multi-core
Good trick !firace wrote:Another proven way, which I sometimes use, is simply launching several instances of your executable, each doing separate portions of the job. The processes will nicely spread over all cores. But of course this would only work for relatively simple things.
I call it the lazy and poor man's approach to parallel processing
There are 2 methods to program bugless.
But only the third works fine.
Win10, Pb x64 5.71 LTS
But only the third works fine.
Win10, Pb x64 5.71 LTS
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: Activate multi-core
Well, I have to run simulations in possible scenarios.IdeasVacuum wrote:marcoagpintoWhat, exactly, takes 18-19 hours?I am also using my dual-core Celeron (netbook) but it takes around 18-19 hours.
121 simulations for each scenario.
Since it eats all 8 GB RAM, I divided it in three: 40 + 40 + 41.
I can only use mum's laptop when she is not there... once or twice a day.
My dual-core Celeron netbook takes 18-19 hours for each series and I leave it on most of the time to advance.
Re: Activate multi-core
perhaps someone with experience in cloud computing could give advice?
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Activate multi-core
...still do not know what you are doing in detail, so really impossible to help.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Activate multi-core
have a look at this post by MichaelW http://www.freebasic.net/forum/viewtopi ... 46#p205146
it's about controlling which cores are used by a thread, it's not in PB but I hope it helps.
it's about controlling which cores are used by a thread, it's not in PB but I hope it helps.
Re: Activate multi-core
It works on some languages, not in PB.marcoagpinto wrote:why can't it work out of the box?
What you need is only to write code using threads, that will lead to 100% usage of all CPU cores.
If it is hard for you to write multhithreaded code, you can do multithreading by another crude way -- running several executables simultaneously (they will run on different cores, you can use also tools like Process Hacker to easily change affinity mask of those executables).
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: Activate multi-core
On Windows, the function to assign a thread to a specific CPU/core is SetProcessAffinityMask().
-> https://msdn.microsoft.com/en-us/librar ... s.85).aspx
If it could work "out of the box", the entire parallel process branch in computer science wouldn't exist.
The first question is: is it even possible to run your code multi-threaded?
You'd have to give us more information.
__________________________________________________
URL tags added
26.04.2017
RSBasic
-> https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Because it is impossible. Your code must specifically be designed to be able to leverage multiple cores.marcoagpinto wrote:why can't it work out of the box?
If it could work "out of the box", the entire parallel process branch in computer science wouldn't exist.
The first question is: is it even possible to run your code multi-threaded?
You'd have to give us more information.
This is exactly how it is often done when the code has not been designed to work with multiple threads, so no problem being "lazy" here.Another proven way, which I sometimes use, is simply launching several instances of your executable, each doing separate portions of the job.
__________________________________________________
URL tags added
26.04.2017
RSBasic
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: Activate multi-core
Guys,
Basically I want to do something similar to:
[17:41] <marcoagpinto> red=0
[17:41] <marcoagpinto> for f=1 to 100
[17:41] <marcoagpinto> red+1
[17:41] <marcoagpinto> next f
[17:41] <marcoagpinto> -------
[17:41] <marcoagpinto> blue=0
[17:42] <marcoagpinto> for f=1 to 100
[17:42] <marcoagpinto> blue+1
[17:42] <marcoagpinto> next f
but using more complex variables such as structured arrays and strings.
EDIT: The lines above are from IRC chat. I tried also to get help there.
Basically I want to do something similar to:
[17:41] <marcoagpinto> red=0
[17:41] <marcoagpinto> for f=1 to 100
[17:41] <marcoagpinto> red+1
[17:41] <marcoagpinto> next f
[17:41] <marcoagpinto> -------
[17:41] <marcoagpinto> blue=0
[17:42] <marcoagpinto> for f=1 to 100
[17:42] <marcoagpinto> blue+1
[17:42] <marcoagpinto> next f
but using more complex variables such as structured arrays and strings.
EDIT: The lines above are from IRC chat. I tried also to get help there.