digitalmars.D - Parallel : get cpu usage ?
- Larry (18/18) Dec 22 2013 The more I use D, the more I like it.
- Joakim (9/27) Dec 22 2013 I don't think there is a way to do this in D right now. Can you
- Philippe Sigaud (2/9) Dec 22 2013 Doesn't std.parallelism deal with this, with task, taskPool and
- larry (6/6) Dec 22 2013 Yes,
The more I use D, the more I like it. Is there a way to get cpu usage to dynamically set the parallel options ? E.g : I have a dual core, if cpu usage is superior than x, then blah. It would be interesting to : - to be able to set the execution logic based on the cpu capability - as a consequence of the latter, setting the nice value of the current thread dynamically. - As a consequence of both : to avoid the cpu to burn. Conclusion : So it would be useful to have a "std" way to set the nice of the pid, and get the cpu usage and eventually deciding on which core -obviously the least busy- the parallel will start on and then, eventually, deploy to. Did I miss a hidden functionality that already does this ? Thanks
Dec 22 2013
On Sunday, 22 December 2013 at 09:04:18 UTC, Larry wrote:The more I use D, the more I like it. Is there a way to get cpu usage to dynamically set the parallel options ? E.g : I have a dual core, if cpu usage is superior than x, then blah. It would be interesting to : - to be able to set the execution logic based on the cpu capability - as a consequence of the latter, setting the nice value of the current thread dynamically. - As a consequence of both : to avoid the cpu to burn. Conclusion : So it would be useful to have a "std" way to set the nice of the pid, and get the cpu usage and eventually deciding on which core -obviously the least busy- the parallel will start on and then, eventually, deploy to. Did I miss a hidden functionality that already does this ? ThanksI don't think there is a way to do this in D right now. Can you do it in C? If so, you can always call the necessary functions yourself. For example, phobos calls sysconf on linux to figure out the number of CPUs: https://github.com/D-Programming-Language/phobos/blob/19bed560cd7f85f46fe4c2db787cf44ed6439223/std/parallelism.d#L141 If there are other native APIs to do what you want from C, you can always call them from D too, but I don't believe there is already a std way to do this.
Dec 22 2013
Is there a way to get cpu usage to dynamically set the parallel options ?Conclusion : So it would be useful to have a "std" way to set the nice of the pid, and get the cpu usage and eventually deciding on which core -obviously the least busy- the parallel will start on and then, eventually, deploy to. Did I miss a hidden functionality that already does this ? ThanksDoesn't std.parallelism deal with this, with task, taskPool and parallel foreach?
Dec 22 2013
Yes, The Queue seems to manage that. I will use Python to check all the processes and see if one is going wild to nice it. Solved I think :) Thanks
Dec 22 2013