Blender and OpenMP, how much is actually multi-threaded?

This is a Development general question, I recall a couple of years ago you saw this and that is running on OpenMP. Contemporary development on Mantaflow you can see OpenMP mentioned.

I also recall, multi-threading with vanilla code wasn’t that super straigh-forward back in the days, that’s the first time I ever heard of OpenMP as an solution.

The reason why is that I just casually browse around, and ended up check out openmp.org and found this blog-post that peaked my interest.

In the past decades, we see that the increase in CPU speed is slowing down and the problems that we want to solve become more complex. With the advancement of the GPU technology, utilizing the computing power of GPU becomes a promising approach. This presents a challenge to the programming model as the architecture is no longer homogeneous. Programmers may not want to deal with different ISA (Instruction Set Architecture) in a single application if they want to offload the compute intense part of the application to the GPU or other devices. A programming model that makes the underneath hardware transparent and provides a high level of usability is needed.

It’s a bit NVIDIA centric in the article, I don’t know how AMD card works on this level. Also I suspect not all NVIDIA cards has that POWER processor? wasn’t that a big deal with Pascal or Maxwell?

Does anybody know of a page on blender.org where there’s an actual list of which libraries that are used to compile blender? and also what version? Otherwise one might wanna make that, could be neat to know. Exactly which Bullet Physics version is used, and ditto with OpenMP.

I don’t know coding on this C level, but wouldn’t it be really compelling to try and use OpenMP where ever possible? To get the multi-threading without much knowledge of coding it vanilla in C?

Also the benefit would come in later, when more GPU support is added to OpenMP. You could try and offload some parts of the code to GPU and get better performance if there’s a supported GPU.

I kinda get that this is not really for rendering engines like Cycles, there it’s smarted to go straight down closer to the metal. So you have C code for CPU, then CUDA/NVIDIA and OpenCL/AMD.

I wonder maybe if sculpt, paint could benefit from OpenMP, obviously simulations have benefited from being multi-threaded.

Anyways just a casual development question about OpenMP and Blender, if anyone have deeper knowledge and time to try and explain how much OpenMP is used in Blender and what version, I would be thankful.

// Martin

1 Like

I would love to see this in the “Blender and CG Discussions” subforum instead, tbh !
This is a very interesting question, but I believe it might get overlooked in here.

If I recall correctly, multires (and sculpting in general?) are also multithreaded. Might be wrong though!

Multi threaded programming is a can of worms

If you dont know what you are doing its very easy to slow down your code because there are many gotchas. Technically speaking the more threads you use the slower your code will become , especially when you exceed the amount of hardware threads per core (with hyperthreading they are 2 per core)

CPU speed is slowing down because GPUs have become insanely faster. It’s no secret that when it comes to the driving force behind computer evolution the games have been the elephant in the room for over 3 decades now. The complexity of 3d graphics demands a great deal of parallelism that is simply not possible with CPU. Becuase at best a CPU has 32 cores a GPU can easily have more than 100 times more cores.

OpenMP is also dead wrong in assuming that high level is the way forward for high performance code, OpenGL was high level and the industry is moving away from it in favor of Vulkan which extremely more low level. Pretty much every GPU API has become more and more low level which is what has boosted the popularity of high level solutions like game engines.

In general high level is a much better in coding than low level , cause its much easier to use and maintain.

But in case of performance, there is a good reason why C++ is still king. So no, if you don’t know exactly what you are doing your code will become slower and slower and slower.

By the way OpenMP is anything but high level and requires a very extensive understanding of CPUs at low level.

Blender makes extremely limited usages of the hardware abilities of CPUs and GPUs for the simple reason is that more you boost performance the more low level you have to get and the more complex the code becomes.

The good news is that things like CUDA are accesible by any languages so even Python can become blazing fast using these technologies.

In the end however it depends purely on the coder, no library will be making code faster if you don’t have a deep understanding of what on earth you doing with your code.

I doubt that Blender makes extensive usage of OpenMP for the simply fact that CPUs have completely been replaced by GPUs for any form of high performance coding. Which explains why they want so desperately move OpenMP to GPUs.

But to answer your initial question in order to have a high performance app you need to use as much CUDA and OpenCL as possible. Blender does not make that much heavy usage , its uses CUDA mainly for Cycles and its still stuck at very old opengl versions for viewport that blender devs try now to change with new real time render engine called Eevee for 2.8

1 Like