Page 1 of 1

LuaJIT/Love multicore

Posted: Wed Nov 10, 2021 10:34 pm
by GVovkiv
Just curious
How luajit/love handles cpus with severals cores and threads?
Does it's something that i should care about or luajit/love takes care of it?
Does luajit/love will properly use, for example, cpu with 8 cores? 16?
Or luajit/love will use, for example, 4 cores because it can't use more?(Like some really old games, etc)

Re: LuaJIT/Love multicore

Posted: Wed Nov 10, 2021 10:47 pm
by darkfrei
Don't use multithreading if you can make same without it :)
https://love2d.org/wiki/love.thread

Re: LuaJIT/Love multicore

Posted: Wed Nov 10, 2021 10:55 pm
by GVovkiv
darkfrei wrote: Wed Nov 10, 2021 10:47 pm Don't use multithreading if you can make same without it :)
https://love2d.org/wiki/love.thread
As far as i know, lua's threads how nothing in common with cpu's cores, so if that true, i don't mean that
I just curious about how luajit/love deals with cpu with several cores, nothing more
I was never (at the moment) situation, where i really need that
And because i don't know (at the moment) C and i don't know what "google" is, I just want to ask that from someone who know how that works
thats all

Re: LuaJIT/Love multicore

Posted: Wed Nov 10, 2021 11:10 pm
by grump
A single core is utilized by default. You can manually create threads with love.thread.newThread. They are real threads, scheduled by the OS across available cores. You can send data safely between threads over channels, but actual memory sharing is limited and there are none of the usual synchronization primitives available.

Re: LuaJIT/Love multicore

Posted: Wed Nov 10, 2021 11:12 pm
by GVovkiv
grump wrote: Wed Nov 10, 2021 11:10 pm A single core is utilized by default. You can manually create threads with love.thread.newThread. They are real threads, scheduled by the OS across available cores. You can send data safely between threads over channels, but actual memory sharing is limited and there are none of the usual synchronization primitives available.
Oh, so that REAL threads?
Huh, now that makes that more clear to me, thanks

Re: LuaJIT/Love multicore

Posted: Thu Nov 11, 2021 8:35 am
by zorg
Lua's "fake" threads are coroutines; löve's threads are real, and the only way to actually utilize multiple cpu cores. (well, the audio processing already happens on a separate thread anyway)

Re: LuaJIT/Love multicore

Posted: Thu Nov 11, 2021 9:33 am
by GVovkiv
zorg wrote: Thu Nov 11, 2021 8:35 am Lua's "fake" threads are coroutines; löve's threads are real, and the only way to actually utilize multiple cpu cores. (well, the audio processing already happens on a separate thread anyway)
Yeah, looks like i was confused with lua's coroutines and love's threads
Maybe it should be mentioned in https://www.love2d.org/wiki/love.thread with something like "love.thread can interact with cpu's cores/threads, do not confuse it with lua's coroutines" so someone like me will be never confused with it