Improving Abort Functionality in VTK

Currently, the abort mechanism is designed to function only within a single thread when the abort flag is set by an observer of the progress event. This severely limits the usefulness of the functionality as evidenced by the fact that it is rarely used (which must be the case as it has many bugs that no one reports on). Our goal is to redesign how VTK algorithms are interrupted (aborted) in a way that is friendly to multi-threaded execution.

A more in-depth explanation of the design and an example are located here.

Please share your comments if you have any questions, concerns, and improvements about this design.

i support to improve abort functionality in VTK

Three years later, I’m carrying @Stephen_Crowell torch in order to provide a solution for this.

I’m afraid it may not be a nice as he would have hoped but here it is (read https://gitlab.kitware.com/vtk/vtk/-/work_items/18463 first) :

The current abort implementation is merely a CheckAbort being repeatedly called at high velocity in the filters. This is problematic because there is no way to call SetAbortExecute while the filter execute in a distributed way.

Applications however rely on the rank 0 sending progress events to track progress of filters, and executing code on rank 0 during a progress event is possible, which of course include calling SetAbortExecute.

So once rank 0 has the abort flag, how to transmit it to other ranks ?

Well, the idea is of course to send it from rank 0 to other ranks, but it is not VTK responsability to do that.

VTK is merely responsible to signal to applications that each rank is currently checking the abort flag.

So I will introduce a CheckAbortAndInvoke method, that will invoke a CheckAbort event and then check if the abort is set.

This is the first hurdle, but then, since application uses this event to trigger multiprocess communication, we end up needing to call CheckAbortAndInvoke the exact same number of time on each rank, which is an unreassonnable ask.

The solution is to use another signal, at the end of the request data implementation, which can be emitted easilly using CleanupAbortCheckEvent.

Application are now able to cleanup any multi process communication setup that they have been using during the CheckAbort event handling.

I was able to implement that in ParaView using MPI NoBlockSend/NoBlockReceive/Test/Cancel API : https://gitlab.kitware.com/paraview/paraview/-/merge_requests/7921

Of course, it means that any VTK user willing to get the same abort support also require to implement the communication, but I’m afraid this implementation is outside of the scope of vtkAlgorithm responsabilities.

I encourage you to try your change with Thread Sanitizer. As I recall, TSan had several warnings about multi-threaded access to those abort flags…