Commit Graph

231 Commits

Author SHA1 Message Date
Alexey Bataev b0eae8d6f4 [OPENMP] Add dependency to clang/clang-headers etc. for in-tree build of libomp.
Add additional dependency to clang/clang-headers/FileCheck to avoid possible troubles with in-tree build/test of libomp + allow parallel testing of libomp. Also includes bugfixes for tests + improvements to avoid possible race conditions.
Differential Revision: http://reviews.llvm.org/D14055

llvm-svn: 251797
2015-11-02 13:43:32 +00:00
Jonathan Peyton 57d171c9a6 [OMPT] Adding missing free() calls to ompt_tool_windows() function.
llvm-svn: 251719
2015-10-30 20:24:25 +00:00
Jonathan Peyton 69e596a5e7 [OMPT] Windows Support for OMPT
The problem is that the ompt_tool() function (which must be implemented by a
performance tool) should be defined in the RTL as well to cover the case when
the tool is not present in the address space of the process. This functionality
is accomplished with weak symbols in Unices. Unfortunately, Windows does not
support weak symbols.

The solution in these changes is to grab the list of all modules loaded by the
process and then search for symbol "ompt_tool()" within them. The function
ompt_tool_windows() performs the search of the ompt_tool symbol. If ompt_tool is
found, then its return value is used to initialize the tool. If ompt_tool is not
found, then ompt_tool_windows() returns NULL and OMPT is thus, disabled.

While doing these changes, the OMPT_SUPPORT detection in CMake was changed to
test for the required featuers for OMPT_SUPPORT, namely: builtin_frame_address()
existence, weak attribute existence and psapi.dll existence. For
LIBOMP_HAVE_OMPT_SUPPORT to be true, it must be that the builtin_frame_address()
intrinsic exists AND one of: either weak attributes exist or psapi.dll exists.

Also, since Process Status API is used I had to add new dependency -- psapi.dll
to the library dependency micro test.

Differential Revision: http://reviews.llvm.org/D14027

llvm-svn: 251654
2015-10-29 20:56:24 +00:00
Jonathan Peyton 0dd75fdfa9 Removed zeroing th.th_task_state for master thread at start of nested parallel.
The th.th_task_state for the master thread at the start of a nested parallel
should not be zeroed in __kmp_allocate_team() because it is later put in the
stack of states in __kmp_fork_call() for further re-use after exiting the
nested region. It is zeroed after being put in the stack.

Differential Revision: http://reviews.llvm.org/D13702

llvm-svn: 250847
2015-10-20 19:21:04 +00:00
Jonathan Peyton 55f027b1d4 Removed '@' from delimiters, added it as offset designator.
Moved '@' from delimiters to offset designators for the KMP_PLACE_THREADS
environment variable. Only one of: postfix "o" or prefix @, should be used
in the value of KMP_PLACE_THREADS. For example, '2s@2,4c@2,1t'. This is also
the format of KMP_SETTINGS=1 output now (removed "o" from there).
e.g., 2s,2o,4c,2o,1t.

Differential Revision: http://reviews.llvm.org/D13701

llvm-svn: 250846
2015-10-20 19:15:48 +00:00
Jonathan Peyton 6778c73243 Fix OMP_PLACES negation operator parsing (!place)
Just moved the *scan++ line up before the recursive call.  Otherwise,
infinite recursion occurs and leads to a segmentation fault.

llvm-svn: 250729
2015-10-19 19:43:01 +00:00
Jonathan Peyton 45ca5dada1 Clean-up cancellation state flag between parallel regions
Without this fix, cancellation requests in one parallel region cause
cancellation of the second region even though the second one was
not intended to be cancelled.

llvm-svn: 250727
2015-10-19 19:33:38 +00:00
Dimitry Andric 9b8c353c90 On FreeBSD, PTHREADS_THREADS_MAX does not fit into an int, leading to
warnings similar to the following:

    runtime/src/kmp_global.c:117:35: warning: implicit conversion from
    'unsigned long' to 'int' changes value from 18446744073709551615 to -1
    [-Wconstant-conversion]
    int           __kmp_sys_max_nth = KMP_MAX_NTH;
                  ~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~
    runtime/src/kmp.h:849:34: note: expanded from macro 'KMP_MAX_NTH'
    #    define KMP_MAX_NTH          PTHREAD_THREADS_MAX
                                     ^~~~~~~~~~~~~~~~~~~

Clamp KMP_MAX_NTH to INT_MAX to avoid these warnings.  Also use INT_MAX
whenever PTHREAD_THREADS_MAX is not defined at all.

Differential Revision: http://reviews.llvm.org/D13827

llvm-svn: 250708
2015-10-19 17:32:04 +00:00
Jonathan Peyton 0e6d457797 [OMPT] Add OMPT events for API locking
This fix implements the following OMPT events for the API locking routines:
* ompt_event_acquired_lock
* ompt_event_acquired_nest_lock_first
* ompt_event_acquired_nest_lock_next
* ompt_event_init_lock
* ompt_event_init_nest_lock
* ompt_event_destroy_lock
* ompt_event_destroy_nest_lock

For the acquired events the depths of the locks ist required, so a return value
was added similiar to the return values we already have for the release lock
routines.

Patch by Tim Cramer

Differential Revision: http://reviews.llvm.org/D13689

llvm-svn: 250526
2015-10-16 16:52:58 +00:00
Jonathan Peyton 33d1d283f6 Detect final task in GOMP interface.
llvm-svn: 250198
2015-10-13 18:36:22 +00:00
Jonathan Peyton 71797c043f [OPENMP][TESTSUITE] Undefined variable in test omp_task_final.c
Patch by Alexey Bataev

Differential Revision: http://reviews.llvm.org/D13661

llvm-svn: 250066
2015-10-12 17:01:05 +00:00
Jonathan Peyton f0344bb02b [OMPT] Reduce overhead of OMPT
* Avoid computing state needed only by OMPT unless the ompt_enabled flag is set.
* Properly handle a corner case in OMPT where team == NULL.

Patch by John Mellor-Crummey

Differential Revision: http://reviews.llvm.org/D13502

llvm-svn: 249857
2015-10-09 17:42:52 +00:00
Jonathan Peyton b401db6d73 [OMPT] Initialize task fields only if needed
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
2015-10-09 17:38:05 +00:00
Jonathan Peyton 1bd61b423e Formatting/Whitespace/Comment changes associated with wait/release improvements.
llvm-svn: 249725
2015-10-08 19:44:16 +00:00
Jonathan Peyton e03b62f3bc Debug trace and assert statement changes for wait/release improvements.
These changes improve/update the trace messages and debug asserts related to
the previous wait/release checkin.

llvm-svn: 249717
2015-10-08 18:49:40 +00:00
Jonathan Peyton a0e159f7aa OpenMP Wait/release improvements.
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
2015-10-08 18:23:38 +00:00
Jonathan Peyton dd4aa9b6b5 Added sockets to the syntax of KMP_PLACE_THREADS environment variable.
Added (optional) sockets to the syntax of the KMP_PLACE_THREADS environment variable.
Some limitations:
* The number of sockets and then optional offset should be specified first (before other parameters).
* The letter designation is mandatory for sockets and then for other parameters.
* If number of cores is specified first, then the number of sockets is defaulted to all sockets on the machine; also, the old syntax is partially supported if sockets are skipped.
* If number of threads per core is specified first, then the number of sockets and cores per socket are defaulted to all sockets and all cores per socket respectively.
* The number of cores per socket cannot be specified before sockets or after threads per core.
* The number of threads per core can be specified before or after core-offset (old syntax required it to be before core-offset);
* Parameters delimiter can be: empty, comma, lower-case x;
* Spaces are allowed around numbers, around letters, around delimiter.
Approximate shorthand specification:
KMP_PLACE_THREADS="[num_sockets(S|s)[[delim]offset(O|o)][delim]][num_cores_per_socket(C|c)[[delim]offset(O|o)][delim]][num_threads_per_core(T|t)]"

Differential Revision: http://reviews.llvm.org/D13175

llvm-svn: 249708
2015-10-08 17:55:54 +00:00
Jonathan Peyton 7edeef1bbf Fix memory corruption in Windows debug library
This patch adjusts the buffer size when reducing the buffer used for printing.
This solves the memory corruption in Windows debug library, and potential
memory corruption in other builds.

llvm-svn: 248588
2015-09-25 17:23:17 +00:00
Jonathan Peyton f209cdfade [OpenMP Testsuite] Change omp_get_wtime.c timer resolution to 3 percent
llvm-svn: 248501
2015-09-24 15:10:57 +00:00
Jonathan Peyton 5a60bc5743 [OpenMP Testsuite] Mac rpath specified when compiling tests
llvm-svn: 248500
2015-09-24 15:09:51 +00:00
Jonathan Peyton 3a91ada1e2 Fix stats build problem.
This change removes the KMP_STATS_ENABLED macro inside kmp_stats.cpp since it
is only compiled anyways when LIBOMP_STATS=on.  Also, include kmp_config.h in
kmp_stats.h to ensure KMP_STATS_ENABLED is defined.

llvm-svn: 248494
2015-09-24 14:47:51 +00:00
Jonathan Peyton 1acc2dbf6e Update Reference.pdf files.
This updates the Reference.pdf files to say LLVM OpenMP Runtime Library and
also updates the build documentation to show how to build with CMake.

llvm-svn: 248407
2015-09-23 18:09:47 +00:00
Jonathan Peyton 614c7ef81c OpenMP Initial testsuite change to purely llvm-lit based testing
This change introduces a check-libomp target which is based upon llvm's lit
test infrastructure. Each test (generated from the University of Houston's
OpenMP testsuite) is compiled and then run. For each test, an exit status of 0
indicates success and non-zero indicates failure. This way, FileCheck is not
needed. I've added a bit of logic to generate symlinks (libiomp5 and libgomp)
in the build tree so that gcc can be tested as well.  When building out-of-
tree builds, the user will have to provide llvm-lit either by specifying
-DLIBOMP_LLVM_LIT_EXECUTABLE or having llvm-lit in their PATH.

Differential Revision: http://reviews.llvm.org/D11821

llvm-svn: 248211
2015-09-21 20:41:31 +00:00
Joerg Sonnenberger 7649cd4389 Use sysconf for the number of cores on FreeBSD too.
llvm-svn: 248209
2015-09-21 20:29:12 +00:00
Joerg Sonnenberger 8abf7c87cd Complex division requires libm on NetBSD, add it.
llvm-svn: 248207
2015-09-21 20:21:02 +00:00
Joerg Sonnenberger 1564f3c4ec Add basic NetBSD support.
llvm-svn: 248204
2015-09-21 20:02:45 +00:00
Joerg Sonnenberger 40252cecb0 Teach the Perl modules about NetBSD.
llvm-svn: 248203
2015-09-21 19:42:05 +00:00
Joerg Sonnenberger f16f649e0d libomp on NetBSD needs libc, libpthread and libm.
llvm-svn: 248200
2015-09-21 19:40:59 +00:00
Joerg Sonnenberger 64be2d271d Assume that all Unix-like systems will want to handle signals and
simplify conditional.

llvm-svn: 248199
2015-09-21 19:38:56 +00:00
Joerg Sonnenberger d742184e0b Darwin is the exception when it comes to accessing environ, all other
Unix-like systems can follow the same code path.

llvm-svn: 248198
2015-09-21 19:37:05 +00:00
Jonathan Peyton b68a85d1f6 [OMPT] Simplify control variable logic for OMPT
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
2015-09-21 18:11:22 +00:00
Jonathan Peyton 82a13bf36c [OMPT] Overhaul OMPT initialization interface
The OMPT specification has changed. This revision brings the LLVM OpenMP
implementation up to date.

Technical overview of changes:
Previously, a public weak symbol ompt_initialize was called after the OpenMP
runtime is initialized. The new interface calls a global weak symbol ompt_tool
prior to initialization. If a tool is present, ompt_tool returns a pointer to
a function that matches the signature for ompt_initialize. After OpenMP is 
initialized the function pointer is called to initialize a tool.
Knowing that OMPT will be enabled before initialization allows OMPT support to
be initialized as part of initialization instead of back patching
initialization of OMPT support after the fact.
Post OpenMP initialization support has been generalized moves from
ompt-specific.c into ompt-general.c, since the OMPT initialization logic is no
longer implementation specific.

Patch by John Mellor-Crummey

Differential Revision: http://reviews.llvm.org/D12998

llvm-svn: 248187
2015-09-21 18:01:02 +00:00
Jonathan Peyton 441f33769e Fix the OpenMP 3.0 build
This change adds guards to the code in places where they are missing to enable
the OpenMP 3.0 build.

Patch by Diego Caballero and Johnny Peyton

Mailing List: http://lists.llvm.org/pipermail/openmp-dev/2015-September/000935.html

llvm-svn: 248178
2015-09-21 17:24:46 +00:00
Jonathan Peyton cab67cc3ff [OMPT] Correct an incorrect OMPT ifdef
An ifdef for OMPT_TRACE needs to be OMPT_BLAME so that both instances of a
callback are controlled by the same ifdef.

Patch by John Mellor-Crummey

Differential Revision: http://reviews.llvm.org/D12911

llvm-svn: 248001
2015-09-18 16:24:46 +00:00
Sylvestre Ledru 6dabac88db Force the readelf call to be in English
Summary:
For example, when readelf is called on a french localization, it will find "Librairie partagées" instead of "shared library"


Reviewers: AndreyChurbanov, jcownie

Differential Revision: http://reviews.llvm.org/D12902

llvm-svn: 247787
2015-09-16 12:01:14 +00:00
Jonathan Peyton 8977618773 Removing the Makefile/Perl build system.
This change deletes the Makefile+Perl build system and all files used by it
which aren't used by the CMake build system. This included many Perl files,
*.mk files, iomp* files.  This change also updates the README's and
index.html to instruct the user to use the CMake build system. All mentioning
of the Perl+Makefile based system are removed.

Differential Revision: http://reviews.llvm.org/D12331

llvm-svn: 247583
2015-09-14 17:20:30 +00:00
Jonathan Peyton 6d247f71c3 [OMPT] Fix assertion that arises when waiting for proxy tasks on runtime shutdown
This only triggered when built in debug mode with OMPT enabled:
__kmp_wait_template expected the state of the current thread to be either
ompt_state_idle or ompt_state_wait_barrier{,_implicit,_explicit}.

Patch by Jonas Hahnfeld

Differential Revision: http://reviews.llvm.org/D12754

llvm-svn: 247339
2015-09-10 21:33:50 +00:00
Jonathan Peyton df4d3dd659 Fix depth field bug and resize() function in hierarchical barrier
This is a follow up to the hierarchy cleanup patch.
Added some clarifying comments to hierarchy_info.
Fixed a bug with the depth field not being updated cleanly during a resize.
Fixed resize to first check capacity as determined by maxLevels before actually doing the full resize.

Differential Revision: http://reviews.llvm.org/D12562

llvm-svn: 247333
2015-09-10 20:34:32 +00:00
Jonathan Peyton 1707836b68 Cleanup of affinity hierarchy code.
Some of this is improvement to code suggested by Hal Finkel. Four changes here:
1.Cleanup of hierarchy code to handle all hierarchy cases whether affinity is available or not
2.Separated this and other classes and common functions out to a header file
3.Added a destructor-like fini function for the hierarchy (and call in __kmp_cleanup)
4.Remove some redundant code that is hopefully no longer needed

Differential Revision: http://reviews.llvm.org/D12449

llvm-svn: 247326
2015-09-10 19:22:07 +00:00
Jonathan Peyton d26e213d11 Fix hanging barriers if number of parallel regions exceeds UINT_MAX
The fix is to make b_arrived flag 64 bit in both structures - kmp_balign_team_t
and kmp_balign_t. Otherwise when flag in kmp_balign_team_t wrapped over
UINT_MAX the library hangs.

Differential Revision: http://reviews.llvm.org/D12563

llvm-svn: 247320
2015-09-10 18:44:30 +00:00
Jonathan Peyton cb549f836a Remove duplicate of num_threads assignment.
The th.th_team_nproc is assigned in __kmp_allocate_thread() just 3 lines above,
so there is no need to assign the same value again.

llvm-svn: 246703
2015-09-02 20:28:50 +00:00
Jonathan Peyton f89fbbb395 Remove fork_context argument from __kmp_join_call() when OMPT is off
Conditionally include the fork_context parameter to __kmp_join_call()
only if OMPT_SUPPORT=1

Differential Revision: http://reviews.llvm.org/D12495

llvm-svn: 246460
2015-08-31 18:15:00 +00:00
Jonathan Peyton afa300606a Follow up to r246426 (Break Fortran Module Files build)
The CMAKE_CURRENT_BINARY_DIR is only necessary on the DEPENDS part of
the add_custom_command to build the Fortran Modules.

llvm-svn: 246448
2015-08-31 15:52:32 +00:00
Andrey Churbanov f506f41434 D12403: Fix GCC warning 'always_inline function might not be inlinable'
llvm-svn: 246434
2015-08-31 12:32:55 +00:00
Andrey Churbanov 5830b19917 Fix for Fortran modules build (from C.Bergstrom)
llvm-svn: 246426
2015-08-31 09:21:21 +00:00
Jonathan Peyton ff7da34bc3 Add kmp_config.h.cmake
In r246314 (Removing expand-vars.pl) patch, I forgot to add kmp_config.h.cmake
This patch just adds it.

llvm-svn: 246317
2015-08-28 19:24:39 +00:00
Jonathan Peyton c0225ca276 [OpenMP] [CMake] Removing expand-vars.pl in favor of CMake's configure_file()
Currently, the libomp CMake build system uses a Perl script to configure files
(tools/expand-vars.pl). This patch replaces the use of the Perl script by using
CMake's configure_file() function. The major changes include:
1. *.var has every $KMP_* variable changed to @LIBOMP_*@
2. kmp_config.h.cmake is a new file which contains all the feature macros and
   #cmakedefine lines
3. Most of the -D lines have been moved from LibompDefinitions.cmake but some
   OS specific MACROs (e.g., _GNU_SOURCE) remain.
4. All expand-vars.pl related logic is removed from the CMake files.

One important note about this change is that it breaks the old Perl+Makefile
build system because it can't create kmp_config.h properly.

Differential Review: http://reviews.llvm.org/D12211

llvm-svn: 246314
2015-08-28 18:42:10 +00:00
Jonathan Peyton 851a2afce9 Update README.txt to include table of supported Power processors
Small patch to the README.txt file which adds a table that shows what compiler
version works on what Power processor. 

Patch by Carlo Bertolli

http://lists.llvm.org/pipermail/openmp-commits/2015-August/000595.html

llvm-svn: 246165
2015-08-27 17:19:17 +00:00
Jonathan Peyton d2eb3c73ad Put taskdata variables under KMP_DEBUG guards.
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
2015-08-26 20:02:21 +00:00
Jonathan Peyton fe9a1d7a69 Replace variables with definitions inside KMP_DEBUG_ASSERT statements
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
2015-08-26 19:58:48 +00:00