I was wondering how to multithread things
For example, we have 8 grids where each grid have an array of 32*32 elemnts (in total 8192 iterations). Lets say that this grids do not share any information, so they selfcontained objects. I need to update each grid every frame and loop over every (or maybe not) element and do something with it.
I came up with this:
https://github.com/MultiPain/Gideros_examples/tree/master/MultithreadingSo, the question: is it correct? Or there is a nicer way?)
For me it seems correct.
16 improvised grids of [64x64] size: 65536 iterations per frame
No threads: ~0.025 seconds full cycle (40 fps)
Threads: ~0.0045 seconds full cycle (60 fps)
32 "grid" [128x128]: 524288 iterations
No threads: ~0.18 seconds full cycle (5 fps)
Threads: ~0.016 seconds full cycle (60 fps)
Specs: i7-2600k 3.4GHz (8 logical cores, 8 threads)
Comments
So...thread can only do some basic operations.
i7-2600k 8 cores - OK
i7-8600 12 cores - OK