summaryrefslogtreecommitdiff
path: root/openmp/runtime/src/kmp_tasking.cpp
AgeCommit message (Collapse)Author
2025-08-06[OFFLOAD][OPENMP] 6.0 compatible interop interface (#143491)Alex Duran
The following patch introduces a new interop interface implementation with the following characteristics: * It supports the new 6.0 prefer_type specification * It supports both explicit objects (from interop constructs) and implicit objects (from variant calls). * Implements a per-thread reuse mechanism for implicit objects to reduce overheads. * It provides a plugin interface that allows selecting the supported interop types, and managing all the backend related interop operations (init, sync, ...). * It enables cooperation with the OpenMP runtime to allow progress on OpenMP synchronizations. * It cleanups some vendor/fr_id mismatchs from the current query routines. * It supports extension to define interop callbacks for library cleanup.
2025-07-18[OpenMP] [NFC] Remove dead code: building task stack (#143589)Jonathan Peyton
This code hasn't been enabled since the first code changes were introduced. Remove the dead code.
2025-06-25[OpenMP] Fix various alignment issues (#142376)Rainer Orth
When running the `openmp` testsuite on 32-bit SPARC, several tests `FAIL` apparently randomly, but always with the same kind of error: ``` # error: command failed with exit status: -11 ``` The tests die with `SIGBUS`, as can be seen in `truss` output: ``` 26461/1: Incurred fault #5, FLTACCESS %pc = 0x00010EAC 26461/1: siginfo: SIGBUS BUS_ADRALN addr=0x0013D12C 26461/1: Received signal #10, SIGBUS [default] 26461/1: siginfo: SIGBUS BUS_ADRALN addr=0x0013D12C ``` i.e. the code is trying an unaligned access which cannot work on SPARC, a strict-alignment target which enforces natural alignment on access. This explains the apparent randomness of the failures: if the memory happens to be aligned appropriately, the tests work, but fail if not. A `Debug` build reveals much more: - `__kmp_alloc` currently aligns to `sizeof(void *)`, which isn't enough on strict-alignment targets when the data are accessed as types requiring larger alignment. Therefore, this patch increases `alignment` to `SizeQuant`. - 32-bit Solaris/sparc `libc` guarantees 8-byte alignment from `malloc`, so this patch adjusts `SizeQuant` to match. - There's a `SIGBUS` in ``` __kmpc_fork_teams (loc=0x112f8, argc=0, microtask=0x16cc8 <__omp_offloading_ffbc020a_4b1abe_main_l9_debug__.omp_outlined>) at openmp/runtime/src/kmp_csupport.cpp:573 573 *(kmp_int64 *)(&this_thr->th.th_teams_size) = 0L; ``` Casting to a pointer to a type requiring 64-bit alignment when that isn't guaranteed is wrong. Instead, this patch uses `memset` instead. - There's another `SIGBUS` in ``` 0xfef8cb9c in __kmp_taskloop_recur (loc=0x10cb8, gtid=0, task=0x23cd00, lb=0x23cd18, ub=0x23cd20, st=1, ub_glob=499, num_tasks=100, grainsize=5, extras=0, last_chunk=0, tc=500, num_t_min=20, codeptr_ra=0xfef8dbc8 <__kmpc_taskloop(ident_t*, int, kmp_task_t*, int, kmp_uint64*, kmp_uint64*, kmp_int64, int, int, kmp_uint64, void*)+240>, task_dup=0x0) at openmp/runtime/src/kmp_tasking.cpp:5147 5147 p->st = st; ``` `p->st` doesn't currently guarantee the 8-byte alignment required by `kmp_int64 st`. `p` is set in ``` __taskloop_params_t *p = (__taskloop_params_t *)new_task->shareds; ``` but `shareds_offset` is currently aligned to `sizeof(void *)` only. Increasing it to `sizeof(kmp_uint64)` to match its use fixes the `SIGBUS`. With these fixes I get clean `openmp` test results on 32-bit SPARC (both Solaris and Linux), with one unrelated exception. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
2025-04-25[OpenMP] Fix taskgraph dependency tracking, memory access, and ↵Josep Pinot
initialization (#136837) This commit resolves multiple issues in the OpenMP taskgraph implementation: - Fix a potential use of uninitialized is_taskgraph and tdg fields when a task is created outside of a taskgraph construct. - Fix use of task ID field when accessing the taskgraph’s record_map. - Fix resizing and copying of the successors array when its capacity is exceeded. Fixes memory management flaws, invalid memory accesses, and uninitialized data risks in taskgraph operations.
2025-04-24[NFC][OpenMP] Fix task record/replay comments (#137178)Josep Pinot
2025-03-21Revert "Update OpenMP runtime to adopt taskgraph clause from 6.0 Specs" ↵Josep Pinot
(#131571)
2025-03-14[OpenMP] Update OpenMP runtime to adopt taskgraph clause from 6.0 Specs ↵Josep Pinot
(#130751) Updating OpenMP runtime taskgraph support(record/replay mechanism): - Adds a `graph_reset` bit in `kmp_taskgraph_flags_t` to discard existing TDG records. - Switches from a strict index-based TDG ID/IDX to a more flexible integer-based, which can be any integer (e.g. hashed). - Adds helper functions like `__kmp_find_tdg`, `__kmp_alloc_tdg`, and `__kmp_free_tdg` to manage TDGs by their IDs. These changes pave the way for the integration of OpenMP taskgraph (spec 6.0). Taskgraphs are still recorded in an array with a lookup efficiency reduced to O(n), where n ≤ `__kmp_max_tdgs`. This can be optimized by moving the TDGs to a hashtable, making lookups more efficient. The provided helper routines facilitate easier future optimizations.
2025-03-12[OpenMP] [Taskgraph] Differentiating task ids from the taskgraph and from ↵Rémy Neveu
the debugger (#130660) This PR creates a new member for task data, which is used to identify the task in its taskgraph (when ompx taskgraph is enabled). It aims to remove the overloading of the td_task_id member, which was used both by the debugger and the taskgraph. This resulted in the identifier's non-unicity in the case of multiple taskgraphs. Co-authored-by: Rémy Neveu <rem2007@free.fr>
2025-02-27[OpenMP][OMPT][OMPD] Fix frame flags for OpenMP tool APIs (#114118)Joachim
In several cases the flags entries in ompt_frame_t are not initialized. According to @jdelsign the address provided as reenter and exit address is the canonical frame address (cfa) rather than a "framepointer". This patch makes sure that the flags entry is always initialized and changes the value from ompt_frame_framepointer to ompt_frame_cfa. The assertion in the tests makes sure that the flags are always set, when a tool (callback.h in this case) looks at the value. Fixes #89058
2024-10-17[OpenMP] Fix missing gtid argument in __kmp_print_tdg_dot function (#111986)Josep Pinot
This patch modifies the signature of the `__kmp_print_tdg_dot` function in `kmp_tasking.cpp` to include the global thread ID (gtid) as an argument. The gtid is now correctly passed to the function. - Updated the function declaration to accept the gtid parameter. - Modified all calls to `__kmp_print_tdg_dot` to pass the correct gtid value. This change addresses issues encountered when compiling with `OMPX_TASKGRAPH` enabled. No functional changes are expected beyond successful compilation.
2024-08-15[OpenMP] Miscellaneous small code improvements (#95603)Hansang Bae
Removes a few uninitialized variables, possible resource leaks, and redundant code.
2024-07-24[OpenMP][libomp] Fix tasking debug assert (#95823)Jonathan Peyton
The debug assert is meant to check that the index is a valid which means the runtime needs to check against the size of the array instead of the number of threads. A free()-ed thread put back in the thread pool may index into anywhere inside the task team's available array from 0 to tt_max_threads potentially. Fixes: #94260
2024-06-04[OpenMP][OMPT] Add missing callbacks for asynchronous target tasks (#93472)Joachim
- The first hidden-helper-thread did not trigger thread-begin - The "detaching" from a target-task when waiting for completion missed to call task-switch - Target tasks identified themself as explicit task Co-authored-by: Kaloyan Ignatov <kaloyan.ignatov@rwth-aachen.de>
2024-05-07[OpenMP] Fix task state and taskteams for serial teams (#86859)Jonathan Peyton
* Serial teams now use a stack (similar to dispatch buffers) * Serial teams always use `t_task_team[0]` as the task team and the second pointer is a next pointer for the stack `t_task_team[1]` is interpreted as a stack of task teams where each level is a nested level ``` inner serial team outer serial team [ t_task_team[0] ] -> (task_team) [ t_task_team[0] ] -> (task_team) [ next ] ----------------> [ next ] -> ... ``` * Remove the task state memo stack from thread structure. * Instead of a thread-private stack, use team structure to store th_task_state of the primary thread. When coming out of a parallel, restore the primary thread's task state. The new field in the team structure doesn't cause sizeof(team) to change and is in the cache line which is only read/written by the primary thread. Fixes: #50602 Fixes: #69368 Fixes: #69733 Fixes: #79416
2024-04-02[OpenMP] Fix nested parallel with tasking (#87309)Jonathan Peyton
When a nested parallel region ends, the runtime calls __kmp_join_call(). During this call, the primary thread of the nested parallel region will reset its tid (retval of omp_get_thread_num()) to what it was in the outer parallel region. A data race occurs with the current code when another worker thread from the nested inner parallel region tries to steal tasks from the primary thread's task deque. The worker thread reads the tid value directly from the primary thread's data structure and may read the wrong value. This change just uses the calculated victim_tid from execute_tasks() directly in the steal_task() routine rather than reading tid from the data structure. Fixes: #87307
2024-03-11[OpenMP] Fixup while loops to avoid bad NULL check (#83302)Jonathan Peyton
2023-11-09[OpenMP][SystemZ] Compile __kmpc_omp_task_begin_if0() with backchain (#71834)Ilya Leoshkevich
OpenMP runtime fails to build on SystemZ with clang with the following error message: LLVM ERROR: Unsupported stack frame traversal count __kmpc_omp_task_begin_if0() uses OMPT_GET_FRAME_ADDRESS(1), which delegates to __builtin_frame_address(), which in turn works with nonzero values on SystemZ only if backchain is in use. If backchain is not in use, the above error is emitted. Compile __kmpc_omp_task_begin_if0() with backchain. Note that this only resolves the build error. If at runtime its caller is compiled without backchain, __builtin_frame_address() will produce an incorrect value, but will not cause a crash. Since the value is relevant only for OMPT, this is acceptable.
2023-11-03Add openmp support to System z (#66081)Neale Ferguson
* openmp/README.rst - Add s390x to those platforms supported * openmp/libomptarget/plugins-nextgen/CMakeLists.txt - Add s390x subdirectory * openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt - Add s390x definitions * openmp/runtime/CMakeLists.txt - Add s390x to those platforms supported * openmp/runtime/cmake/LibompGetArchitecture.cmake - Define s390x ARCHITECTURE * openmp/runtime/cmake/LibompMicroTests.cmake - Add dependencies for System z (aka s390x) * openmp/runtime/cmake/LibompUtils.cmake - Add S390X to the mix * openmp/runtime/cmake/config-ix.cmake - Add s390x as a supported LIPOMP_ARCH * openmp/runtime/src/kmp_affinity.h - Define __NR_sched_[get|set]addinity for s390x * openmp/runtime/src/kmp_config.h.cmake - Define CACHE_LINE for s390x * openmp/runtime/src/kmp_os.h - Add KMP_ARCH_S390X to support checks * openmp/runtime/src/kmp_platform.h - Define KMP_ARCH_S390X * openmp/runtime/src/kmp_runtime.cpp - Generate code when KMP_ARCH_S390X is defined * openmp/runtime/src/kmp_tasking.cpp - Generate code when KMP_ARCH_S390X is defined * openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h - Define ITT_ARCH_S390X * openmp/runtime/src/z_Linux_asm.S - Instantiate __kmp_invoke_microtask for s390x * openmp/runtime/src/z_Linux_util.cpp - Generate code when KMP_ARCH_S390X is defined * openmp/runtime/test/ompt/callback.h - Define print_possible_return_addresses for s390x * openmp/runtime/tools/lib/Platform.pm - Return s390x as platform and host architecture * openmp/runtime/tools/lib/Uname.pm - Set hardware platform value for s390x
2023-09-12[OpenMP] Remove optimization skipping reduction struct initialization (#65697)Rodrigo Ceccato de Freitas
This commit removes an optimization that skips the initialization of the reduction struct if the number of threads in a team is 1. This optimization caused a bug with Hidden Helper Threads. When the task group is initially initialized by the master thread but a Hidden Helper Thread executes a target nowait region, it requires the reduction struct initialization to properly accumulate the data. This commit also adds a LIT test for issue #57522 to ensure that the issue is properly addressed and that the optimization removal does not introduce any regressions. Fixes: #57522
2023-06-19[OpenMP] Implement printing TDGs to dot filesAdrian Munera
This patch implements the "__kmp_print_tdg_dot" function, that prints a task dependency graph into a dot file containing the tasks and their dependencies. It is activated through a new environment variable "KMP_TDG_DOT" Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D150962
2023-05-23[OpenMP] Insert missing variable update inside loopJonathan Peyton
While loop within task priority code did not have necessary update of variable which could lead to hangs if two threads collided when both attempted to execute the compare_and_exchange. Fixes: https://github.com/llvm/llvm-project/issues/62867 Differential Revision: https://reviews.llvm.org/D151138
2023-05-15[OpenMP] Implement task record and replay mechanismChenle Yu
This patch implements the "task record and replay" mechanism. The idea is to be able to store tasks and their dependencies in the runtime so that we do not pay the cost of task creation and dependency resolution for future executions. The objective is to improve fine-grained task performance, both for those from "omp task" and "taskloop". The entry point of the recording phase is __kmpc_start_record_task, and the end of record is triggered by __kmpc_end_record_task. Tasks encapsulated between a record start and a record end are saved, meaning that the runtime stores their dependencies and structures, referred to as TDG, in order to replay them in subsequent executions. In these TDG replays, we start the execution by scheduling all root tasks (tasks that do not have input dependencies), and there will be no involvement of a hash table to track the dependencies, yet tasks do not need to be created again. At the beginning of __kmpc_start_record_task, we must check if a TDG has already been recorded. If yes, the function returns 0 and starts to replay the TDG by calling __kmp_exec_tdg; if not, we start to record, and the function returns 1. An integer uniquely identifies TDGs. Currently, this identifier needs to be incremented manually in the source code. Still, depending on how this feature would eventually be used in the library, the caller function must do it; also, the caller function needs to implement a mechanism to skip the associated region, according to the return value of __kmpc_start_record_task. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D146642
2023-05-01[OpenMP] Handle function calls from `libomp` to `libomptarget` correctlyShilei Tian
D132005 introduced function calls from `libomp` to `libomptarget` if offloading is enabled. However, the external function declaration may not always work. For example, it causes a link error on macOS. Currently it is guarded properly by a macro, but in order to get OpenMP target offloading working on macOS, it has to be handled correctly. This patch applies the same idea of how we support target memory extension by using function pointer indirect call for that function. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D149557
2023-05-01Revert "[OpenMP] Handle function calls from `libomp` to `libomptarget` ↵Shilei Tian
correctly" This reverts commit 479e335fc37c06767654141358ea076ac066de11. The assertion at `kmp_tasking.cpp(29)` is triggered.
2023-05-01[OpenMP] Handle function calls from `libomp` to `libomptarget` correctlyShilei Tian
D132005 introduced function calls from `libomp` to `libomptarget` if offloading is enabled. However, the external function declaration may not always work. For example, it causes a link error on macOS. Currently it is guarded properly by a macro, but in order to get OpenMP target offloading working on macOS, it has to be handled correctly. This patch applies the same idea of how we support target memory extension by using function pointer indirect call for that function. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D149557
2023-04-21Fix an issue with th_task_state_memo_stack and proxy/helper tasksAlex Duran
When proxy or helper tasks were used in inactive parallel regions, no memo of the th_task_state was stored in the stack, so th_task_state became invalid. This change inserts an item in the memo stack to track these th_task_states. Patch by Alex Duran. Differential Revision: https://reviews.llvm.org/D145736
2022-12-20[OpenMP] Disable libomptarget integration on unsupported platformsGuilherme Valarini
Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D140419
2022-12-14[OpenMP] Add non-blocking support for target nowait regionsGuilherme Valarini
This patch better integrates the target nowait functions with the tasking runtime. It splits the nowait execution into two stages: a dispatch stage, which triggers all the necessary asynchronous device operations and stores a set of post-processing procedures that must be executed after said ops; and a synchronization stage, responsible for synchronizing the previous operations in a non-blocking manner and running the appropriate post-processing functions. Suppose during the synchronization stage the operations are not completed. In that case, the attached hidden helper task is re-enqueued to any hidden helper thread to be later synchronized, allowing other target nowait regions to be concurrently dispatched. Reviewed By: jdoerfert, tianshilei1992 Differential Revision: https://reviews.llvm.org/D132005
2022-12-09Revert "[OpenMP] Clang Support for taskwait nowait clause"Chi Chun Chen
This reverts commit 100dfe7a8ad3789a98df623482b88d9a3a02e176.
2022-12-08[OpenMP] Clang Support for taskwait nowait clauseSunil K
Support for taskwait nowait clause with placeholder for runtime changes. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D131830
2022-05-18[OpenMP] libomp: honor passive wait policy requested with taskingAndreyChurbanov
Currently the library ignores requested wait policy in the presence of tasking. Threads always actively spin. The patch fixes this problem making the wait policy passive if this explicitly requested by user. Differential Revision: https://reviews.llvm.org/D123044
2022-04-12[OpenMP][libomp] Fix some Doxygen issuesJonathan Peyton
Fix spelling of variable names and remove accidental references (#) in Doxygen comments.
2022-04-06[OpenMP] Fix warningsHansang Bae
Silenced compiler warnings after pushing the following change. https://reviews.llvm.org/D122107 Differential Revision: https://reviews.llvm.org/D123233
2022-04-06[OpenMP] Add support for ompt_callback_dispatchHansang Bae
This change adds support for ompt_callback_dispatch with the new dispatch chunk type introduced in 5.2. Definitions of the new ompt_work_loop types were also added in the header file. Differential Revision: https://reviews.llvm.org/D122107
2022-03-07[OpenMP] libomp: implemented task priorities.AndreyChurbanov
Before this patch task priorities were ignored, that was a valid implementation as the task priority is a hint according to OpenMP specification. Implemented shared list of sorted (high -> low) task deques one per task priority value. Tasks execution changed to first check if priority tasks ready for execution exist, and these tasks executed before others; otherwise usual tasks execution mechanics work. Differential Revision: https://reviews.llvm.org/D119676
2022-01-18[OpenMP] Add use of TPAUSETerry Wilmarth
Add use of TPAUSE (from WAITPKG) to the runtime for Intel hardware, with an envirable to turn it on in a particular C-state. Always uses TPAUSE if it is selected and enabled by Intel hardware and presence of WAITPKG, and if not, falls back to old way of checking __kmp_use_yield, etc. Differential Revision: https://reviews.llvm.org/D115758
2021-12-29[OpenMP] Add missing `tt_hidden_helper_task_encountered` along with ↵Shilei Tian
`tt_found_proxy_tasks` In most cases, hidden helper task behave similar as detached tasks. That means, for example, if we have to wait for detached tasks, we have to do the same thing for hidden helper tasks as well. This patch adds the missing condition for hidden helper task accordingly along with detached task. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D107316
2021-10-18[OpenMP] libomp: add check of task function pointer for NULL.AndreyChurbanov
This patch allows to simplify compiler implementation on "taskwait nowait" construct. The "taskwait nowait" is semantically equivalent to the empty task. Instead of creating an empty routine as a task entry, compiler can just send NULL pointer to the runtime. Then the runtime will make all the work with dependences and return because of the absent task routine. Differential Revision: https://reviews.llvm.org/D112015
2021-08-31[OpenMP] Fix task wait doesn't work as expected in serialized teamShilei Tian
As discussed in D107121, task wait doesn't work when a regular task T depends on a detached task or a hidden helper task T' in a serialized team. The root cause is, since the team is serialized, the last task will not be tracked by `td_incomplete_child_tasks`. When T' is finished, it first releases its dependences, and then decrements its parent counter. So far so good. For the thread that is running task wait, if at the moment it is still spinning and trying to execute tasks, it is fine because it can detect the new task and execute it. However, if it happends to finish the function `flag.execute_tasks(...)`, it will be broken because `td_incomplete_child_tasks` is 0 now. In this patch, we update the rule to track children tasks a little bit. If the task team encounters a proxy task or a hidden helper task, all following tasks will be tracked. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D107496
2021-08-19[OpenMP] Use `__kmpc_give_task` in `__kmp_push_task` when encountering a ↵Shilei Tian
hidden helper task This patch replaces the current implementation, overwrites `gtid` and `thread`, with `__kmpc_give_task`. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D106977
2021-08-07[OpenMP] mark target task untiedYe Luo
OpenMP specification Tasking Terminology target task :A mergeable and untied task that ... Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D107686
2021-08-04[OpenMP] Clean up for hidden helper taskShilei Tian
This patch makes some clean up for code of hidden helper task. Reviewed By: protze.joachim Differential Revision: https://reviews.llvm.org/D107008
2021-08-04[OpenMP] Fix performance regression reported in bug #51235Shilei Tian
This patch fixes the "performance regression" reported in https://bugs.llvm.org/show_bug.cgi?id=51235. In fact it has nothing to do with performance. The root cause is, the stolen task is not allowed to execute by another thread because by default it is tied task. Since hidden helper task will always be executed by hidden helper threads, it should be untied. Reviewed By: protze.joachim Differential Revision: https://reviews.llvm.org/D107121
2021-07-30[OpenMP][NFC] libomp: silence warnings on unused variables.AndreyChurbanov
Put declarations/definitions of unused variables under corresponding macros to silence clang build warnings. Differential Revision: https://reviews.llvm.org/D106608
2021-07-29[OpenMP] libomp: Add new experimental barrier: two-level distributed barrierTerry Wilmarth
Two-level distributed barrier is a new experimental barrier designed for Intel hardware that has better performance in some cases than the default hyper barrier. This barrier is designed to handle fine granularity parallelism where barriers are used frequently with little compute and memory access between barriers. There is no need to use it for codes with few barriers and large granularity compute, or memory intensive applications, as little difference will be seen between this barrier and the default hyper barrier. This barrier is designed to work optimally with a fixed number of threads, and has a significant setup time, so should NOT be used in situations where the number of threads in a team is varied frequently. The two-level distributed barrier is off by default -- hyper barrier is used by default. To use this barrier, you must set all barrier patterns to use this type, because it will not work with other barrier patterns. Thus, to turn it on, the following settings are required: KMP_FORKJOIN_BARRIER_PATTERN=dist,dist KMP_PLAIN_BARRIER_PATTERN=dist,dist KMP_REDUCTION_BARRIER_PATTERN=dist,dist Branching factors (set with KMP_FORKJOIN_BARRIER, KMP_PLAIN_BARRIER, and KMP_REDUCTION_BARRIER) are ignored by the two-level distributed barrier. Patch fixed for ITTNotify disabled builds and non-x86 builds Co-authored-by: Jonathan Peyton <jonathan.l.peyton@intel.com> Co-authored-by: Vladislav Vinogradov <vlad.vinogradov@intel.com> Differential Revision: https://reviews.llvm.org/D103121
2021-07-28[OpenMP] Fix deadlock for detachable task with child tasksJoachim Protze
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=49066. For detachable tasks, the assumption breaks that the proxy task cannot have remaining child tasks when the proxy completes. In stead of increment/decrement the incomplete task count, a high-order bit is flipped to mark and wait for the incomplete proxy task. Differential Revision: https://reviews.llvm.org/D101082
2021-07-23[OpenMP] Fix bug 50022Shilei Tian
Bug 50022 [0] reports target nowait fails in certain case, which is added in this patch. The root cause of the failure is, when the second task is created, its parent's `td_incomplete_child_tasks` will not be incremented because there is no parallel region here thus its team is serialized. Therefore, when the initial thread is waiting for its unfinished children tasks, it thought there is only one, the first task, because it is hidden helper task, so it is tracked. The second task will only be pushed to the queue when the first task is finished. However, when the first task finishes, it first decrements the counter of its parent, and then release dependences. Once the counter is decremented, the thread will move on because its counter is reset, but actually, the second task has not been executed at all. As a result, since in this case, the main function finishes, then `libomp` starts to destroy. When the second task is pushed somewhere, all some of the structures might already have already been destroyed, then anything could happen. This patch simply moves `__kmp_release_deps` ahead of decrement of the counter. In this way, we can make sure that the initial thread is aware of the existence of another task(s) so it will not move on. In addition, in order to tackle dependence chain starting with hidden helper thread, when hidden helper task is encountered, we force the task to release dependences. Reference: [0] https://bugs.llvm.org/show_bug.cgi?id=50022 Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D106519
2021-07-22[OpenMP] Refined the logic to give a regular task from a hidden helper taskShilei Tian
In current implementation, if a regular task depends on a hidden helper task, and when the hidden helper task is releasing its dependences, it directly calls `__kmp_omp_task`. This could cause a problem that if `__kmp_push_task` returns `TASK_NOT_PUSHED`, the task will be executed immediately. However, the hidden helper threads are assumed to only execute hidden helper tasks. This could cause problems because when calling `__kmp_omp_task`, the encountering gtid, which is not the real one of the thread, is passed. This patch uses `__kmp_give_task`, but because it is a static function, a new wrapper `__kmpc_give_task` is added. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D106572
2021-07-19[OpenMP] Fixed a segmentation fault when using taskloop and target nowaitShilei Tian
The synchronization of task loop misses hidden helper tasks, causing segmentation fault reported in https://bugs.llvm.org/show_bug.cgi?id=50002. Reviewed By: ye-luo Differential Revision: https://reviews.llvm.org/D106220
2021-07-13[OpenMP] Minor improvement in task allocationHansang Bae
This patch includes a few changes to improve task allocation performance slightly. These changes are enough to restore performance drop observed after introducing hidden helper. Differential Revision: https://reviews.llvm.org/D105715