Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
parallalization and taskset
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sat Nov 16, 2024 9:13 pm    Post subject: parallalization and taskset Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22672

PostPosted: Sat Nov 16, 2024 11:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sun Nov 17, 2024 11:07 am    Post subject: Reply with quote

With your method i have no guarante its parallelized in different core with taskset instead i have guarante. Or not?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22672

PostPosted: Sun Nov 17, 2024 3:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sun Nov 17, 2024 4:45 pm    Post subject: Reply with quote

Are you sure that its sufficient & for have parallalization?
I read somewhere that its not sure this
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22672

PostPosted: Sun Nov 17, 2024 5:09 pm    Post subject: Reply with quote

& 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
View user's profile Send private message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sun Nov 17, 2024 6:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22672

PostPosted: Sun Nov 17, 2024 7:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sun Nov 17, 2024 7:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22672

PostPosted: Sun Nov 17, 2024 8:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Marcofras
n00b
n00b


Joined: 29 May 2023
Posts: 20

PostPosted: Sun Nov 17, 2024 8:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1701
Location: South America

PostPosted: Sun Nov 17, 2024 8:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3433

PostPosted: Sun Nov 17, 2024 8:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum