Commit Graph

1417 Commits

Author SHA1 Message Date
Peyton, Jonathan L 5aafdd7b88 [OpenMP] Introduce new file wrapper class for runtime
Introduce new kmp_safe_raii_file_t class with RAII semantics for file
open/close. It is essentially a wrapper around the C-style FILE* object.
This also unifies the way we error report if a file can't be opened.

Differential Revision: https://reviews.llvm.org/D92604
2020-12-15 14:46:30 -06:00
Hansang Bae 171ca93c54 [OpenMP] Initialize runtime in the forked child process
This patch enables serial initialization in the forked child process
to fix unstable runtime behavior when used with Python-based AI tools.

Differential Revision: https://reviews.llvm.org/D93230
2020-12-15 07:29:28 -06:00
Giorgis Georgakoudis e007b32864 [OpenMP] Add time profiling for libomptarget
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D93055
2020-12-11 18:53:37 -08:00
Jon Chesterfield ce93de3bb2 [libomptarget][nfc] Remove data_sharing type aliasing
[libomptarget][nfc] Remove data_sharing type aliasing

Libomptarget previous used __kmpc_data_sharing_slot to access values of type
__kmpc_data_sharing_{worker,master}_slot_static. This aliasing violation was
benign in practice. The master type has since been removed, so a single type
can be used instead.

This is particularly helpful for the transition to an openmp deviceRTL, as the
c++/openmp compiler for amdgcn currently rejects the flexible array member for
being an incomplete type. Serves the same purpose as abandoned D86324.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D93075
2020-12-11 02:13:34 +00:00
Hansang Bae c3b5009aa7 [OpenMP] Use RTM lock for OMP lock with synchronization hint
This patch introduces a new RTM lock type based on spin lock which is
used for OMP lock with speculative hint on supported architecture.

Differential Revision: https://reviews.llvm.org/D92615
2020-12-09 19:14:53 -06:00
Nawrin Sultana 540007b427 [OpenMP] Add strict mode in num_tasks and grainsize
This patch adds new API __kmpc_taskloop_5 to accomadate strict
modifier (introduced in OpenMP 5.1) in num_tasks and grainsize
clause.

Differential Revision: https://reviews.llvm.org/D92352
2020-12-09 16:46:30 -06:00
Peyton, Jonathan L fe3b244ef7 [OpenMP] Fix norespect affinity bug for Windows
KMP_AFFINITY=norespect was triggering an error because the underlying
process affinity mask was not updated to include the entire machine.
The Windows documentation states that the thread affinities must be
subsets of the process affinity. This patch also moves the printing
(for KMP_AFFINITY=verbose) of whether the initial mask was respected
out of each topology detection function and to one location where the
initial affinity mask is read.

Differential Revision: https://reviews.llvm.org/D92587
2020-12-09 14:32:48 -06:00
Peyton, Jonathan L 9b7d6a6bff [OpenMP] Fix too long name for shm segment on macOS
Remove the user id component to the shm segment name and just use
the pid like before.

Differential Revision: https://reviews.llvm.org/D92660
2020-12-09 14:31:15 -06:00
Jon Chesterfield 7c59614394 [libomptarget][amdgpu] clang-format src/rtl.cpp 2020-12-09 19:45:51 +00:00
Jon Chesterfield c9bc414840 [libomptarget][amdgpu] Let default number of teams equal number of CUs 2020-12-09 19:35:34 +00:00
Jon Chesterfield e191d31159 [libomptarget][amdgpu] Robust handling of device_environment symbol 2020-12-09 19:21:51 +00:00
Jon Chesterfield cab9f69235 [libomptarget][amdgpu] Improve diagnostics on arch mismatch 2020-12-09 18:55:53 +00:00
Giorgis Georgakoudis 18dff28958 [OpenMP] Add doxygen generation for the runtime
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D92779
2020-12-08 16:20:45 -08:00
AndreyChurbanov fff1abc406 [OpenMP] NFC: comment adjusted 2020-12-07 19:50:14 +03:00
AndreyChurbanov 22558c8501 [OpenMP] libomp: Fix possible NULL dereferences
Check pointer returned by strchr, as it can be NULL in case of broken
format of input string. Introduced new function __kmp_str_loc_numbers
for fast parsing of numbers only in the location string.
Also made some cleanup of __kmp_str_loc_init declaration and usage:
- changed type of init_fname parameter to bool;
- changed input from true to false in places where fname is not used.

Differential Revision: https://reviews.llvm.org/D90962
2020-12-07 19:09:07 +03:00
Jon Chesterfield 71f4693020 [libomptarget][amdgpu] Add plumbing to call into hostrpc lib, if linked 2020-12-07 15:24:01 +00:00
Jon Chesterfield e1b8e8a1f4 [libomptarget][amdgpu] Skip device_State allocation when using bss global 2020-12-06 12:13:56 +00:00
Joachim Protze a148216b31 [OpenMP][OMPT] Fix OMPT return address guard for gomp interface
D91692 missed various locations in kmp_gsupport, where the scope for
OMPT_STORE_RETURN_ADDRESS is too narrow, i.e. the scope ends before the OMPT
callback is called in some nested function.

This patch fixes the scoping issue, so that all OMPT tests pass, when the
tests are built with gcc.

Differential Revision: https://reviews.llvm.org/D92121
2020-12-05 19:06:28 +01:00
Joachim Protze d3ec512b1d [OpenMP][OMPT] Make sure that 0 is never used as ID in tests (NFC) 2020-12-04 18:41:56 +01:00
Jon Chesterfield f628eef98a [libomptarget][amdgpu] Fix latent race in load binary 2020-12-04 16:29:09 +00:00
Hansang Bae c4a22224d9 [OpenMP] Add __kmpc_omp_target_task_alloc to dllexport
This patch enables use of the entry on Windows.

Differential Revision: https://reviews.llvm.org/D92618
2020-12-04 08:11:14 -06:00
Jon Chesterfield ae9d96a656 [libomptarget][amdgpu] Address compiler warnings, drive by fixes
[libomptarget][amdgpu] Address compiler warnings, drive by fixes

Initialize some variables, remove unused ones.
Changes the debug printing condition to align with the aomp test suite.

Differential Revision: https://reviews.llvm.org/D92559
2020-12-03 11:09:12 +00:00
Pushpinder Singh afc09c6fe4 [libomptarget][AMDGPU] Remove MaxParallelLevel
Removes MaxParallelLevel references from rtl.cpp and drops
resulting dead code.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D92463
2020-12-03 00:27:03 -05:00
Terry Wilmarth e0665a9050 [OpenMP] Add support for Intel's umonitor/umwait
These changes add support for Intel's umonitor/umwait usage in wait
code, for architectures that support those intrinsic functions. Usage of
umonitor/umwait is off by default, but can be turned on by setting the
KMP_USER_LEVEL_MWAIT environment variable.

Differential Revision: https://reviews.llvm.org/D91189
2020-12-01 14:07:46 -06:00
AndreyChurbanov 6bf84871e9 [OpenMP] libomp: add UNLIKELY hints to rarely executed branches
Added UNLIKELY hint to one-time or rarely executed branches.
This improves performance of the library on some tasking benchmarks.

Differential Revision: https://reviews.llvm.org/D92322
2020-12-01 16:53:21 +03:00
Joachim Protze fd3d1b09c1 [OpenMP][Tests][NFC] Use FileCheck from cmake config 2020-11-30 23:16:56 +01:00
Todd Erdner 9615890db5 [OpenMP] libomp: change shm name to include UID, call unregister_lib on SIGTERM
With the change to using shared memory, there were a few problems that need to be fixed.
- The previous filename that was used for SHM only used process id. Given that process is
  usually based on 16bit number, this was causing some conflicts on machines. Thus we add
  UID to the name to prevent this.
- It appears under some conditions (SIGTERM, etc) the shared memory files were not getting
  cleaned up. Added a call to clean up the shm files under those conditions. For this user
  needs to set envirable KMP_HANDLE_SIGNALS to true.

Patch by Erdner, Todd <todd.erdner@intel.com>

Differential Revision: https://reviews.llvm.org/D91869
2020-12-01 00:40:47 +03:00
AndreyChurbanov f6f28b44ad [OpenMP] libomp: fix mutexinoutset dependence for proxy tasks
Once __kmp_task_finish is not executed for proxy tasks,
move mutexinoutset dependency code to __kmp_release_deps
which is executed for all task kinds.

Differential Revision: https://reviews.llvm.org/D92326
2020-12-01 00:13:31 +03:00
Joachim Protze 723be4042a [OpenMP][OMPT][NFC] Fix failing test
The test would fail for gcc, when built with debug flag.
2020-11-29 19:07:42 +01:00
Joachim Protze cdf9401df8 [OpenMP][OMPT][NFC] Fix flaky test
The test had a chance to finish the first task before the second task is
created. In this case, the dependences-pair event would not trigger.
2020-11-29 19:07:41 +01:00
Jon Chesterfield 89a0f48c58 [libomptarget][cuda] Detect missing symbols in plugin at build time
[libomptarget][cuda] Detect missing symbols in plugin at build time

Passes -z,defs to the linker. Error on unresolved symbol references.

Otherwise, those unresolved symbols present as target code running on the host
as the plugin fails to load. This is significantly harder to debug than a link
time error. Flag matches that passed by amdgcn and ve plugins.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D92143
2020-11-27 15:39:41 +00:00
Martin Storsjö 6b429668de [OpenMP][OMPT] Fix building with OMPT disabled after 6d3b81664a 2020-11-26 10:09:32 +02:00
Johannes Doerfert 227c8ff189 [OpenMP][Docs] Add more content, call coordinates, FAQ entries, links 2020-11-25 11:52:35 -06:00
AndreyChurbanov 9e3e332d27 [OpenMP] libomp: fix non-X86, non-AARCH64 builds
Commit https://reviews.llvm.org/rG7b5254223acbf2ef9cd278070c5a84ab278d7e5f
broke the build for some architectures, because macro KMP_PREFIX_UNDERSCORE
was defined only for x86, x86_64 and aarch64. This patch defines it for other
architectures (as a no-op).

Differential Revision: https://reviews.llvm.org/D92027
2020-11-25 20:40:23 +03:00
Joachim Protze 6d3b81664a [OpenMP][OMPT] Introduce a guard to handle OMPT return address
This is an alternative approach to address inconsistencies pointed out in: D90078
This patch makes sure that the return address is reset, when leaving the scope.
In some cases, I had to move the macro out of an if-statement to have it in the
right scope, in some cases I added an additional block to restrict the scope.

This patch does not handle inconsistencies, which might occur if the return
address is still set when we call into the application.

Test case (repeated_calls.c) provided by @hbae

Differential Revision: https://reviews.llvm.org/D91692
2020-11-25 18:17:44 +01:00
Isabel Thärigen b281a05dac [OpenMP][OMPT] Implement verbose tool loading
OpenMP 5.1 introduces the new env variable
OMP_TOOL_VERBOSE_INIT=(disabled|stdout|stderr|<filename>) to enable verbose
loading and initialization of OMPT tools.
This env variable helps to understand the cause when loading of a tool fails
(e.g., undefined symbols or dependency not in LD_LIBRARY_PATH)
Output of OMP_TOOL_VERBOSE_INIT is added for OMP_DISPLAY_ENV

Tests for this patch are integrated into the different existing tool loading
tests, making these tests more verbose. An Archer specific verbose test is
integrated into an existing Archer test.

Patch prepared by: Isabel Thärigen

Differential Revision: https://reviews.llvm.org/D91464
2020-11-25 18:17:44 +01:00
AndreyChurbanov 7b5254223a [OpenMP] fix asm code for for arm64 (AARCH64) for Darwin/macOS
Adjusted external reference for Darwin/AARCH64 link compatibility.
Made size directive conditional only if __ELF__ defined.

Patch by Michael_Pique <mpique@icloud.com>

Differential Revision: https://reviews.llvm.org/D88252
2020-11-24 13:08:24 +03:00
AndreyChurbanov 5644f734d6 Revert "[OpenMP] Add support for Intel's umonitor/umwait"
This reverts commit 9cfad5f9c5.
2020-11-20 12:16:34 +03:00
AndreyChurbanov 9cfad5f9c5 [OpenMP] Add support for Intel's umonitor/umwait
Patch by tlwilmar (Terry Wilmarth)

Differential Revision: https://reviews.llvm.org/D91189
2020-11-19 22:04:21 +03:00
cchen 7036fe8a0c [libomptarget] Add support for target update non-contiguous
This patch is the runtime support for https://reviews.llvm.org/D84192.

In order not to modify the tgt_target_data_update information but still be
able to pass the extra information for non-contiguous map item (offset,
count, and stride for each dimension), this patch overload arg when
the maptype is set as OMP_TGT_MAPTYPE_DESCRIPTOR. The origin arg is for
passing the pointer information, however, the overloaded arg is an
array of descriptor_dim:

```
struct descriptor_dim {
  int64_t offset;
  int64_t count;
  int64_t stride
};
```

and the array size is the dimension size. In addition, since we
have count and stride information in descriptor_dim, we can replace/overload the
arg_size parameter by using dimension size.

Reviewed By: grokos, tianshilei1992

Differential Revision: https://reviews.llvm.org/D82245
2020-11-19 11:33:27 -06:00
Joseph Huber da8bec47ab [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging
Summary:
Add support for passing source locations to libomptarget runtime functions using the ident_t struct present in the rest of the libomp API. This will allow the runtime system to give much more insightful error messages and debugging values.

Reviewers: jdoerfert grokos

Differential Revision: https://reviews.llvm.org/D87946
2020-11-19 12:01:53 -05:00
Joseph Huber 5378c6a4bf [OpenMP] Add Support for Mapping Names in Libomptarget RTL
Summary:
This patch adds basic support for priting the source location and names for the mapped variables. This patch does not support names for custom mappers. This is based on D89802.

Reviewers: jdoerfert

Differential Revision: https://reviews.llvm.org/D90172
2020-11-18 16:01:59 -05:00
Joseph Huber 97e55cfef5 [OpenMP] Add Passing in Original Declaration Names To Mapper API
Summary:
This patch adds support for passing in the original delcaration name in the source file to the libomptarget runtime. This will allow the runtime to provide more intelligent debugging messages. This patch takes the original expression parsed from the OpenMP map / update clause and provides a textual representation if it was explicitly mapped, otherwise it takes the name of the variable declaration as a fallback. The information in passed to the runtime in a global array of strings that matches the existing ident_t source location strings using ";name;filename;column;row;;"

Reviewers: jdoerfert

Differential Revision: https://reviews.llvm.org/D89802
2020-11-18 15:28:39 -05:00
Hansang Bae 44a11c342c [OpenMP] Use explicit type casting in kmp_atomic.cpp
Differential Revision: https://reviews.llvm.org/D91105
2020-11-17 14:31:13 -06:00
Nawrin Sultana 5439db05e7 [OpenMP] Add omp_realloc implementation
This patch adds omp_realloc function implementation according to
OpenMP 5.1 specification.

Differential Revision: https://reviews.llvm.org/D90971
2020-11-17 13:43:00 -06:00
Peyton, Jonathan L 8647c669a4 [OpenMP] NFC: remove tabs in message catalog file 2020-11-17 10:15:04 -06:00
Peyton, Jonathan L 0454154efd [OpenMP][stats] reset serial state when re-entering serial region
Differential Revision: https://reviews.llvm.org/D90867
2020-11-17 10:09:56 -06:00
Joachim Protze fdc9dfc8e4 [OpenMP][Tool] Add Archer option to disable data race analysis for sequential part
This introduces the new `ARCHER_OPTIONS` flag `ignore_serial=0|1` to disable
analysis and logging of memory accesses in the sequential part of the OpenMP
application.

In the sequential part of an OpenMP program no data race is possible, unless
there is non-OpenMP concurrency (such as pthreads, MPI, ...). For the latter
reason, this is not active by default.

Besides reducing the runtime overhead for the sequential part of the program,
this reduces the memory overhead for sequential initialization. In combination
with `flush_shadow=1` this can allow analysis of applications, which run close
to the limit of available memory, but only access smaller parts of shared
memory during each OpenMP parallel region.

A problem for this approach is that Archer only gets active, when the OpenMP
runtime gets initialized, which might be after serial initialization of the
application. In such case, it helps to call for example `omp_get_max_threads()`
at the beginning of main.

Differential Revision: https://reviews.llvm.org/D90473
2020-11-16 10:45:21 +01:00
Martin Storsjö 9bcef58b63 [OpenMP] Fix building for windows after adding omp_calloc
Differential Revision: https://reviews.llvm.org/D91478
2020-11-15 21:32:38 +02:00
Nawrin Sultana 938f1b8581 [OpenMP] Add omp_calloc implementation
This patch adds omp_calloc implementation according to OpenMP 5.1
specification.

Differential Revision: https://reviews.llvm.org/D90967
2020-11-13 14:35:46 -06:00