Page MenuHome

Geometry Nodes: Parallelize Attribute Nodes
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on May 1 2021, 7:22 PM.
Subscribers
None
Tokens
"Love" token, awarded by DerivedC."100" token, awarded by shader."Love" token, awarded by gilberto_rodrigues."Burninate" token, awarded by Bit."Love" token, awarded by digim0nk."Love" token, awarded by billreynish."Love" token, awarded by charlie."Burninate" token, awarded by kursadk."Love" token, awarded by HEYPictures."Yellow Medal" token, awarded by Galagax."Love" token, awarded by kenziemac130.

Details

Summary

This patch will significantly speed up attribute node when multiple
threads are available, especially in linear situations when parallelism
cannot be achieved elsewhere.

I tested on a mesh with 4 million vertices on a Ryzen 3700x.
All tests were done on "plain" attributes where no conversion
is necessary and the data is stored in contiguous arrays.
The results are an average over ~30 runs.

NodeBefore (ms)After (ms)Speedup (x times faster)Notes
Align Rotation to Vector65170.89.19"Auto" pivot mode
Attribute Math60.110.15.95"Hyperbolic Sine" operation
Attribute Color Ramp55.211.14.97
Attribute Mix36.27.744.67Color data type
Attribute Sample Texture430924.66"Clouds" texture
Attribute Math10.62.604.12"Add" operation
Attribute Randomize38.712.03.21Vector data type
Attribute Vector Math58.818.53.18Refract operation
Attribute Map Range28.26.794.17Vector data type

The changes are not exhaustive, other nodes could still
be parallelized in the future. Also, it would be possible to further
optimize the grain size in parallel_for. I'd rather make sure that
it isn't too small though. I tested some different values, but also
relied on intuition-- increasing grain size for less complex operations
and vice versa.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-attribute-parallelize (branched from master)
Build Status
Buildable 14337
Build 14337: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.May 1 2021, 7:22 PM
Hans Goudey (HooglyBoogly) created this revision.
  • Remove commented changes
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
59

You can just use parallel_for without blender::.

source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
276

Your performance measurements for the Map Range node probably didn't improve, because you forgot to parallelize these loops.

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
243

Any reason for why you have the grain size in a separate variable here, but not in the other files?

This revision is now accepted and ready to land.May 3 2021, 10:17 AM
Hans Goudey (HooglyBoogly) marked 3 inline comments as done.May 3 2021, 2:56 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
276

Wow, oops!

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
243

No, I meant to remove that. It suggests that the grain size is more "permanent" than it actually should be,

This revision was automatically updated to reflect the committed changes.
Hans Goudey (HooglyBoogly) marked 2 inline comments as done.