summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src/kmp_tasking.c
Commit message (Collapse)AuthorAgeFilesLines
* Change source files from .c to .cppJonathan Peyton2016-12-141-3162/+0
| | | | | | | | Patch by Hansang Bae Differential Revision: https://reviews.llvm.org/D26688 llvm-svn: 289732
* Cleanup: debug print fixed and moved inside critical section.Andrey Churbanov2016-12-141-5/+5
| | | | | | | | Patch by Victor Campos. Differential Revision: https://reviews.llvm.org/D27647 llvm-svn: 289640
* [OpenMP] Enable ThreadSanitizer to check OpenMP programsJonas Hahnfeld2016-11-071-4/+23
| | | | | | | | | | | | | | | | | | | | | | This patch allows ThreadSanitizer (Tsan) to verify OpenMP programs. It means that no false positive will be reported by Tsan when verifying an OpenMP programs. This patch introduces annotations within the OpenMP runtime module to provide information about thread synchronization to the Tsan runtime. In order to enable the Tsan support when building the runtime, you must enable the TSAN_SUPPORT option with the following environment variable: -DLIBOMP_TSAN_SUPPORT=TRUE The annotations will be enabled in the main shared library (same mechanism of OMPT). Patch by Simone Atzeni and Joachim Protze! Differential Revision: https://reviews.llvm.org/D13072 llvm-svn: 286115
* Change task stealing to always get task from head of victim's deque.Andrey Churbanov2016-11-021-13/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D26187 llvm-svn: 285833
* Fixed problem introduced by part of https://reviews.llvm.org/D21196.Andrey Churbanov2016-11-011-2/+2
| | | | | | | | | | | | Check Task Scheduling Constraint (TSC) on stealing of untied task. This is needed because the untied task can produce tied children those can break TSC if untied is not a descendant of current task. This can cause live lock on complex tyasking tests (e.g. kastors/strassen-task-dep). Differential Revision: https://reviews.llvm.org/D26182 llvm-svn: 285703
* Add more conditions to check whether task waiting is necessary in ↵Andrey Churbanov2016-11-011-4/+4
| | | | | | | | | | kmp_omp_taskwait. Differential Revision: https://reviews.llvm.org/D26058 Patch by Victor Campos llvm-svn: 285678
* Fixed a memory leak related to task dependencies.Andrey Churbanov2016-10-271-1/+34
| | | | | | | | Differential Revision: http://reviews.llvm.org/D25504 Patch by Alex Duran. llvm-svn: 285283
* Fixed memory leak mistakenly introduced by https://reviews.llvm.org/D23115Andrey Churbanov2016-10-201-3/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D25510 llvm-svn: 284747
* Fix OpenMP 4.0 library buildJonathan Peyton2016-10-181-0/+4
| | | | | | | | Patch by Andrey Churbanov Differential Revision: https://reviews.llvm.org/D25505 llvm-svn: 284499
* [OMPT] Align implementation of reenter frame address to latest (frozen) ↵Jonas Hahnfeld2016-09-141-5/+5
| | | | | | | | | | | | | | | | version of OMPT spec The latest OMPT spec changed the semantic of a tasks reenter frame to be the application frame, that will be entered, when the runtime frame drops. Before it was the last frame in the runtime. This doesn't work for some gcc execution pathes or even clang generated code for : Since there is no runtime frame between the executed task and the encountering task. The test case compares exit and reenter addresses against addresses captured in application code Patch by Joachim Protze! Differential Revision: https://reviews.llvm.org/D23305 llvm-svn: 281464
* Do not block on explicit task depending on proxy taskJonas Hahnfeld2016-08-081-1/+12
| | | | | | | | | | | | | | | | | | | | | | Consider the following code: int dep; #pragma omp target nowait depend(out: dep) { sleep(1); } #pragma omp task depend(in: dep) { printf("Task with dependency\n"); } printf("Doing some work...\n"); In its current state the runtime will block on the second task and not continue execution. Differential Revision: https://reviews.llvm.org/D23116 llvm-svn: 277992
* __kmp_free_task: Fix for serial explicit tasks producing proxy tasksJonas Hahnfeld2016-08-081-14/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following code which may be executed by a serial team: int dep; #pragma omp target nowait depend(out: dep) { sleep(1); } #pragma omp task depend(in: dep) { #pragma omp target nowait { sleep(1); } } Here the explicit task may not be freed until the nested proxy task has finished. The current code hasn't considered this and called __kmp_free_task anyway which triggered an assert because of remaining incomplete children: KMP_DEBUG_ASSERT( TCR_4(taskdata->td_incomplete_child_tasks) == 0 ); Differential Revision: https://reviews.llvm.org/D23115 llvm-svn: 277991
* Add debug trace messages for taskloopJonathan Peyton2016-06-211-0/+5
| | | | llvm-svn: 273299
* Addition of debugger comments and whitespaceJonathan Peyton2016-06-211-0/+4
| | | | | | | | | | | | The removal of legacy code to support long-deprecated debugger support library resulted in some whitespace changes. Comments from that legacy code were made public as they may be useful for other debuggers. Patch by Olga Malysheva. Differential Revision: http://reviews.llvm.org/D21391 llvm-svn: 273282
* Renaming change: 41 -> 45 and 4.1 -> 4.5Jonathan Peyton2016-06-141-21/+21
| | | | | | | | OpenMP 4.1 is now OpenMP 4.5. Any mention of 41 or 4.1 is replaced with 45 or 4.5. Also, if the CMake option LIBOMP_OMP_VERSION is 41, CMake warns that 41 is deprecated and to use 45 instead. llvm-svn: 272687
* Exclude untied tasks from task stealing constraintJonathan Peyton2016-06-131-2/+2
| | | | | | | | | | If either current_task or new_task is untied then skip task scheduling constraint checks, because untied tasks are not affected by the task scheduling constraints. Differential Revision: http://reviews.llvm.org/D21196 llvm-svn: 272570
* [STATS] Add stats gathering for taskloop constructJonathan Peyton2016-06-131-0/+2
| | | | llvm-svn: 272560
* Fix spelling in commentJonathan Peyton2016-06-091-1/+1
| | | | llvm-svn: 272291
* Refactor __kmp_execute_tasks_template functionJonathan Peyton2016-06-091-228/+105
| | | | | | | | | | | | | | Refactored __kmp_execute_tasks_template to shorten and remove code redundancy. The original code for __kmp_execute_tasks_template was very redundant with large sections of repeated code that needed to be kept consistent, and goto statements that made the control flow difficult to discern. This refactoring removes all gotos and redundancy. Patch by Terry Wilmarth Differential Revision: http://reviews.llvm.org/D20879 llvm-svn: 272286
* Fine tuning of TC* macros - small followupPaul Osmialowski2016-06-011-1/+1
| | | | | | | | | As I replaced no-op TCR_4 with actual code, compiler complained while building debug build. This patch moves 'cast to int' to the correct place. Extension to Differential Revision: http://reviews.llvm.org/D19880 llvm-svn: 271377
* Use C++11 atomics for ticket locks implementationPaul Osmialowski2016-05-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | This patch replaces use of compiler builtin atomics with C++11 atomics for ticket locks implementation. Ticket locks are used in critical places of the runtime, e.g. in the tasking mechanism. The main reason this change was introduced is the problem with work stealing function on ARM architecture which suffered from nasty race condition. It turned out that the root cause of the problem lies in the way ticket locks are implemented. Changing compiler builtins into C++11 atomics solves the problem. Two assertions were added into kmp_tasking.c which are useful for detecting early symptoms of something wrong going on with work stealing, which were among the possible outcomes of the race condition. Differential Revision: http://reviews.llvm.org/D19878 llvm-svn: 271324
* Avoid deadlock with COIJonathan Peyton2016-05-311-23/+72
| | | | | | | | | | | | | | When an asynchronous offload task is completed, COI calls the runtime to queue a "destructor task". When the task deques are full, a dead-lock situation arises where the OpenMP threads are inside but cannot progress because the COI thread is stuck inside the runtime trying to find a slot in a deque. This patch implements the solution where the task deques doubled in size when a task is being queued from a COI thread. Differential Revision: http://reviews.llvm.org/D20733 llvm-svn: 271319
* Remove trailing whitespace in src/ directoryJonathan Peyton2016-05-201-18/+18
| | | | | | This patch doesn't affect D19878's context. So D19878 still cleanly applies. llvm-svn: 270252
* Fine tuning of TC* macrosPaul Osmialowski2016-05-071-2/+2
| | | | | | | | | | This patch introduces following: * TCI_* and TCD_* macros for incrementation and decrementation * Fix for invalid use of TCR_8 in one expression Differential Revision: http://reviews.llvm.org/D19880 llvm-svn: 268826
* [STATS] Use partitioned timer schemeJonathan Peyton2016-05-051-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | This change removes the current timers with ones that partition time properly. The current timers are nested, so that if a new timer, B, starts when the current timer, A, is already timing, A's time will include B's. To eliminate this problem, the partitioned timers are designed to stop the current timer (A), let the new timer run (B), and when the new timer is finished, restart the previously running timer (A). With this partitioning of time, a threads' timers all sum up to the OMP_worker_thread_life time and can now easily show the percentage of time a thread is spending in different parts of the runtime or user code. There is also a new state variable associated with each thread which tells where it is executing a task. This corresponds with the timers: OMP_task_*, e.g., if time is spent in OMP_task_taskwait, then that thread executed tasks inside a #pragma omp taskwait construct. The changes are mostly changing the MACROs to use the new PARITIONED_* macros, the new partitionedTimers class and its methods, and new state logic. Differential Revision: http://reviews.llvm.org/D19229 llvm-svn: 268640
* Runtime support for untied tasksJonathan Peyton2016-04-181-2/+36
| | | | | | | | | | | Introduced a counter of parts of an untied task submitted for execution. The counter controls whether all parts of the task are already finished. The compiler should generate re-submission of partially executed untied task by itself before exiting of each task part except for the lexical last part. Differential Revision: http://reviews.llvm.org/D19026 llvm-svn: 266675
* [ITTNOTIFY] Correct barrier imbalance time in case of tasksJonathan Peyton2016-04-141-0/+17
| | | | | | | | | | | | | | | | ittnotify fix for barrier imbalance time in case tasks exist. In the current implementation, task execution time is included into aggregated time on a barrier. This fix calculates task execution time and corrects the arrive time by subtracting the task execution time. Since __kmp_invoke_task() can not only be called on a barrier, the field th.th_bar_arrive_time is used to check if the function was called at the barrier (th.th_bar_arrive_time != 0). So for this check, th_bar_arrive_time is set to zero right after the value is used on the barrier. Differential Revision: http://reviews.llvm.org/D19030 llvm-svn: 266332
* Initialize two variables in kmp_tasking.Samuel Antao2016-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Two initialized local variables are causing clang to produce warnings: ``` ./src/projects/openmp/runtime/src/kmp_tasking.c:3019:5: error: variable 'num_tasks' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ ./src/projects/openmp/runtime/src/kmp_tasking.c:3027:21: note: uninitialized use occurs here for( i = 0; i < num_tasks; ++i ) { ^~~~~~~~~ ./src/projects/openmp/runtime/src/kmp_tasking.c:2968:28: note: initialize the variable 'num_tasks' to silence this warning kmp_uint64 i, num_tasks, extras; ^ = 0 ./src/projects/openmp/runtime/src/kmp_tasking.c:3019:5: error: variable 'extras' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ ./src/projects/openmp/runtime/src/kmp_tasking.c:3022:52: note: uninitialized use occurs here KMP_DEBUG_ASSERT(tc == num_tasks * grainsize + extras); ^~~~~~ ./src/projects/openmp/runtime/src/kmp_debug.h:62:60: note: expanded from macro 'KMP_DEBUG_ASSERT' #define KMP_DEBUG_ASSERT( cond ) KMP_ASSERT( cond ) ^ ./src/projects/openmp/runtime/src/kmp_debug.h:60:51: note: expanded from macro 'KMP_ASSERT' #define KMP_ASSERT( cond ) ( (cond) ? 0 : __kmp_debug_assert( #cond, __FILE__, __LINE__ ) ) ^ ./src/projects/openmp/runtime/src/kmp_tasking.c:2968:36: note: initialize the variable 'extras' to silence this warning kmp_uint64 i, num_tasks, extras; ^ = 0 2 errors generated. ``` This patch initializes these two variables. Reviewers: tlwilmar, jlpeyton Subscribers: tlwilmar, openmp-commits Differential Revision: http://reviews.llvm.org/D17909 llvm-svn: 263316
* [STATS] change TASK_execution name to OMP_taskJonathan Peyton2016-03-111-1/+1
| | | | llvm-svn: 263291
* Add new OpenMP 4.5 taskloop construct featureJonathan Peyton2016-03-021-0/+228
| | | | | | | | | | | | | | | | | | From the standard: The taskloop construct specifies that the iterations of one or more associated loops will be executed in parallel using OpenMP tasks. The iterations are distributed across tasks created by the construct and scheduled to be executed. This initial implementation uses a simple linear tasks distribution algorithm. Later we can add other algorithms to speedup generation of huge number of tasks (i.e., tree-like tasks generation should be faster). This needs to be put into the OpenMP runtime library in order for the compiler team to develop the compiler side of the implementation. Differential Revision: http://reviews.llvm.org/D17404 llvm-svn: 262535
* Add initial support for OpenMP 4.5 task priority featureJonathan Peyton2016-02-251-2/+2
| | | | | | | | | | | The maximum task priority value is read from envirable: OMP_MAX_TASK_PRIORITY. But as of now, nothing is done with it. We just handle the environment variable and add the new api: omp_get_max_task_priority() which returns that value or zero if it is not set. Differential Revision: http://reviews.llvm.org/D17411 llvm-svn: 261908
* [OMPT] Frame information for openmp taskwaitJonas Hahnfeld2016-02-121-3/+6
| | | | | | | | | | | | | For pragma omp taskwait the runtime is called from the task context. Therefore, the reentry frame information should be updated. The information should be available for both taskwait event calls; therefore, set before the first event and reset after the last event. Patch by Joachim Protze Differential Revision: http://reviews.llvm.org/D17145 llvm-svn: 260674
* Fix incorrect task_team in __kmp_give_taskJonathan Peyton2016-02-111-4/+6
| | | | | | | | | | | | When a target task finishes and it tries to access the th_task_team from the threads in the team where it was created, th_task_team can be NULL or point to a different place when that thread started a nested region that is still running. Finding the exact task_team that the threads were using is difficult as it would require to unwind the task_state_memo_stack. So a new field was added in the taskdata structure to point to the active task_team when the task was created. llvm-svn: 260615
* Fix a couple of typos in commentsJonathan Peyton2016-02-111-2/+2
| | | | llvm-svn: 260613
* [OMPT] Add support for ompt_event_task_dependences and ↵Jonas Hahnfeld2016-01-281-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ompt_event_task_dependence_pair The attached patch adds support for ompt_event_task_dependences and ompt_event_task_dependence_pair events from the OMPT specification [1]. These events only apply to OpenMP 4.0 and 4.1 (aka 4.5) because task dependencies were introduced in 4.0. With respect to the changes: ompt_event_task_dependences According to the specification, this event is raised after the task has been created, thefore this event needs to be raised after ompt_event_task_begin (in __kmp_task_start). However, the dependencies are known at __kmpc_omp_task_with_deps which occurs before __kmp_task_start. My modifications extend the ompt_task_info_t struct in order to store the dependencies of the task when _kmpc_omp_task_with_deps occurs and then they are emitted in __kmp_task_start just after raising the ompt_event_task_begin. The deps field is allocated and valid until the event is raised and it is freed and set to null afterwards. ompt_event_task_dependence_pair The processing of the dependences (i.e. checking whenever a dependence is already satisfied) is done within __kmp_process_deps. That function checks every dependence and calls the __kmp_track_dependence routine which gives some support for graphical output. I used that routine to emit the dependence pair but I also needed to know the sink_task. Despite the fact that the code within KMP_SUPPORT_GRAPH_OUTPUT refers to task_sink it may be null because sink->dn.task (there's a comment regarding this) and in fact it does not point to a proper pointer value because the value is set in node->dn.task = task; after the __kmp_process_deps calls in __kmp_check_deps. I have extended the __kmp_process_deps and __kmp_track_dependence parameter list to receive the sink_task. [1] https://github.com/OpenMPToolsInterface/OMPT-Technical-Report/blob/target/ompt-tr.pdf Patch by Harald Servat Differential Revision: http://reviews.llvm.org/D14746 llvm-svn: 259038
* Restore th_current_task first as suggested by John Mellor-CrummeyJonathan Peyton2016-01-271-5/+4
| | | | | | | If an asynchronous inquiry peers into the runtime system it doesn't see the freed task as the current task. llvm-svn: 258990
* Removing extra empty linesJonathan Peyton2016-01-271-4/+0
| | | | llvm-svn: 258984
* Fix crash when __kmp_task_team_setup called for single threaded teamJonathan Peyton2015-11-301-20/+21
| | | | | | | | | | | The task_team pointer is dereferenced unconditionally which causes a SEGFAULT when it is NULL (e.g. for serialized parallel, that can happen for "teams" construct or for "target nowait"). The solution is to skip second task team setup for single thread team. Differential Revision: http://reviews.llvm.org/D14729 llvm-svn: 254321
* [OMPT] Add ompt_event_task_switch event into OMPT/OpenMPJonathan Peyton2015-11-111-0/+24
| | | | | | | | | | | | The patch adds support for ompt_event_task_switch into LLVM/OpenMP. Note that the patch has also updated the signature of ompt_event_task_switch to ompt_task_pair_callback_t (rather than the previous ompt_task_switch_callback_t). Patch by Harald Servat Differential Revision: http://reviews.llvm.org/D14566 llvm-svn: 252761
* Fixes to wait-loop codeJonathan Peyton2015-11-091-0/+1
| | | | | | | | | | | | | 1) Add get_ptr_type() method to all wait flag types. 2) Flag in sleep_loc may change type by the time the resume is called from __kmp_null_resume_wrapper. We use get_ptr_type to obtain the real type and compare it to the casted object received. If they don't match, we know the flag has changed (already resumed and replaced by another flag). If they match, it doesn't hurt to go ahead and resume it. Differential Revision: http://reviews.llvm.org/D14458 llvm-svn: 252487
* Fixes and improvements to tasking in barriersJonathan Peyton2015-11-091-1/+0
| | | | | | | | | | | | | | | 1) When the number of threads in a team increases, new threads need to have all their barrier struct fields initialized. We were missing the parent_bar and team fields. 2) For non-forkjoin barriers, we now do the __kmp_task_team_setup before the gather. The setup now sets up the task_team that all the threads will switch to after the barrier, but it needs to be done before other threads do the switch. 3) Remove an unneeded assignment of tt_found_tasks in task team free function. Differential Revision: http://reviews.llvm.org/D14456 llvm-svn: 252486
* [OMPT] Add OMPT events for the OpenMP taskwait construct.Jonathan Peyton2015-11-091-0/+25
| | | | llvm-svn: 252472
* Refactor of task_team code.Jonathan Peyton2015-11-041-90/+62
| | | | | | | | | | This is a refactoring of the task_team code that more elegantly handles the two task_team case. Two task_teams per team are kept in use for the lifetime of the team. Thus no reference counting is needed. Differential Revision: http://reviews.llvm.org/D13993 llvm-svn: 252082
* [OMPT] Initialize task fields only if neededJonathan Peyton2015-10-091-17/+12
| | | | | | | | | | | | | | Because __kmp_task_init_ompt is called for every initial task in each thread and always generated task ids, this was a big performance issue on bigger systems even without any tool attached. After changing the initialization interface to ompt_tool, we can now rely on already knowing whether a tool is attached and OMPT is enabled at this point. Patch by Jonas Hahnfeld Differential Revision: http://reviews.llvm.org/D13494 llvm-svn: 249855
* Formatting/Whitespace/Comment changes associated with wait/release improvements.Jonathan Peyton2015-10-081-14/+13
| | | | llvm-svn: 249725
* Debug trace and assert statement changes for wait/release improvements.Jonathan Peyton2015-10-081-19/+23
| | | | | | | These changes improve/update the trace messages and debug asserts related to the previous wait/release checkin. llvm-svn: 249717
* OpenMP Wait/release improvements.Jonathan Peyton2015-10-081-5/+4
| | | | | | | | | | These changes improve the wait/release mechanism for threads spinning in barriers that are handling tasks while spinnin by providing feedback to the barriers about any task stealing that occurs. Differential Revision: http://reviews.llvm.org/D13353 llvm-svn: 249711
* [OMPT] Simplify control variable logic for OMPTJonathan Peyton2015-09-211-7/+7
| | | | | | | | | | | | | | | Prior to this change, OMPT had a status flag ompt_status, which could take several values. This was due to an earlier OMPT design that had several levels of enablement (ready, disabled, tracking state, tracking callbacks). The current OMPT design has OMPT support either on or off. This revision replaces ompt_status with a boolean flag ompt_enabled, which simplifies the runtime logic for OMPT. Patch by John Mellor-Crummey Differential Revision: http://reviews.llvm.org/D12999 llvm-svn: 248189
* Put taskdata variables under KMP_DEBUG guards.Jonathan Peyton2015-08-261-2/+3
| | | | | | | These variables are only used in the TRACE macros and so don't need to be defined unless compiling in debug mode. llvm-svn: 246067
* Replace variables with definitions inside KMP_DEBUG_ASSERT statementsJonathan Peyton2015-08-261-4/+2
| | | | | | | | This change just removes the variables created solely for KMP_DEBUG_ASSERT statements and puts the definition of the removed variables inside the KMP_DEBUG_ASSERT statements. llvm-svn: 246065
OpenPOWER on IntegriCloud