Lua :: How to write simple program that will load multiple CPUs?

后端 未结 6 574
猫巷女王i
猫巷女王i 2021-02-07 17:27

I haven\'t been able to write a program in Lua that will load more than one CPU. Since Lua supports the concept via coroutines, I believe it\'s achievable.

Reason for me

6条回答
  •  庸人自扰
    2021-02-07 18:08

    In addition to already suggested LuaLanes, llthreads and other stuff mentioned here, there is a simpler way.

    If you're on POSIX system, try doing it in old-fashioned way with posix.fork() (from luaposix). You know, split the task to batches, fork the same number of processes as the number of cores, crunch the numbers, collate results.

    Also, make sure that you're using LuaJIT 2 to get the max speed.

提交回复
热议问题