[Bf-committers] SSE/AVX in cloth simulator

darkdefende at gmail.com darkdefende at gmail.com
Thu Dec 19 16:45:44 CET 2019


On Thu, Dec 19, 2019 at 01:55:13PM +0100, Mariusz Pluciński wrote:
> 1. Is what I noticed correct? Does Blender not have support for SSE/AVX in
> cloth simulator, or in general, in mathematical functions of blenlib?
>
We support it in the way that we leave it up to the compiler to do this
for us. Only certain parts of blender have been handwritten to
explicitly use specific CPU instructions.

> 2. I tried explicitly enabling auto vectorization in GCC, but it didn't
> change much. Is that normal? If not, which flags should be used?
>
The biggest issue with the current cloth sim is that it is using a very
strictly single threaded way of computing the cloth simulation.

Other programs and games use newer methods that are multi threaded and
can in some cases even be run on the GPU with large speed gains.

Or method while slow, is in terms of simulation accuracy not bad. In some
cases it is even better than some of the multi threaded methods. But
I don't really think many people care about simulation accuracy. They
just want nice looking simulations.

> 3. If there's no other way, I may be ready to try to rewrite critical parts
> of the simulator for SSE/AVX. In such case, could you give me a guideline
> on how to do it correctly (with ultimate merge into master in mind)? I
> noticed Cycles code has #ifdefs for SSE support inside its mathematical
> functions, would similar approach be useful here?
>

While I think you might be able to speed this up a bit by doing this, I
don't think this is the way to go. The bottle neck will still be the
inherent single threaded nature of our cloth solver.

I've been looking into integrating one of the newer multi threaded cloth
solvers. Namely https://www.cs.utah.edu/~ladislav/liu13fast/liu13fast.html
and a modified version that builds on top of the previous paper:
https://www.researchgate.net/publication/315916604_A_fast_mass_spring_model_solver_for_high-resolution_elastic_objects

For the first paper (Fast Simulation of Mass-Spring Systems), I've
noticed that quite a few people has implemented this and uploaded the
code under the MIT licence to github:
https://github.com/sam007961/FastMassSpring

I were planning to see if it is able to simulate cloth fast and with
nice results.

If you want to help me with this I would be really happy.

There are of course other papers about cloth solvers like this one:
https://www.youtube.com/watch?v=eGtB0VXJsuI
(paper is linked in the video description)

However, those have a different data structure for the cloth sim than
what we currently have in blender, so it would be a much bigger rewrite.

The previous papers I have linked have nearly the same data structure
as the current method we have in blender. So integration should in
theory be easier.

Regards,
Sebastian Parborg


More information about the Bf-committers mailing list