victorliu / S4

Stanford Stratified Structure Solver - Electromagnetic simulator for layered periodic structures
http://www.stanford.edu/group/fan/S4/
GNU General Public License v2.0
128 stars 149 forks source link

Multi-threading/Muti-processing #114

Closed michelgaglioni closed 6 months ago

michelgaglioni commented 6 months ago

Hello Everyone,

I've been running multiple simulations on S4 through multiple Linux terminals on Windows (through WSL). However, when I get to monitor my cores' usage, it seems that only specific cores are being used instead of all the available ones. For instance, of all the eight power cores and eight efficiency cores available, only three of them appear to be in use (I'm affirming that due to the temperature increase in the cores). My question is: is there an efficient way of multithreading or multiprocessing on S4? in other words: can I do something to force the simulations to run on all available cores?

PS: I'm using the LUA API, since, at least in my PC, it performs way faster than the Python one, even with Python multiprocessing.

WangL3i commented 5 months ago

Hello, michelgaglioni. I am having the same problem as you and it has been bothering me for a long time. May I ask how you solved it?

michelgaglioni commented 5 months ago

Hello WangL3i,

I haven't solved it, actually. Thing is: it seems that opening multiple terminal instances and running Lua codes on each one of them does use all of the available cores - just not in an evenly distributed way; in opposite (and I have no idea why), the Python multiprocessing functionality performs WAY worse than the Lua-based consoles. So my best advice is: if you need to run extensive, time-consuming simulations, do it on Lua; if you need the convenience of editing the codes in an IDE (VSCode, for instance) and your simulations do not demand extense processing, use Python instead (if you're not aware of that possibility, you can integrate VSCode and Ubuntu through WSL on Windows, if that's the operating system you're using; personally I've never tried to do that on Linux because I do not use it as a standard system, but I think that should be doable too). One more thing: for another unknown reason, Python seems to run the codes for RCWA simulations a little bit faster than Lua when it comes to increasing the number of Fourier components in the simulation; that's one thing that should also be considered when choosing between them.

Hope it helps! Feel free to make any further questions.

Sincerely,


MSc. Michel Gaglioni Rocha

PhD Student - Department of Electrical and Computer Engineering - Lab. of Telecommunications - Group of Photonics and Metamaterials (GMETA)

São Carlos School of Engineering - University of São Paulo

Mobile: +5517981973435


De: WangL3i @.> Enviado: 25 de março de 2024 10:42 Para: victorliu/S4 @.> Cc: Michel Gaglioni Rocha @.>; State change @.> Assunto: Re: [victorliu/S4] Multi-threading/Muti-processing (Issue #114)

Hello, michelgaglioni. I am having the same problem as you and it has been bothering me for a long time. May I ask how you solved it?

— Reply to this email directly, view it on GitHubhttps://github.com/victorliu/S4/issues/114#issuecomment-2018035832, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANYZBP7MWUHFJPMSQD6PEU3Y2ASVNAVCNFSM6AAAAABDRZ7CQOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJYGAZTKOBTGI. You are receiving this because you modified the open/close state.