# Improving Abort Functionality in VTK

**URL:** https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813
**Category:** Development
**Tags:** proposal
**Created:** [February 10, 2022, 10:24pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813 "2022-02-10T22:24:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Stephen\_Crowell](https://discourse.vtk.org/user_avatar/discourse.vtk.org/stephen_crowell/32/4675_2.png) [@Stephen\_Crowell](https://discourse.vtk.org/u/Stephen_Crowell)
#### Post date: [February 10, 2022, 10:24pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/1 "2022-02-10T22:24:49Z")

</div>

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](https://gitlab.kitware.com/vtk/vtk/-/issues/18463).

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

---

<div class="post-metadata">

### Author: ![tong\_yang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tong_yang/32/6355_2.png) [@tong\_yang](https://discourse.vtk.org/u/tong_yang)
#### Post date: [January 3, 2023, 7:29am UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/2 "2023-01-03T07:29:49Z")

</div>

i support to improve abort functionality in VTK

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [August 25, 2026, 1:13pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/3 "2026-08-25T13:13:35Z")

</div>

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](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](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.

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)
#### Post date: [August 25, 2026, 4:37pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/4 "2026-08-25T16:37:21Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [August 25, 2026, 5:26pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/5 "2026-08-25T17:26:16Z")

</div>

There is nothing about multhreaded computation in my post. Do you have a link ?

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)
#### Post date: [August 25, 2026, 8:57pm UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/6 "2026-08-25T20:57:59Z")

</div>

[https://gitlab.kitware.com/vtk/vtk/-/work\_items/20050](https://gitlab.kitware.com/vtk/vtk/-/work_items/20050)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [August 26, 2026, 8:36am UTC](https://discourse.vtk.org/t/improving-abort-functionality-in-vtk/7813/7 "2026-08-26T08:36:59Z")

</div>

Ha right, I’ve answered there but the new API should not be used in multithreaded context anyway.
