ParaView/ParaView And Mesa 3D: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
Line 66: Line 66:

== Using the llvmpipe and swr drivers at runtime ==
== Using the llvmpipe and swr drivers at runtime ==
Using the above configuration, the resuling mesa will have a (and possibly containing only the softpipe, llvmpipe, and swr drivers, with llvmpipe always being the default.  To change drivers at runtime, use the GALLIUM_DRIVER environment variable, setting it to either softpipe, llvmpipe, or swr:

= A comparison of OSMesa Gallium llvmpipe, OSMesa classic and, GPU Accelerated Rendering Performance =
= A comparison of OSMesa Gallium llvmpipe, OSMesa classic and, GPU Accelerated Rendering Performance =

Revision as of 18:12, 21 November 2016

Read this first

ParaView and VTK make use of OpenGL for rendering. Most operating systems provide a default OpenGL library. If you're running a Windows or Mac OSX operating system, this page is not for you. On Windows download and install the latest drivers for your system's graphics hardware. On Apple Mac OSX just use the default OS provided drivers. On Linux the default OpenGL drivers are typically provided by Mesa. Mesa is an open source OpenGL implementation that supports a wide range of graphics hardware each with it's own back-end called a renderer. Mesa also provides several software based renderers for use on systems without graphics hardware. If you're running a Linux OS on a system without graphics hardware then this page is for you.

Mesa for your GPU

Before getting into details of Mesa graphics hardware drivers, a disclaimer. If you have graphics hardware Mesa is not your best option. To get the best performance from your graphics card you'll need to install the vendor provided driver. Vendor provided OpenGL drivers are typically much faster of a much higher quality than Mesa's which can be quite buggy. Many distros now provide thridparty non-opensource source drivers through specialized package repositories. The details of installing vendor provided drivers in beyond the scope of this document. Please consult distro and/or vendor specific documentation.

If you're running a Linux OS with X11 and graphics hardware and have not installed any OpenGL libraries you're probably already using Mesa! Note that the windowing system, in this case X11, is required for on-screen interactive rendering. On Linux systems the easiest way to install Mesa is through your distro's package manager. Most distros also provide packages for Mesa's software based renderers as well. Unfortunately, some OpenGL features may be disabled by your distro's package maintainers to avoid patent or other licensing restrictions. If you find that this is the case then you'll likely want to build Mesa from source. Given the depth and breadth of the universe of hardware that Mesa supports, building Mesa for use on systems with graphics hardware is beyond the scope of this article. Please consult the Mesa documentation directly.

Configuring VTK and ParaView with X11 or hardware accelerated Mesa only requires pointing VTK to the desired Mesa install and ensuring that LD_LIBRARY_PATH includes your Mesa install.

OSMesa, Mesa without graphics hardware

OpenGL applications require some mechanism to create and manage a rendering context. On Linux and Unix systems using X11 and GPUs, this is typically done with the GLX library (libGL) provided by a vendor supplied graphics driver. For systems without graphics cards or powerful GPUs, the Mesa 3D package provides the OSMesa library (Off-Screen Mesa) and several CPU based renderers providing OpenGL drivers. Here we will discuss 2 of OSMesa's renderers: llvmpipe and swr. Both Mesa's llvmpipe and swr renderers are some of the exciting recent developments in Mesa. They are threaded software based OpenGL drivers which use LLVM and clang for JIT compilation of GLSL shaders. The llvmpipe driver for OSMesa was added in the 2013 9.2.0 release and the swr driver in the 2016 12.0.0 release. The llvmpipe driver is available on most of Mesa's supported platforms while the swr driver is a much more highly optimized and threaded driver only available for newer x86_64 processors with AVX or AVX2 capability. They are currently the best software based OpenGL option for ParaView and VTK in terms of both OpenGL features and performance (swr on Intel CPUs and llvmpipe on all others). OSMesa classic swrast no longer supports the necessary OpenGL features required by newer VTK and ParaView versions. Mesa's softpipe, the single threaded reference software rederer, may still be useful in the case of a bug in the llvmpipe or swr sreivers and provides a stable fallback option. When enabling llvmpipe, you will get softpipe for free.

Installing Mesa llvmpipe and swr drivers

The Mesa 13.0.1 OSMesa state-tracker with either llvmpipe or swr driver is the preferred CPU based renderer for ParaView and VTK. The following shows how to configure Mesa with a system installed LLVM. Our strategy is to configure Mesa with the options necessary to provide a minimal build with only OSMesa and it's associated drivers. This greatly simplifies the build as many of the other drivers/renderers depend on X11 or other libraries. The following set of options are from Mesa v13.0.1 release; older or newer releases may require slightly different options. Consult ./configure --help for additional details.

<source lang="bash">

  1. !/bin/bash

./configure \

 --prefix=/path/to/install/mesa                    \
 --enable-opengl --disable-gles1 --disable-gles2   \
 --disable-va --disable-xvmc --disable-vdpau       \
 --enable-shared-glapi                             \
 --disable-texture-float                           \
 --enable-gallium-llvm --enable-llvm-shared-libs   \
 --with-gallium-drivers=swrast,swr                 \
 --disable-dri --with-dri-drivers=                 \
 --disable-egl --with-egl-platforms= --disable-gbm \
 --disable-glx                                     \
 --disable-osmesa --enable-gallium-osmesa

make -j8 make install </source>

Some explanation of these options:

--enable-opengl --disable-gles1 --disable-gles2
Specify which APIs to enable. Mesa will try to enable OpenGL, OpenGL ES, and OpenGL ES2 by default. We only need "normal OpenGL" so we're explicitly disabling the others.
--disable-va --disable-xvmc --disable-vdpau
Mesa comes with several different state trackers on by default. We don't need any of them so we explicitly disable them.
This option specifically deals with OpenGL floating point textures. There is a questionable legal and patent issue with enabling them so only do so if you are either unaffected by this in your country / juristion or are willing to deal with the associated legal issues. See for more detail.
--enable-gallium-llvm --enable-llvm-shared-libs
LLVM is needed for much of the desired infrastructure for both the llvmpipe and swr drivers. If ./configure is having trouble locating an appropriate LLVM installation, you may need to also pass the --with-llvm-prefix=/path/to/llvm/installation option.
The swrast driver enables the softpipe render and, if llvm is enabled (which it is in the previous option), then the llvmpipe driver as well. The swr driver is the optimized Intel-specific multithreaded driver. Leave this out if you are on an older CPU without AVX capability or on a non-Intel architecture.
--disable-dri --with-dri-drivers=
Since we are using the Mesa's newer "galllium" driver infrastructure then we can explicitly disable the older DRI infrastructure
--disable-egl --with-egl-platforms= --disable-gbm
We're only intrested in OSMesa so we can drop the unnecessary EGL context creation
Again, only OSMesa so no need for GLX.
  • If you want to ALSO build to have GLX with the softpipe, llvmpipe, and swr drivers for an X server in addition to, then change this to --enable-glx.
--disable-osmesa --enable-gallium-osmesa
Disable the older "classic" OSMesa in favor of the newer "gallium" OSMesa

Using the llvmpipe and swr drivers at runtime

Using the above configuration, the resuling mesa will have a (and possibly containing only the softpipe, llvmpipe, and swr drivers, with llvmpipe always being the default. To change drivers at runtime, use the GALLIUM_DRIVER environment variable, setting it to either softpipe, llvmpipe, or swr:

A comparison of OSMesa Gallium llvmpipe, OSMesa classic and, GPU Accelerated Rendering Performance

The following chart shows the run time of VTK's Rendering ctests with OSMesa classic, Gallium llvmpipe OSMesa state-tracker, and an ATI Radeon HD 7870. The CPU on the test sytsem is a 4 core(8 thread) Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz. The ATI driver used is AMD Catalyst 13.11-beta6. Run times were obtained by running each ctest twice consecutively discarding the first time. Tests that took less than 1 second were discarded, as were tests that failed on any one of the renderers. Note results are reported in cases where Classic OSMesa doesn't provide all the extensions, but Gallium llvmpipe does. For example classic OSMesa doesn't provide render buffer float. In these cases the run time reported for the classic OSMesa is ~0.

The results show that Gallium llvmpipe OSMesa state tracker is quite a bit better across the board and supports more rendering algorithms than OSMesa classic. This especially so for GPU accelerated volume rendering.


Configuring ParaView for use with OSMesa

Configure ParaView as described on ParaView:Build And Install. The only cmake variables that need to be updated are:

<source lang="bash">

  1. !/bin/bash

cmake \


make -j32 make -j32 install </source>

The rest on the configure and build process for ParaView remains as described on ParaView:Build And Install. Note that all of these build options with the exception of PARAVIEW_BUILD_QT_GUI are VTK options, thus this also describes how to configure VTK without ParaView.

libGLU is no longer packaged as part of Mesa (since early 2012, approximately Mesa-8 [(Mesa-dev post)]). As such, if it does not exist on your system, it can be separately downloaded and installed from the [libGLU ftp].

MPI-Parallel rendering with OSMesa Gallium llvmpipe state-tracker

When running ParaView in parallel with MPI one should consider how best to set the number of rendering threads used by the llvmpipe renderer. The number of rendering threads may be set using the LP_NUM_THREADS environment variable. Our parallel benchmarks of the surface LIC painter on one NERSC Edison compute node showed that the best performance was achieved when the total number of rendering threads per node was equal to the number of available hyper threads. As of Mesa 9.2.2 only the fragment pipeline is threaded. This has some important implications for parallel rendering of large datasets. First, it's important to use a mix of MPI parallelism as well as rendering threads because MPI parallelism is the only option for speeding up vertex operations. Keep in mind that generally speaking with large datasets the vertex pipeline will have more work to do than the fragment pipeline. Also, note that only algorithms that have heavy fragment shader use, such as GPU accelerated volume rendering, surface LIC, depth peeling, etc, will see a substantial benefits when using large numbers of threads. Fixed-function algorithms will not generally see the same benefit. Finally note that Mesa has a hard coded compile time limit on the number of threads set by the LP_MAX_THREADS macro, which in v9.2.2 is 16 threads.

Fig 1a: Surface LIC benchmark 1 MPI process with between 1 and 16 rendering threads. The plot shows that vertex operations, shown in teal, aren't threaded, but account for roughly 1/2 of the serial rendering time. The other colors represent fragment operations that benefit from additional rendering threads.
Fig 1b: Surface LIC benchmark with between 1 and 16 MPI processes and 16 rendering threads. The plot shows that MPI parallelism can be used to speedup vertex operations. Note that using more rendering threads than the number of hyperthreads available on the node slows down the fragment operations.

Can ParaView be built with X11/GPU accelerated OpenGL and OSMesa in the same build?

No, this is not currently possible due to library symbol conflicts. You need to choose one or the other for each build. Note that it is possible to use OSMesa rendering in the server and hardware accelerated OpenGL in the client, by having two builds. In this scenario, the client configured for X11/GPU accelerated OpenGL, and the second for server configured to use OSMesa OpenGL. You'll need to run in client-server mode.

Link to the old page

I'd like to remove this link. ParaView/ParaView_And_Mesa_3D_tmp