-
Notifications
You must be signed in to change notification settings - Fork 15k
[OpenMP] Fix td_tdg_task_id underflow when taskloop and taskgraph #150877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
72f5101 to
c53fcbe
Compare
|
What is the purpose of the decrement? |
Currently, when taskloop construct is invoked, clang generates a runtime call to The PR is still in Draft because this solution does not fit cases where multiple taskgraphs are been recorded at the same time. I want to move the @jprotze Do you have any suggestions? |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
Even with a localized counter as implemented with your latest commit, I think this decrement can be problematic. Is it really important to avoid spurious holes in the numbering of task IDs? As I understand, this is just used for accessing the A bigger issue is, that the accesses to the |
Yes, the decrement is bit of a haky solution. The problem is that the Regarding the I'll also take a look at the |
|
I think, the number of places where you iterate over all records is limited. In these places, you could simply check for |
81ef84f to
8c5b124
Compare
Thank you for the feedback and sorry for the delayed response. @jprotze, what are your thoughts? |
This patch addresses an issue where the td_tdg_task_id could underflow, leading to a negative task ID, when a taskloop region was encountered before a taskgraph clause. This change allows surious holes in the record_map.
Delayed allocation of successors in kmp_node until the array is needed, removing the small allocation when a taskgraph node is created or resized.
8c5b124 to
bf1f0df
Compare
|
The I think there are two options:
|
|
Another issue, not directly connected to this PR: I think, the implementation of |
Yes, you're right. I agree that locking all read/write interactions with record_map would be too expensive. Two possible solutions come to mind:
@jprotze any thoughts? |
|
Right, I missed, that record_map is essentially of type Another possible approach would be to use a customized vector which allocates |
f76881e to
b151a84
Compare
I have pushed a WIP commit with the changes discussed. However, a data race occurs when thread A reallocates blocks (the array of @jprotze, do you know what might be causing this? |
My bad, the problem was that thread B was holding the freed |
Add pointer to node represeting the task in the TDG, the way avoids locking access to record_map every time a node need to be accessed.
Replaced the fixed-size array for TDG successors with kmp_node_vector, a custom dynamic vector of kmp_node_info to TDG nodes. This change aims to mitigate data races during vector resizing by using a block-based allocation strategy.
b151a84 to
32edeb6
Compare
As discussed, the latest change implements a vector-like abstraction for nodes to allow resizing without modifying the addresses of existing nodes. This aims to resolve the thread safety issues. |
This patch addresses an issue where the
td_tdg_task_idcould underflow, leading to a negative task ID, when ataskloopregion was encountered before a taskgraph clause.Previously,
td_tdg_task_idwas decremented unconditionally within a taskloop, even if that taskloop was not part of an active taskgraph. This caused problems in scenarios like the following:EDIT(18/09/2025):
This implementation: