Commit Graph
43 Commits
Author SHA1 Message Date
Jonathan Peyton 0afe745b65 [OpenMP] Introduce hierarchical scheduling
This patch introduces the logic implementing hierarchical scheduling.
First and foremost, hierarchical scheduling is off by default
To enable, use -DLIBOMP_USE_HIER_SCHED=On during CMake's configure stage.
This work is based off if the IWOMP paper:
"Workstealing and Nested Parallelism in SMP Systems"

Hierarchical scheduling is the layering of OpenMP schedules for different layers
of the memory hierarchy. One can have multiple layers between the threads and
the global iterations space. The threads will go up the hierarchy to grab
iterations, using possibly a different schedule & chunk for each layer.

[ Global iteration space (0-999) ]

(use static)
[ L1 | L1 | L1 | L1 ]

(use dynamic,1)
[ T0 T1 | T2 T3 | T4 T5 | T6 T7 ]

In the example shown above, there are 8 threads and 4 L1 caches begin targeted.
If the topology indicates that there are two threads per core, then two
consecutive threads will share the data of one L1 cache unit. This example
would have the iteration space (0-999) split statically across the four L1
caches (so the first L1 would get (0-249), the second would get (250-499), etc).
Then the threads will use a dynamic,1 schedule to grab iterations from the L1
cache units. There are currently four supported layers: L1, L2, L3, NUMA

OMP_SCHEDULE can now read a hierarchical schedule with this syntax:
OMP_SCHEDULE='EXPERIMENTAL LAYER,SCHED[,CHUNK][:LAYER,SCHED[,CHUNK]...]:SCHED,CHUNK
And OMP_SCHEDULE can still read the normal SCHED,CHUNK syntax from before

I've kept most of the hierarchical scheduling logic inside kmp_dispatch_hier.h
to try to keep it separate from the rest of the code.

Differential Revision: https://reviews.llvm.org/D47962


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@336571 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 17:51:13 +00:00
Jonathan Peyton ab0fc85192 [OpenMP] Use C++11 Atomics - barrier, tasking, and lock code
These are preliminary changes that attempt to use C++11 Atomics in the runtime.
We are expecting better portability with this change across architectures/OSes.
Here is the summary of the changes.

Most variables that need synchronization operation were converted to generic
atomic variables (std::atomic<T>). Variables that are updated with combined CAS
are packed into a single atomic variable, and partial read/write is done
through unpacking/packing

Patch by Hansang Bae

Differential Revision: https://reviews.llvm.org/D47903


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@336563 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 17:36:22 +00:00
Joachim Protze 8b6b3274cb [OMPT] Rename ompt_frame_t to omp_frame_t
Rename ompt_frame_t to omp_frame_t, as defined in the spec.

Differential Revision: https://reviews.llvm.org/D43568

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@333367 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-28 08:14:58 +00:00
Joachim Protze a838d8e95f [OMPT] Fix thread_num for implicit_task_end callbacks in nested parallel regions
implicit_task_end callbacks in nested parallel regions did not always give the
correct thread_num, since the inner parallel region may have already been
finalized.
Now, the thread_num is stored at the beginning of the implicit task and
retrieved at the end, whenever necessary.

A testcase was added as well.

Differential Revision: https://reviews.llvm.org/D46260

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@331632 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-07 12:42:21 +00:00
Andrey Churbanov 68e7471d49 Fix for Fix for https://bugs.llvm.org/show_bug.cgi?id=36705.
Differential Revision: https://reviews.llvm.org/D44637


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@327875 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 18:05:15 +00:00
Andrey Churbanov ec2d186756 Improve OpenMP threadprivate implementation.
Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D41914


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@326733 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-05 18:42:01 +00:00
Jonas Hahnfeld 3954610539 [OMPT] Fix parallel_data in implicit barrier-end
This is required to be NULL for implicit barriers at the end of a
parallel region. Noticed in review of D43191.

Differential Revision: https://reviews.llvm.org/D43308

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@325922 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-23 16:46:25 +00:00
Jonathan Peyton 0fd60a5ceb Simplify __kmp_expand_threads
This change simplifies __kmp_expand_threads to take a single argument.
Previously, it allowed two arguments and had logic to decide on different
potential expansion sizes. However, no calls to __kmp_expand_threads in the
runtime make use of this extra logic. Thus the extra argument and logic is
removed here.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D41836


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@322204 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 18:27:01 +00:00
Jonathan Peyton 63acc26632 Minor code cleanup
Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D41831


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@322203 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 18:24:09 +00:00
Jonathan Peyton 03e17bc444 Improve stability of the runtime in parent/child processes
This change improves stability of the runtime when the application forks child
processes.  Acquiring/releasing __kmp_initz_lock and __kmp_forkjoin_lock in the
atfork handlers insures that the actual fork does not occur while those two
locks are held, and __kmp_itt_reset() reverts the itt's global state to the
initial state which also initializes the mutex stored in the global state.
Some missing initialization code was also inserted in the child's atfork handler.

Patch by Hansang Bae

Differential Revision: https://reviews.llvm.org/D41462


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@322202 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 18:21:48 +00:00
Joachim Protze cd3a757667 [OMPT] Fix ompt_task_data handling in implicit barriers
Changes to task_data in barrier-begin were not visible at barrier-end

Differential Revision: https://reviews.llvm.org/D41176

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@322178 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 12:51:27 +00:00
Jonathan Peyton c2ca3f2e78 Fix trademarks found by scanner
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@321827 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 22:56:47 +00:00
Jonathan Peyton 9cdb2558bd Make kmp_r_sched_t into a union
This change makes kmp_r_sched_t type into a union for simpler
comparisons and assignments

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D40374


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@319379 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29 22:47:52 +00:00
Joachim Protze 28671628a4 Rename fields of ompt_frame_t
This is part of the renaming of data types from OpenMP TR4 to TR6

Patch by Simon Convent

Differential Revision: https://reviews.llvm.org/D39326

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317435 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-05 14:11:10 +00:00
Jonas Hahnfeld 74248f8850 Revert "Rename fields of ompt_frame_t"
This reverts commit r317338 which discarded some recent commits.

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317347 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03 18:28:25 +00:00
Jonas Hahnfeld ac062a9ef1 Revert "Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)"
This reverts commit r317339 which discarded some recent commits.

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317346 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03 18:28:19 +00:00
Joachim Protze 92e5a1069f Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)
The TR6 document is expected to be publically released around November 15.
This patch does not implement OMPT for libomptarget.

Patch by Simon Convent and Joachim Protze

Differential Revision: https://reviews.llvm.org/D39182

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03 17:09:00 +00:00
Joachim Protze 1d2c9dccb9 Rename fields of ompt_frame_t
This is part of the renaming of data types from OpenMP TR4 to TR6

Patch by Simon Convent

Differential Revision: https://reviews.llvm.org/D39326

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317338 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03 17:08:40 +00:00
Joachim Protze ff9d3f5109 Update implementation of OMPT to the specification OpenMP 5.0 Preview 1 (TR4).
The code is tested to work with latest clang, GNU and Intel compiler. The implementation
is optimized for low overhead when no tool is attached shifting the cost to execution with
tool attached.

This patch does not implement OMPT for libomptarget.

Patch by Simon Convent and Joachim Protze

Differential Revision: https://reviews.llvm.org/D38185

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@317085 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01 10:08:30 +00:00
Jonathan Peyton be524d6135 Apply formatting changes
.clang-format's comments are removed and a (hopefully) final
set of formatting changes are applied.

Differential Revision: https://reviews.llvm.org/D38837
Differential Revision: https://reviews.llvm.org/D38920


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@316227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20 19:30:57 +00:00
Jonathan Peyton 5b33aeb207 Remove unnecessary semicolons
Removes semicolons after if {} blocks, function definitions, etc.
I was able to apply the large OMPT patch cleanly on top of this one
with no conflicts.


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@314340 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27 20:36:27 +00:00
Jonathan Peyton af6ac33754 Remove unused t_single_lock
Add padding inside team structure to keep same structure size.


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@314242 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-26 20:12:16 +00:00
Jonathan Peyton e945cccc7e Minor code cleanup of Klocwork issues
Minor code cleanup of Klocwork issues. Fatal messages are given no return
attribute. Define and use KMP_NORETURN to work for multiple C++ versions.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D37275


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@312538 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-05 15:43:58 +00:00
Jonathan Peyton f4926388d0 Remove BUILD_TV
Cleanup code to remove BUILD_TV and unused code bracketed by it.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D36011


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@311114 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17 19:09:28 +00:00
Paul Osmialowski 521c639c91 OMP_PROC_BIND: better spread
This change improves the way threads are spread across cores
when OMP_PROC_BIND=spread is set and no unusual affinity masks are in use.

Differential Revision: https://reviews.llvm.org/D36510

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@310670 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-10 23:04:11 +00:00
Jonathan Peyton ec81ddf65a Add new envirable KMP_TEAMS_THREAD_LIMIT
This change adds a new environment variable, KMP_TEAMS_THREAD_LIMIT, which is
used to set a new global variable, __kmp_teams_max_nth, which is checked when
determining the size and quantity of teams that will be created in the teams
construct. Specifically, it is a limit on the total number of threads in a given
teams construct. It differentiates the limits for the teams construct from the
limits for regular parallel regions (KMP_DEVICE_THREAD_LIMIT/__kmp_max_nth and
OMP_THREAD_LIMIT/__kmp_cg_max_nth). When each individual team is formed, it is
still subject to those limits. After the clauses to the teams construct are
parsed and calculated, we check to make sure we are within this limit, and if
not, reduce num_threads per team and/or number of teams, accordingly. The
default value is set to the number of available processors on the system.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D36009


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@309874 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 20:04:45 +00:00
Jonathan Peyton 12f81b0f7c Fix implementation of OMP_THREAD_LIMIT
This change fixes the implementation of OMP_THREAD_LIMIT. The implementation of
this previously was not restricted to a contention group (but it should be,
according to the spec), and this is fixed here. A field is added to root thread
to store a counter of the threads in the contention group. An extra check is
added when reserving threads for a parallel region that checks this variable and
compares to threadlimit-var, which is implemented as a new global variable,
kmp_cg_max_nth. Associated settings changes were also made, and clean up of
comments that referred to OMP_THREAD_LIMIT, but should refer to the new
KMP_DEVICE_THREAD_LIMIT (added in an earlier patch).

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D35912


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@309319 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27 20:58:41 +00:00
Jonathan Peyton c701446276 Introduce KMP_DEVICE_THREAD_LIMIT
This change drops in KMP_DEVICE_THREAD_LIMIT to replace KMP_MAX_THREADS. It's
possible there will eventually be a OMP_DEVICE_THREAD_LIMIT, and we need
something to distinguish from OMP_THREAD_LIMIT, which is currently implemented
incorrectly (the fix for that will be added soon in a separate patch).
KMP_ALL_THREADS is deprecated here, but we can keep the "all" option on
KMP_DEVICE_THREAD_LIMIT to support that functionality. KMP_DEVICE_THREAD_LIMIT
now has priority over its deprecated rival KMP_ALL_THREADS. I also cleaned up
some comments that incorrectly referred to non-existent kmp_max_threads variable
instead of kmp_max_nth.

I've left the name of where this setting eventually ends up as
__kmp_max_nth, for now.

This change does not change much in the way of functionality. It does NOT change
OMP_THREAD_LIMIT. It's just cleaning up and setting up for that.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D35860


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@309168 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26 20:07:58 +00:00
Andrey Churbanov b88a01f4ef OpenMP RTL cleanup: eliminated warnings with -Wcast-qual, patch 2.
Changes are: got all atomics to accept volatile pointers that allowed
to simplify many type conversions. Windows specific code fixed correspondingly.

Differential Revision: https://reviews.llvm.org/D35417


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@308164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17 09:03:14 +00:00
Andrey Churbanov 1c31fdada0 OpenMP RTL cleanup: eliminated warnings with -Wcast-qual.
Changes are: replaced C-style casts with cons_cast and reinterpret_cast;
type of several counters changed to signed; type of parameters of 32-bit and
64-bit AND and OR intrinsics changes to unsigned; changed files formatted
using clang-format version 3.8.1.

Differential Revision: https://reviews.llvm.org/D34759


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@307020 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-03 11:24:08 +00:00
Jonathan Peyton 8924d7386a Replace platform macro with KMP_MIC_SUPPORTED
Differential Revision: https://reviews.llvm.org/D34119


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@305307 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13 17:17:26 +00:00
Andrey Churbanov 2b5580f57b OpenMP 4.5: implemented support of schedule(simd:guided) and
schedule(simd:runtime) - library part. Compiler generation should use newly
introduced scheduling kinds kmp_sch_guided_simd = 46, kmp_sch_runtime_simd = 47,
as parameters to __kmpc_dispatch_init_* entries.

Differential Revision: https://reviews.llvm.org/D31602


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@304724 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-05 17:17:33 +00:00
Andrey Churbanov 20fe9e7270 Re-enable assertion after the problem that caused it to be hit had been fixed
Differential Revision: https://reviews.llvm.org/D31421


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@304443 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01 18:10:45 +00:00
Jonathan Peyton fcec73a508 Fix minor formatting issues
Some code was restructured to move it under KMP_DEBUG.  The rest is
formatting changes to fix some things broken by clang-format

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D33744


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@304438 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01 16:46:36 +00:00
Jonathan Peyton e703e783e7 Clang-format and whitespace cleanup of source code
This patch contains the clang-format and cleanup of the entire code base. Some
of clang-formats changes made the code look worse in places. A best effort was
made to resolve the bulk of these problems, but many remain. Most of the
problems were mangling line-breaks and tabbing of comments.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D32659


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@302929 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 18:01:32 +00:00
Olga Malysheva b8b75f9476 Reset cancellation status for 'parallel', 'sections' and 'for' constracts.
Without this fix cancellation status for parallel, sections and for persists 
across construct boundaries.

Differential Revision: https://reviews.llvm.org/D31419

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@299434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-04 13:56:50 +00:00
Andrey Churbanov ea09034b77 Fix for bug https://llvm.org/bugs/show_bug.cgi?id=30889
Condition adjusted for Debug assertion.

Differential Revision: https://reviews.llvm.org/D29638


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@298915 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 13:35:42 +00:00
Andrey Churbanov e70eb2bba4 Fixed intermittent hang on tests with "target teams if(0)" construct with no parallel inside.
Differential Revision: https://reviews.llvm.org/D29597


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@298373 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21 13:48:52 +00:00
Jonathan Peyton d3acdf9c86 OpenMP version 5.0 added
Add build option LIBOMP_OMP_VERSION=50, 5.0 headers, and add the year/month
associated with OpenMP 5.0 in relevant source locations. Also, remove the
deprecated LIBOMP_OMP_VERSION=41 option.

Patch by Olga Malysheva

Differential Revision: https://reviews.llvm.org/D30450


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@297083 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06 22:07:40 +00:00
Andrey Churbanov 273c4bfef1 Fix a race in shutdown when tasking is used.
Patch by Terry Wilmarth.

Differential Revision: https://reviews.llvm.org/D28377


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@294214 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-06 18:53:32 +00:00
Jonathan Peyton 0e5d1992ca Fix small memory leak regarding __kmp_nested_proc_bind
There is no corresponding free() for this expandable array.  The logic is
added in __kmp_cleanup() next to the freeing of __kmp_nested_nth.


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@292348 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 06:40:19 +00:00
Jonathan Peyton 4277fc10ad Follow up to r289732: Update comments in source files to reference .cpp files
Patch by Hansang Bae


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@289739 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 23:01:24 +00:00
Jonathan Peyton 844de54c9c Change source files from .c to .cpp
Patch by Hansang Bae

Differential Revision: https://reviews.llvm.org/D26688


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@289732 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 22:39:11 +00:00