You are viewing the course site for a past offering of this course. The current offering may be found here.
Lecture 19: Intro to Physical Simulation (5)
ericyche

I am curious if we can multithread this work. It seems like one particle has an effect on other particles.

Staffjamesfong1

@ericyche Interesting idea. Yes: multithreading is very relevant for particle simulations. A common approach is to assume that particles only interact with a local neighborhood of nearby particles. This allows you to simulate regions of space in parallel, and only synchronize when particles physically cross between thread boundaries.

Check out CS267 if you are interested in learning more about parallel computing.

geos98

@ericyche, I believe GPU, which is commonly used for physical simulation, is basically a device that allows you to do all computation in parallel.

Since you have many cores for GPU and individual computation (i.e., one step of simulation) might not be very complicated, I think maybe you don't really need threading? At the end of the day, context switching is not that cheap.

red-robby

In addition to the use of parallelism, the choice of data structure is very important. This web page provides a good basic introduction to various approaches and their trade offs: https://www.particleincell.com/2012/particle-data-structure/

sharhar

@geos98, GPUs are definitely used for particle simulations because they can do many things in parallel. However, unlike a CPU, the GPU can really only do things in parallel if the operations are "similar" enough. in practice, this is because the GPU has massive SIMD instructions that processes like 32 numbers at once, meaning that it can do 32 parallel computations on each core since all the computations are identical, with the only difference being the input data. This works very well for particle simulations where at each time-step we need to calculate the exact same math equations millions of times with different inputs.

You must be enrolled in the course to comment