View previous topic :: View next topic |
Author |
Message |
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sat Nov 16, 2024 9:13 pm Post subject: parallalization and taskset |
|
|
is it possible have parallalization with taskset?
Code: |
m@localhost ~/Desktop/bitmap $ time taskset -c 1 ./desc && time taskset -c 2 ./desc && time taskset -c 3 ./desc && time taskset -c 4 ./desc
real 0m0.019s
user 0m0.013s
sys 0m0.006s
real 0m0.014s
user 0m0.013s
sys 0m0.001s
real 0m0.012s
user 0m0.011s
sys 0m0.001s
real 0m0.012s
user 0m0.012s
sys 0m0.000s
|
four instance of the program are executed simultaniously with save time? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22672
|
Posted: Sat Nov 16, 2024 11:32 pm Post subject: |
|
|
Why are you using taskset at all? If you want four instances, run four instances: Code: | for a in {0..3}; do ./desc & done; wait | Let the scheduler sort out where to run them. |
|
Back to top |
|
|
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sun Nov 17, 2024 11:07 am Post subject: |
|
|
With your method i have no guarante its parallelized in different core with taskset instead i have guarante. Or not? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22672
|
Posted: Sun Nov 17, 2024 3:48 pm Post subject: |
|
|
With taskset, you guarantee that each task either runs on the specified core or, if that core is not available, does not run at all. Without taskset, you let the scheduler pick which core to run each one on, and it will try to run as many things in parallel as you have cores available. Why do you think you need to force particular core assignments for particular processes? |
|
Back to top |
|
|
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sun Nov 17, 2024 4:45 pm Post subject: |
|
|
Are you sure that its sufficient & for have parallalization?
I read somewhere that its not sure this |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22672
|
Posted: Sun Nov 17, 2024 5:09 pm Post subject: |
|
|
& tells the shell to place the command in the background. Where did you read that this would not work? Have you tried the command I gave you? What went wrong? |
|
Back to top |
|
|
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sun Nov 17, 2024 6:31 pm Post subject: |
|
|
Im under c++ and that command no works, i use a series of system(./desc &) or something similar is it correct? Will it works? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22672
|
Posted: Sun Nov 17, 2024 7:39 pm Post subject: |
|
|
If you are using system from C++, why is your opening post expressed as shell? Rather than asking if something will work after I told you it will, why not try it and report whether it works?
I think you should provide a Minimum Reproducible Example demonstrating your problem. |
|
Back to top |
|
|
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sun Nov 17, 2024 7:48 pm Post subject: |
|
|
Indeed i was wrong im tryng in shell before c++, dont you think its the same? I dont make c++ code yet, do you think system(./desc &) will work and save time with parallelization i wish? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22672
|
Posted: Sun Nov 17, 2024 8:00 pm Post subject: |
|
|
I gave you a loop that should work. I later reiterated that I expect it to work. Yes, system should work fine, since, according to its manual page, that is delegating back to the shell, which is almost always the wrong thing to do in a C++ program. If you need further help, please demonstrate a specific problem. |
|
Back to top |
|
|
Marcofras n00b
Joined: 29 May 2023 Posts: 20
|
Posted: Sun Nov 17, 2024 8:31 pm Post subject: |
|
|
I will make the code c++ in days.
Why its wrong thing which is the correct form? Maybe thread or something similar? |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1701 Location: South America
|
Posted: Sun Nov 17, 2024 8:45 pm Post subject: |
|
|
Because a C++ program can do things like spawning processes by using the libc directly (or through some convenience library) instead of invoking the shell. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
Last edited by GDH-gentoo on Sun Nov 17, 2024 8:46 pm; edited 1 time in total |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3433
|
Posted: Sun Nov 17, 2024 8:45 pm Post subject: |
|
|
Marcofras, you're bouncing around too much. Pause for a minute and focus.
What are you _actually_ trying to do? _________________ Make Computing Fun Again |
|
Back to top |
|
|
|