1327 Commits

Author SHA1 Message Date
Shilei Tian
5ba8ecb6cc [Clang][OpenMP] Find the type omp_allocator_handle_t from identifier table
In Clang, in order to determine the type of `omp_allocator_handle_t`, Clang
checks the type of those predefined allocators. The first one it checks is
`omp_null_allocator`. If the language is C, and the system is 64-bit, what Clang
gets is a `int`, instead of an enum of size 8, given the fact how we define
`omp_allocator_handle_t` in `omp.h`.  If the allocator is captured by a region,
let's say a parallel region, the allocator will be privatized. Because Clang deems
`omp_allocator_handle_t` as an `int`, it will first cast the value returned by
the runtime library (for `libomp` it is a `void *`) to `int`, and then in the
outlined function, it casts back to `omp_allocator_handle_t`. This two casts
completely shaves the first 32-bit of the pointer value returned from `libomp`,
and when the private "new" pointer is fed to another runtime function
`__kmpc_allocate()`, it causes segment fault. That is the root cause of PR54082.
I have no idea why `-fno-pic` could hide this bug.

In this patch, we detect `omp_allocator_handle_t` using roughly the same method
as `omp_event_handle_t`, by looking it up into the identifier table.

Fix #54082.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D142297
2023-01-24 22:49:05 -05:00
Shilei Tian
dafebd5b5a [OpenMP] Create a temp file in /tmp if /dev/shm is not accessible
When `libomp` is initialized, it creates a temp file in `/dev/shm` to store
registration flag. Some systems, like Android, don't have `/dev/shm`, then this
feature is disabled by the macro `KMP_USE_SHM`, though most Linux distributions
have that. However, some customized distribution, such as the one reported in
https://github.com/llvm/llvm-project/issues/53955, doesn't support it either.
It causes a core dump. In this patch, if it is the case, we will try to create a
temporary file in `/tmp`, and if it still doesn't make it, then we error out.
Note that we don't consider in this patch if the temporary directory has been
set to `TMPDIR` in this patch. If `/tmp` is not accessible, we error out.

Fix #53955.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142175
2023-01-24 21:45:38 -05:00
Shilei Tian
7e89420116 [OpenMP] Disable tests that are not supported by GCC if it is used for testing
GCC doesn't support `-fopenmp-version`, causing test failure if the compiler used
for testing is GCC.

GCC's OpenMP 5.2 support is very limited yet. Disable those tests requiring 5.2
feature for GCC as well.

We might want to take a look at all `libomp` tests and mark those tests that
don't support GCC yet.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D142173
2023-01-24 17:00:15 -05:00
Terry Wilmarth
4c58e5a28f [OpenMP] Fix for distributed barrier.
Distributed barrier was found to cause hangs in some test cases. Found
that a section updating the barrier size was improperly shifted to a
different code section during patching.  Restored to original
location, all tests run to completion.

Differential Revision: https://reviews.llvm.org/D141618
2023-01-20 13:54:25 -06:00
Shilei Tian
50d2a193a7 [OpenMP] Only test kmp_atomic_float10_max_min.c on X86
The test `openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c` uses a compiler
flag `-mlong-double-80` that might not be supported by all targets. Currently it
requires `x86-registered-target`, but that requirement can be true when LLVM
supports X86 while the actual `libomp` arch is not X86. For example, when LLVM
is built on AArch64 with all targets enabled, `x86-registered-target` can be met.
If `libomp` is built with native target, aka. AArch64, the test will still be enabled,
causing test failure.

This patch only enables the test if the actual target is X86. The actual target
is determined by `LIBOMP_ARCH`.

Fix #53696.

Reviewed By: jlpeyton

Differential Revision: https://reviews.llvm.org/D142172
2023-01-20 10:52:53 -05:00
Gilles Gouaillardet
3a362a9f38 [OpenMP][libomp] Insert correct HWLOC version guards
Put needed HWLOC version guards around relevant HWLOC API.
Tested OpenMP host runtime build with HWLOC 1.11.13, 2.0-2.9.

Differential Revision: https://reviews.llvm.org/D142152
Fix #54951
2023-01-19 14:30:43 -06:00
Shilei Tian
97ae7d83e3 [OpenMP][OMPT] Expect failure from tool_available_search.c on macOS
D91464 introduced verbose tool loading, but the test check only considers Linux.
On macOS, the outputs are totally different, causing the regression afterwards.
This patch simply sets the test to XFAIL on macOS.

Fix #56833.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142045
2023-01-18 20:09:06 -05:00
Shilei Tian
a4f246a83e [OpenMP] Fix inconsistent task state if hot team is not used
This patch fixes the inconsistent task state when hot team is not used.
When the primary thread executes `__kmp_join_call`, it calls `__kmp_free_team`,
where worker threads will get destroyed if not using hot team. The destroy of
worker threads also reset their task state. However, the primary thread's is not
reset. When the next parallel region is encountered, in `__kmp_task_team_sync`,
the task state of thread will be flipped. Since the state of primary thread is not
reset, it is still 1, but all the worker threads will be 0, this leads to the
inconsistent task state, causing those threads are using completely different
task team.

Fix #59190.

Reviewed By: tlwilmar

Differential Revision: https://reviews.llvm.org/D141979
2023-01-18 18:21:57 -05:00
Jonathan Peyton
2aea0a9de0 [OpenMP][libomp] Switch Intel topology type values: module, tile
According to Software Developer Manual, modules should be value 3 and
tile should be value 4.
2023-01-18 12:11:43 -06:00
Jonathan Peyton
f311922535 [OpenMP][libomp] Fix stats-gathering for new MSVC sections API
Differential Revision: https://reviews.llvm.org/D139867
2023-01-18 11:59:12 -06:00
Jonathan Peyton
f4cce0f47b [OpenMP][libomp] Add topology information to thread structure
Each time a thread gets a new affinity assigned, it will not
only assign its mask, but also topology information including
which socket, core, thread and core-attributes (if available)
it is now assigned. This occurs for all non-disabled KMP_AFFINITY
values as well as OMP_PLACES/OMP_PROC_BIND.

The information regarding which socket, core, etc. can take on three
values:
  1) The actual ID of the unit (0 - (N-1)), given N units
  2) UNKNOWN_ID (-1) which indicates it does not know which ID
  3) MULTIPLE_ID (-2) which indicates the thread is spread across
     multiple of this unit (e.g., affinity mask is spread across
     multiple hardware threads)
This new information is stored in th_topology_ids[] array. An example
how to get the socket Id, one would read th_topology_ids[KMP_HW_SOCKET].
This could be expanded in the future to something more descriptive for
the "multiple" case, like a range of values. For now, the single
value suffices.

The information regarding the core attributes can take on two values:
  1) The actual core-type or core-eff
  2) KMP_HW_CORE_TYPE_UNKNOWN if the core type is unknown, and
     UNKNOWN_CORE_EFF (-1) if the core eff is unknown.
This new information is stored in th_topology_attrs. An example
how to get the core type, one would read
th_topology_attrs.core_type.

Differential Revision: https://reviews.llvm.org/D139854
2023-01-16 23:04:06 -06:00
Shilei Tian
4e27097c5b [OpenMP] Fix the wrong format string used in __kmpc_error
This patch fixes the wrong format string used in `__kmpc_error`, which could
cause segment fault at runtime.

Reviewed By: jlpeyton

Differential Revision: https://reviews.llvm.org/D141889
2023-01-16 23:55:26 -05:00
Jonathan Peyton
0aa5aebd0a [OpenMP][libomp] Fix macOS 12 library destruction
When building the library with icc and using it on macOS 12,
the library destruction process is skipped which has many OMPT tests
failing for macOS 12. This change registers the
__kmp_internal_end_library() call for atexit() which will be a
harmless, redundant call for macOS 11 and below and the only destructor
called for macOS 12+.

Differential Revision: https://reviews.llvm.org/D139857
2023-01-16 22:42:18 -06:00
Carlo Bertolli
b215932e69 [OpenMP][libomptarget][AMDGPU] lock/unlock (pin/unpin) mechanism in libomptarget amdgpu plugin (API and implementation)
The current only way to obtain pinned memory with libomptarget is to use a custom allocator llvm_omp_target_alloc_host.
This reflects well the CUDA implementation of libomptarget, but it does not correctly expose the AMDGPU runtime API,
where any system allocated page can be locked/unlocked through a call to hsa_amd_memory_lock/unlock.
This patch enables users to allocate memory through malloc (mmap, sbreak) and then pin the related memory pages
with a libomptarget special call. It is a base support in the amdgpu libomptarget plugin to enable users to prelock
their host memory pages so that the runtime doesn't need to lock them itself for asynchronous memory transfers.

Reviewed By: jdoerfert, ye-luo

Differential Revision: https://reviews.llvm.org/D139208
2023-01-13 12:18:49 -06:00
Nawrin Sultana
c17e40ba52 [OpenMP] Fix dynamic schedule assertion failure on AArch64
This patch fixes assertion failure in dynamic schedule with 8 byte induction
variable. It uses acquire load instead of relaxed to ensure that steal_lock
pointer is not NULL.

Differential Revision: https://reviews.llvm.org/D139373
2023-01-12 14:43:54 -06:00
Terry Wilmarth
9830a5d0c1 [OpenMP] Fix for smaller team sizes inside teams construct.
When a team nested inside a teams construct is allocated, it is
allocated to a size specified by the teams thread_limit.  In the case
where any mechanism that might not grant the full thread_limit is in
use, we may get a smaller team.  This possibility was not reflected in
the code when using the th_teams_size.nth value stored on the master
thread for the team. This value was never updated even when t_nproc on
the team itself was different.  I added a line to update it shortly
before the team is forked.

Added a simple teams test that uses KMP_DYNAMIC_MODE=random to mimic
allocating teams with sizes <= thread_limit. Eventually, this
will segfault without the fix in this commit.

Differential Revision: https://reviews.llvm.org/D139960
2023-01-11 11:24:21 -06:00
JP Lehr
263962545d [OpenMP] Solve potential VERSION script error w/ OMPT symbols
The patch adds the symbols if OMPT_SUPPORT is not defined.
Github issue: https://github.com/llvm/llvm-project/issues/59660

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D140591
2023-01-03 16:47:12 -05:00
Guilherme Valarini
4e32d5cedf [OpenMP] Disable libomptarget integration on unsupported platforms
Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D140419
2022-12-20 16:41:43 -03:00
Sunil Kuravinakop
e9babe7571 [OpenMP] Clang Support for taskwait nowait clause
Support for taskwait nowait clause with placeholder for runtime changes.

Reviewed By: cchen, ABataev

Differential Revision: https://reviews.llvm.org/D131830
2022-12-20 12:13:56 -06:00
Carlo Bertolli
ac52c8f589 [OpenMP] Add missing test for pinned memory API
I accidentally left out the test for the pinned API introduced by D138933. Adding it back.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D140077
2022-12-15 21:29:15 -06:00
Guilherme Valarini
89c82c8394 [OpenMP] Add non-blocking support for target nowait regions
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-14 14:03:32 -03:00
Carlo Bertolli
d6281caa34 [OpenMP] Add API for pinned memory
This patch adds API support for the atk_pinned trait for omp_alloc.
It does not implement kmp_target_lock_mem and kmp_target_unlock_mem in libomptarget,
but prepares libomp for it. Patches to libomptarget to implement
lock/unlock coming after this one.

Reviewed by: jlpeyton, jdoerfert

Differential Revision: https://reviews.llvm.org/D138933
2022-12-14 08:50:10 -06:00
Martin Storsjö
15151315f7 [OpenMP] Add a missing dllexport for the new function __kmpc_fork_call_if
This new function was added in b72f1ec9fbb14cd7d2f5112d2c52ef5cdd1aa94a,
but wasn't exported from the DLL on Windows.

This fixes the parallel/omp_parallel_if.c OpenMP testcase on
Windows.
2022-12-14 14:19:10 +02:00
Martin Storsjö
93c011eebb [OpenMP] Fix detecting warning options for GCC
If testing for a warning option like -Wno-<foo> with GCC, GCC won't
print any diagnostic at all, leading to the options being accepted
incorrectly. However later, if compiling a file that actually prints
another warning, GCC will also print warnings about these -Wno-<foo>
options being unrecognized.

This avoids warning spam like this, for every OpenMP source file that
produces build warnings with GCC:

    cc1plus: warning: unrecognized command line option ‘-Wno-int-to-void-pointer-cast’
    cc1plus: warning: unrecognized command line option ‘-Wno-return-type-c-linkage’
    cc1plus: warning: unrecognized command line option ‘-Wno-covered-switch-default’
    cc1plus: warning: unrecognized command line option ‘-Wno-enum-constexpr-conversion’

This matches how such warning options are detected and added in
llvm/cmake/modules/HandleLLVMOptions.cmake, e.g. like this:

    check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
    append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)

This also matches how LLDB warning options were restructured for
GCC compatibility in e546bbfda0ab91cf78c096d8c035851cc7c3b9f3.

Differential Revision: https://reviews.llvm.org/D139922
2022-12-14 14:19:03 +02:00
gonglingqin
b49d3e50e3 [OpenMP][Test] Make the output error message consistent with the comment
Modify the error message output of affinity/kmp-affinity.c and
affinity/omp-places.c.

Differential Revision: https://reviews.llvm.org/D139803
2022-12-14 10:07:15 +08:00
gonglingqin
9a0831afa0 [OpenMP] Skip extra blank line when parsing /proc/cpuinfo on LoongArch64
This fixes the following test cases:

* affinity/kmp-affinity.c
* affinity/kmp-hw-subset.c
* affinity/omp-places.c

Differential Revision: https://reviews.llvm.org/D139802
2022-12-13 20:13:10 +08:00
Terry Wilmarth
bc6cc63ab8 [OpenMP] Refactoring: Move teams forking and serial region forking to separate functions.
Code for serial parallel regions and teams construct have been moved
out of __kmp_fork_call and into separate functions.  This is to reduce
the size of the __kmp_fork_call function, and aid in debugging.

Differential Revision: https://reviews.llvm.org/D139116
2022-12-12 17:19:53 -06:00
Chi Chun Chen
e0fd86db09 Revert "[OpenMP] Clang Support for taskwait nowait clause"
This reverts commit 100dfe7a8ad3789a98df623482b88d9a3a02e176.
2022-12-09 11:06:45 -06:00
David Truby
b72f1ec9fb [openmp][mlir] Lower parallel if to new fork_call_if function.
This patch adds a new runtime function `fork_call_if` and uses that
to lower parallel if statements when going through OpenMPIRBuilder.

This fixes an issue where the OpenMPIRBuilder passes all arguments to
fork_call as a struct but this struct is not filled corretly in the
non-if branch by handling the fork inside the runtime.

Differential Revision: https://reviews.llvm.org/D138495
2022-12-09 14:23:27 +00:00
Martin Storsjö
c2a289dbdf [openmp] Provide an assembly implementation of __kmp_invoke_microtask on ARM
This fixes passing an arbitrarily large number of arguments to
microtasks, fixing the misc_bugs/many-microtask-args.c testcase on
ARM.

Differential Revision: https://reviews.llvm.org/D138704
2022-12-08 22:53:28 +02:00
Sunil K
100dfe7a8a [OpenMP] Clang Support for taskwait nowait clause
Support for taskwait nowait clause with placeholder for runtime changes.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D131830
2022-12-08 12:40:44 -08:00
Joseph Huber
c6e6231e2f [OpenMP][libomp] Fix version scripts after undefined version script changes
Summary:
Building with `lld` now errors on undefined symbols by default now. This
was causing `libomp` to think that the compiler didn't support version
scripts when checking linker features. This patch adds a new script that
exports all symbols to be used for testing. We also remove the old
workarounds for undefined versions now that it's no longer necessary.
2022-12-08 13:37:03 -05:00
Bran Hagger
7a795c42ad Enable kmpc_atomic functions for arm64
Define the same kmpc_atomic functions for arm and arm64 that are defined for x86 and x64.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D139139
2022-12-07 23:38:12 +02:00
zhanglimin
600c2b0f1e [OMPT][test] Fix mismatch error between the current address and the return address for LoongArch
This patch fixes tests masked.c and master.c on LoongArch.

Reviewed By: SixWeining, protze.joachim

Differential Revision: https://reviews.llvm.org/D138785
2022-12-07 11:58:28 +08:00
Jonathan Peyton
fef73b81e9 [OpenMP][libomp] Cleanup version script and exported symbols
This patch fixes issues seen once https://reviews.llvm.org/D135402 is applied.

The exports_so.txt file attempts to export functions which may not exist
depending on which features are enabled/disabled in the OpenMP
runtime library. There are not many of these so exporting dummy
symbols is feasible.

* Export dummy __kmp_reset_stats() function when stats is disabled.
* Export dummy debugging data when USE_DEBUGGER is disabled
* Export dummy __kmp_itt_[fini|init]_ittlib() functions
   when ITT Notify is disabled
* Export dummy __kmp_reap_monitor() function when KMP_USE_MONITOR
  is disabled
* Remove __kmp_launch_monitor and __kmp_launch_worker from being exported.
  They have been static symbols since library inception.

Fixes: https://github.com/llvm/llvm-project/issues/58858
Differential Revision: https://reviews.llvm.org/D138049
2022-12-06 08:33:31 -06:00
Nawrin Sultana
e6d2665df3 [OpenMP] Let predefined allocator fallback to default instead of returning null
Differential Revision: https://reviews.llvm.org/D139376
2022-12-05 20:52:51 -06:00
Ron Lieberman
b09a5e5cb3 Revert "Add mean_anyway to hpc config"
my bad, wrong repo ,so sorry.

This reverts commit 0b9350f3da7daf1d740bbbfab79d01613fcd29f4.
2022-11-29 15:20:23 -06:00
Martin Storsjö
624e9e1318 [openmp] [test] Use stdint.h instead of manual code defining kmp_int*. NFC.
Differential Revision: https://reviews.llvm.org/D138818
2022-11-29 23:16:11 +02:00
Martin Storsjö
2bd2734f44 Reapply [openmp] [test] XFAIL many-microtask-args.c on ARM
On ARM, a C fallback version of __kmp_invoke_microtask is used,
which only handles up to a fixed number of arguments - while
many-microtask-args.c tests that the function can handle an
arbitrarily large number of arguments (the testcase produces 17
arguments).

On the CMake level, we can't add ${LIBOMP_ARCH} directly to
OPENMP_TEST_COMPILER_FEATURES in OpenMPTesting.cmake, since
that file is parsed before LIBOMP_ARCH is set. Instead
convert the feature list into a proper CMake list, and append
${LIBOMP_ARCH} into it before serializing it to an Python array.

Reapply: Make sure OPENMP_TEST_COMPILER_FEATURES is defined
properly in all other test subdirectories other than
runtime/test too.

Differential Revision: https://reviews.llvm.org/D138738
2022-11-29 23:16:10 +02:00
Ron Lieberman
0b9350f3da Add mean_anyway to hpc config 2022-11-29 15:11:57 -06:00
Martin Storsjö
5611bf69fc Revert "[openmp] [test] XFAIL many-microtask-args.c on ARM"
This reverts commit 03bf001b6d95f7c6a88a2b95f3cad752b9d1ed45.

This commit broke a number of OpenMP buildbots, e.g.
https://lab.llvm.org/buildbot#builders/84/builds/31839, where
the build ends up with errors like this:

[0/1] Running OpenMP tests
llvm-lit: /b/1/openmp-clang-x86_64-linux-debian/llvm.src/llvm/utils/lit/lit/TestingConfig.py:140: fatal: unable to parse config file '/b/1/openmp-clang-x86_64-linux-debian/llvm.build/projects/openmp/libomptarget/test/x86_64-pc-linux-gnu/lit.site.cfg', traceback: Traceback (most recent call last):
 File "/b/1/openmp-clang-x86_64-linux-debian/llvm.src/llvm/utils/lit/lit/TestingConfig.py", line 129, in load_from_path
   exec(compile(data, path, 'exec'), cfg_globals, None)
 File "/b/1/openmp-clang-x86_64-linux-debian/llvm.build/projects/openmp/libomptarget/test/x86_64-pc-linux-gnu/lit.site.cfg", line 6
   config.test_compiler_features =
                                   ^
SyntaxError: invalid syntax
2022-11-28 23:08:10 +02:00
Martin Storsjö
4ed8fcc59a [openmp] [test] Fix data structure mismatches for tests that define kmp_depend_info
Use the correct data type for pointer sized integers on Windows;
"long" is always 32 bit, even on 64 bit Windows - don't use it
for the kmp_intptr_t type.

Provide the exact correct definition of the kmp_depend_info
struct - avoid the risk of mismatches (if a platform would pack
things slightly differently when things are declared differently).

Zero initialize the whole dep_info struct before filling it in;
if only setting the in/out bits, the rest of the unallocated bits
in the bitfield can have undefined values. Libomp reads the flags
in combined form as an kmp_uint8 by reading the flag field - thus,
the unused bits do need to be zeroed. (Alternatively, the flag field
could be set to zero before setting the individual bits in the
bitfield).

Use kmp_intptr_t instead of long for casting pointers to integers.

Differential Revision: https://reviews.llvm.org/D137748
2022-11-28 22:40:02 +02:00
Martin Storsjö
03bf001b6d [openmp] [test] XFAIL many-microtask-args.c on ARM
On ARM, a C fallback version of __kmp_invoke_microtask is used,
which only handles up to a fixed number of arguments - while
many-microtask-args.c tests that the function can handle an
arbitrarily large number of arguments (the testcase produces 17
arguments).

On the CMake level, we can't add ${LIBOMP_ARCH} directly to
OPENMP_TEST_COMPILER_FEATURES in OpenMPTesting.cmake, since
that file is parsed before LIBOMP_ARCH is set. Instead
convert the feature list into a proper CMake list, and append
${LIBOMP_ARCH} into it before serializing it to an Python array.

Differential Revision: https://reviews.llvm.org/D138738
2022-11-28 22:40:02 +02:00
Martin Storsjö
63f0fdc262 [openmp] [test] Set __COMPAT_LAYER=RunAsInvoker when running tests on Windows
Windows heuristics may decide to want to run some tested processes
as elevated (since it may think some of them are installers - executables
with "dispatch" in the name may hit a heuristic looking for "patch").

Set this environment variable to disable this heuristic and just run
the executable with whatever privileges the caller has.

This fixes a couple tests on such versions of Windows where this
heuristic is active.

Differential Revision: https://reviews.llvm.org/D137772
2022-11-28 22:40:01 +02:00
Martin Storsjö
db6406acec [openmp] Use GCC style intrinsics for atomics on Clang-cl on aarch64 too
This fixes compilation in the Clang-cl configuration on aarch64;
Clang doesn't implement all the aarch64 MSVC atomic intrinsics yet.

Differential Revision: https://reviews.llvm.org/D138737
2022-11-28 22:40:01 +02:00
Martin Storsjö
97958c9bb8 [openmp] Support building for armv7 Windows with mingw tools
This does things in the same way as
D137168 / a356782426f5bf54a00570e1f925345e5fda7b2e and
D101173 / 4fb0aaf03381473ec8af727edb4b5d59b64b0d60 did for aarch64.

This adds a C implementation of __kmp_invoke_microtask in the same
way as the fallback C implementation in z_Linux_util.cpp.

Both the existing C fallback used on arm linux, and this one added here,
fail test/misc_bugs/many-microtask-args.c similarly (which could be
considered as an XFAIL).

Differential Revision: https://reviews.llvm.org/D138689
2022-11-25 21:46:31 +02:00
Martin Storsjö
d6ab42dec4 [openmp] Fix build break for less common architectures
fb947c358661b3bd3d5e1fa776ec74cc0f308854 introduced the gas
macro COMMON, but it was only defined within ifdefs of the form:

    #if (KMP_OS_LINUX || KMP_OS_DARWIN || KMP_OS_WINDOWS) && KMP_ARCH_AARCH64

It was used, however, within other conditions:

    #if KMP_ARCH_ARM || KMP_ARCH_MIPS

and:

    #if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64

Move the definition of the COMMON macro out from the current ifdef,
so that it always gets defined (as it's only dependent on the target
platform).

This fixes building on ARM (and presumably all the other mentioned
architectures except aarch64).

Differential Revision: https://reviews.llvm.org/D138703
2022-11-25 21:46:31 +02:00
Martin Storsjö
fb947c3586 [openmp] Use z_Linux_asm.S to provide __kmp_invoke_microtask with Clang for Windows/aarch64
When building for Windows aarch64, and not using the actual MSVC,
we can assemble gnu assembly files just fine, and the existing
correct implementation of __kmp_invoke_microtask is fully usable.

The C implementation of __kmp_invoke_microtask in
z_Windows_NT-586_util.cpp relies on unguaranteed assumptions about
the compiler behaviour - it does work currently on MSVC, but doesn't
necessarily on other compilers. That function uses an alloca to pass
parameters on the stack to the called functions.

There's no guarantee that the buffer allocated by alloca is exactly
at the bottom of the stack when doing the call; the compiler might
have left space for extra things to save on the stack there.

Additionally, when compiled with Clang with optimization, Clang
optimizes out the alloca and memcpy entirely. On the C language
level, they don't have any visible effect outside of the function
and thus can be omitted entirely.

This fixes calling microtasks with more than 6 parameters, in
builds for Windows/aarch64 with Clang.

Differential Revision: https://reviews.llvm.org/D137827
2022-11-24 23:06:21 +02:00
Fangrui Song
cae1942297 [CMake][OpenMP] Remove -Wl,--warn-shared-textrel
This option is legacy and is removed from GNU ld's doc (many binutils
distributions are configured with --enable-textrel-check=). lld ignores the
option.
2022-11-21 00:37:32 +00:00
Martin Storsjö
a6440b0fc5 [openmp] [test] Fix warnings about printf format mismatches on Windows
This fixes warnings like this:

```
openmp/runtime/test/omp_testsuite.h:107:60: warning: format specifies type 'unsigned int' but the argument has type 'DWORD' (aka 'unsigned long') [-Wformat]
    fprintf(stderr, "CreateThread() failed: Error #%u.\n", GetLastError());
                                                   ~~      ^~~~~~~~~~~~~~
                                                   %lu
```

Differential Revision: https://reviews.llvm.org/D137747
2022-11-18 08:50:26 +02:00