On some devices, we are observing a SEGFAULT crash in BenchmarkInSitu
when the program exits. This is likely because the benchmark creates
DataSet variables that are constructed before VTK-m is
initialized and are therefore destroyed after VTK-m (and its devices)
are finalized. The crash happens when the
DataSet attempts to free the
memory on the device that it allocated, but the device is no longer
there to be deleted.
Fix the problem by wrapping these global variables as static variables in functions. This will defer the construction of the global variables to when the function is called. C++ specifies that global objects are destroyed in the reverse order in which they are constructed. Thus, if we defer the construction of the benchmark's objects until after the construction of internal device objects, the data will be destroyed before the device is finalized.
Fixes #712 (closed)