1646 Commits

Author SHA1 Message Date
MessyHack
ea848d0a6d
[OpenMP] Sort topology after adding processor group layer. (#83943)
Various behavior around creating affinity masks and detecting uniform
topology depends on the topology being sorted.

resort topology after adding processor group layer to ensure that the
updated topology reflects the newly added processor group info.

Observed that the topology was not sorted correctly on high core count
AMD Epyc Genoa (2 sockets, 96 cores, 2 threads) using NUMA (NPS 2+).
2024-03-13 16:22:23 -05:00
Jonathan Peyton
6272500e0b
[OpenMP] Remove unused logical/physical CPUID information (#83298) 2024-03-12 11:37:01 -07:00
Jonathan Peyton
3303be63fc
[OpenMP] Make sure mask is set to nullptr (#83299) 2024-03-12 11:36:43 -07:00
Jonathan Peyton
f5334f5da5
[OpenMP] Add debug checks for divide by zero (#83300) 2024-03-12 11:36:19 -07:00
Jonathan Peyton
9b1c496898
[OpenMP] Fixup while loops to avoid bad NULL check (#83302) 2024-03-11 10:28:12 -05:00
Jonathan Peyton
de4d7015d0
[OpenMP] Remove unnecessary check of ap (#83303) 2024-03-11 10:27:53 -05:00
Jonathan Peyton
1ed463d961
[OpenMP] Make sure ptr is used after NULL check (#83304) 2024-03-11 10:27:31 -05:00
Jonathan Peyton
b4e39ad117
[OpenMP] Remove dead code of checking int > INT_MAX (#83305) 2024-03-11 10:26:53 -05:00
David CARLIER
facb89ae12
[openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#84626) 2024-03-11 13:15:43 +00:00
David CARLIER
fa4cc39255
[openmp] adding affinity support to DragonFlyBSD. (#84672) 2024-03-10 09:56:55 +00:00
Vadim Paretsky
110141b378
[OpenMP] fix endianness dependent definitions in OMP headers for MSVC (#84540)
MSVC does not define __BYTE_ORDER__ making the check for BigEndian
erroneously evaluate to true and breaking the struct definitions in MSVC
compiled builds correspondingly. The fix adds an additional check for
whether __BYTE_ORDER__ is defined by the compiler to fix these.

---------

Co-authored-by: Vadim Paretsky <b-vadipa@microsoft.com>
2024-03-09 10:47:31 -08:00
David CARLIER
11cd2a33f1
[openmp] porting affinity feature to netbsd. (#84618)
netbsd supports the portable hwloc's layer as well. for a hardware with
4 cpus, a cpu set is 4 and maxcpus is 256.
2024-03-09 11:45:07 +00:00
David CARLIER
05280b582a
[OpenMP] Implements __kmp_is_address_mapped for Solaris/Illumos. (#82930)
Also fixing OpenMP build itself for this platform.
2024-03-08 20:34:43 +00:00
vadikp-intel
fcd2d48325
[OpenMP] runtime support for efficient partitioning of collapsed triangular loops (#83939)
This PR adds OMP runtime support for more efficient partitioning of
certain types of collapsed loops that can be used by compilers that
support loop collapsing (i.e. MSVC) to achieve more optimal thread load
balancing.

In particular, this PR addresses double nested upper and lower isosceles
triangular loops of the following types

1. lower triangular 'less_than'
   for (int i=0; i<N; i++)
     for (int j=0; j<i; j++)
2. lower triangular 'less_than_equal'
   for (int i=0; i<N; j++)
     for (int j=0; j<=i; j++)
3. upper triangular
   for (int i=0; i<N; i++)
     for (int j=i; j<N; j++)

Includes tests for the three supported loop types.

---------

Co-authored-by: Vadim Paretsky <b-vadipa@microsoft.com>
2024-03-07 16:28:03 -08:00
Jonathan Peyton
0e0bee26e7
[OpenMP] Fix distributed barrier hang for OMP_WAIT_POLICY=passive (#83058)
The resume thread logic inside __kmp_free_team() is faulty. Only
checking b_go for sleep status doesn't wake up distributed barrier.
Change to generic check for th_sleep_loc and calling
__kmp_null_resume_wrapper().

Fixes: #80664
2024-02-27 14:15:48 -06:00
Joachim
822142ffdf
[OpenMP][OMPD] libompd must not link libomp (#83119)
Fixes a regression introduced in 91ccd8248.
The code for libompd includes kmp.h for enum kmp_sched. The dependency
to hwloc is not necessary. Avoid the dependency by skipping the
definitions in kmp.h using types from hwloc.h.

Fixes #80750
2024-02-27 16:24:55 +01:00
Xing Xue
a4dcfbcb78
[OpenMP][AIX] XFAIL capacity tests on AIX in 32-bit (#83014)
This patch XFAILs two capacity tests on AIX in 32-bit because running
out resource with `4 x omp_get_max_threads()` in 32-bit mode.
2024-02-26 13:13:05 -05:00
David CARLIER
9e7c0b1385
[OpenMP] Implement __kmp_is_address_mapped on DragonFlyBSD. (#82895)
implement internal __kmp_is_address_mapped.
2024-02-25 14:13:04 +00:00
Xing Xue
94100bc2fb
[OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770)
This patch adds assembly file `z_AIX_asm.S` that contains the 32- and
64-bit XCOFF version of microtasking routines and unnamed common block
definitions. This code has been run through the libomp LIT tests and a
user package successfully.
2024-02-20 12:08:37 -05:00
Martin Storsjö
4b9c089381
[OpenMP] [test] Skip the -mlong-double-80 test on MSVC ABI (#81115)
Within the MSVC ABI, long doubles are the same as regular 64 bit
doubles. This test case, which is compiled with -mlong-double-80, cannot
work when libomp has been compiled without that flag, as
-mlong-double-80 changes the calling convention for the tested
functions.
2024-02-19 11:33:28 +02:00
Xing Xue
2de269a641
[OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996)
This patch sets the stack size of worker threads to `2 x
KMP_DEFAULT_STKSIZE` (2 x 4MB) for AIX if the system stack size is too
big. Also defines maximum stack size for 32-bit AIX.
2024-02-16 15:12:41 -05:00
Xing Xue
ac97562c99
[OpenMP][AIX]Define struct kmp_base_tas_lock with the order of two members swapped for big-endian (#79188)
The direct lock data structure has bit `0` (the least significant bit)
of the first 32-bit word set to `1` to indicate it is a direct lock. On
the other hand, the first word (in 32-bit mode) or first two words (in
64-bit mode) of an indirect lock are the address of the entry allocated
from the indirect lock table. The runtime checks bit `0` of the first
32-bit word to tell if this is a direct or an indirect lock. This works
fine for 32-bit and 64-bit little-endian because its memory layout of a
64-bit address is (`low word`, `high word`). However, this causes
problems for big-endian where the memory layout of a 64-bit address is
(`high word`, `low word`). If an address of the indirect lock table
entry is something like `0x110035300`, i.e., (`0x1`, `0x10035300`), it
is treated as a direct lock. This patch defines `struct
kmp_base_tas_lock` with the ordering of the two 32-bit members flipped
for big-endian PPC64 so that when checking/setting tags in member
`poll`, the second word (the low word) is used. This patch also changes
places where `poll` is not already explicitly specified for
checking/setting tags.
2024-02-13 15:11:24 -05:00
Daniil Fukalov
94272a5a5d
[OpenMP] Fix libomp debug build. (#81029)
Disable libstdc++ assertions in the runtime library just like in
https://reviews.llvm.org/D143168.
2024-02-09 17:54:14 +01:00
Xing Xue
7a9b0e4acb
[OpenMP][test]Flip bit-fields in 'struct flags' for big-endian in test cases (#79895)
This patch flips bit-fields in `struct flags` for big-endian in test
cases to be consistent with the definition of the structure in libomp
`kmp.h`.
2024-02-07 15:24:52 -05:00
vigbalu
edfc21a575
[OMPD] Runtime Entry Point functions for OMPD in libomp.so need C linkage as per standard. (#79246)
Adding extern "C" to all the entry point functions to make sure that
these functions are not mangled.
2024-02-06 10:12:47 +01:00
Martin Storsjö
2d2f962c9b
[openmp] Add a dependency on the separate import library (#80449)
Currently, when doing e.g. "ninja check-openmp", the check-openmp target
only depends on the target "omp", which builds the library. Thus by
doing that, the separate import library "libomp.lib", which is generated
directly from a def file, never gets created, unless one does a separate
invocation first, that builds all targets.

To fix this, make the "omp" target depend on the target for the separate
import library, whenever that is created/used.
2024-02-03 01:06:40 +01:00
Alexandre Ganea
ca0e241791 [openmp] Silence warning when compiling with MSVC targetting x86
This fixes:
```
[3593/7449] Building CXX object projects\openmp\runtime\src\CMakeFiles\omp.dir\kmp_debug.cpp.obj
C:\git\llvm-project\openmp\runtime\src\kmp_os.h(471): warning C4163: '_InlineInterlockedExchange64': not available as an intrinsic function
```
2024-01-25 09:34:19 -05:00
Alexandre Ganea
15fdc7646c Re-land [openmp] Fix warnings when building on Windows with latest MSVC or Clang ToT (#77853)
The reverts 94f960925b7f609636fc2ffd83053814d5e45ed1 and fixes it.
2024-01-23 12:48:38 -05:00
Alexandre Ganea
94f960925b Revert 10f3296dd7d74c975f208a8569221dc8f96d1db1 - [openmp] Fix warnings when building on Windows with latest MSVC or Clang ToT (#77853)
It broke the AMDGPU buildbot: https://lab.llvm.org/buildbot/#/builders/193/builds/45378
2024-01-23 08:51:12 -05:00
Alexandre Ganea
10f3296dd7
[openmp] Fix warnings when building on Windows with latest MSVC or Clang ToT (#77853)
There were quite a few compilation warnings when building openmp on Windows with
the latest Visual Studios 2022 version 17.8.4. Some other warnings were visible
with the latest Clang at tip. This commit fixes all of them.
2024-01-23 08:38:18 -05:00
Alexandre Ganea
0ac992e0ad [openmp] Revert 64874e5ab5fd102344d43ac9465537a44130bf19 since it was committed by mistake and the PR (https://github.com/llvm/llvm-project/pull/77853) wasn't approved yet. 2024-01-18 13:55:03 -05:00
Paul Osmialowski
d5b2e41e20
[OpenMP][omp_lib] Restore compatibility with more restrictive Fortran compilers (#77780)
The most recent changes to `omp_lib.h.var` have re-introduced some
compatibility issues that had to be fixed due to the similar changes in
the past. Namely:

1. D120707 has removed the "use omp_lib_kinds" statement and replaced it
with import

2. D114537 added line continuation to the long lines

This patch introduces the same kind of changes in order to restore
compatibility with some more restrictive Fortran compilers so their
users could still benefit from the LLVM's OpenMP Fortran library.
2024-01-18 11:06:24 +00:00
Alexandre Ganea
64874e5ab5 [openmp] Silence warnings when building the LLVM release with MSVC 2024-01-17 07:23:58 -05:00
Brad Smith
dc03382d3e
[openmp][AIX] Add AIX to __kmp_set_stack_info() (#77421) 2024-01-09 12:02:40 -05:00
Xing Xue
2edce427a8
[openmp][AIX]Initial changes for porting to AIX (#76841)
This PR contains initial changes for building and testing libomp on AIX.
More changes will follow.
- `KMP_OS_AIX` is defined for the AIX platform
- `KMP_ARCH_PPC` is defined for 32-bit PPC
- `KMP_ARCH_PPC_XCOFF` and `KMP_ARCH_PPC64_XCOFF` are for 32- and 64-bit
XCOFF object formats respectively
- Assembly file `z_AIX_asm.S` is used for AIX specific assembly code and
will be added in a separate PR
- The target library is disabled because AIX does not have the device
support
- OMPT is temporarily disabled
2024-01-08 08:33:00 -05:00
Carlos Eduardo Seo
dcd7c8b7c9
[OpenMP][AArch64] Workaround for ompt/synchronization tests (#75848)
ompt/synchronization/[masked.c | master.c] tests fail due to a wrong
offset being calculated for the possible return addreses. PR #65936
fixes this for Darwin and the same has to be done for Linux.

Updates #69627
2023-12-19 19:26:23 +01:00
Shilei Tian
a4d1d5f5b5 [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-12-15 15:12:33 -05:00
Andrew Brown
68ea91dd8b
[openmp][wasm] Allow compiling OpenMP to WebAssembly (#71297)
This change allows building the static OpenMP runtime, `libomp.a`, as
WebAssembly. It builds on the work done in [D142593] but goes further in
several ways:
 - it makes the OpenMP CMake files more WebAssembly-aware
- it conditions much more code (or code that had been refactored since
[D142593]) for `KMP_ARCH_WASM` and `KMP_OS_WASI`
- it fixes a Clang crash due to unimplemented common symbols in
WebAssembly

The commit messages have more details. Please understand this PR as a
start, not the completed work, for WebAssembly support in OpenMP.
Getting the tests running somehow would be a good next step, e.g.; but
what is contained here works, at least with recent versions of
[wasi-sdk] and engines that support [wasi-threads]. I suspect the same
is true for Emscripten and browsers, but I have not tested that
workflow.

[D142593]: https://reviews.llvm.org/D142593
[wasi-sdk]: https://github.com/WebAssembly/wasi-sdk
[wasi-threads]: https://github.com/WebAssembly/wasi-threads

---------

Co-authored-by: Atanas Atanasov <atanas.atanasov@intel.com>
2023-12-14 13:48:01 -06:00
Brad Smith
8b5af3139c
[OpenMP] Change check for OS to check for defined for a macro (#75012)
Check for the existence of the macro instead of checking for Solaris.
illumos has this macro in sys/time.h.

/export/home/brad/llvm-brad/openmp/runtime/src/z_Linux_util.cpp:77:9: warning: 'TIMEVAL_TO_TIMESPEC' macro redefined [-Wmacro-redefined]
   77 | #define TIMEVAL_TO_TIMESPEC(tv, ts)                                            \
      |         ^
/usr/include/sys/time.h:424:9: note: previous definition is here
  424 | #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
      |         ^
2023-12-11 09:54:24 -05:00
Sandeep Kosuri
ecc080c07d
[OpenMP] return empty stmt for nothing (#74042)
- `nothing` directive was effecting the `if` block structure which it
should not. So return an empty statement instead of an error statement
while parsing to avoid this.
2023-12-03 13:33:38 +05:30
Brad Smith
027935d3cd
[OpenMP] Re-enable KMP_HAVE_QUAD on NetBSD 10.0 with GCC 10.5 (#73478) 2023-12-01 16:07:16 -05:00
Shilei Tian
5f864ba195 Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"
This reverts commit 97e16da450e94c92456fa5a74768ec1b22fe6b63 because it
causes build error on i386 system.
2023-11-30 16:15:54 -05:00
Joseph Huber
8b9a6af450
[OpenMP] Add an 'stddef.h' include to 'omp.h' (#73876)
Summary:
We use `size_t` internally in the omp.h header, which is normally
provided by `stdlib.h` which is already included. Howevever, some cases
when using `-ffreestanding` can result in this not being defined via
`stdlib.h`. This patch simply adds an explicit inclusion of this header,
which is provided by the `clang` resource directory, to resolve this in
all cases.
2023-11-29 18:53:30 -06:00
Shilei Tian
97e16da450 [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 19:04:30 -05:00
Shilei Tian
351c3ee5f6 Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"
This reverts commit d46f63553ab9ee041884b5306527afefaf00e144.
2023-11-28 18:58:47 -05:00
Shilei Tian
d46f63553a [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 18:54:48 -05:00
Shilei Tian
e7f5d609dd Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA (#71412)"
This reverts commit eaab947a8aa39002e8bdaa82be08cbc31e116a11 because it
causes link error.
2023-11-28 18:34:24 -05:00
Shilei Tian
eaab947a8a
[OpenMP] Use simple VLA implementation to replace uses of actual VLA (#71412)
Use of VLA can cause compile warning that was introduced in D156565.
This patch
implements a simple stack/heap-based VLA that can miminc the behavior of
an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by
default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 18:30:06 -05:00
Alex
d6f00654fb
[OpenMP][Runtime][test] Fix ompt task testcase fail randomly (#72337)
Fixed #72231
2023-11-28 14:22:57 +01:00
Brad Smith
20406af31b
[runtime] Have the runtime use the compiler builtin for alloca on NetBSD (#73480)
Most of the tests were failing with the following in their logs..

| /usr/bin/ld: /home/brad/llvm-build/runtimes/runtimes-bins/openmp/runtime/src/libomp.so:
warning: Warning: reference to the libc supplied alloca(3); this most likely will not
work. Please use the compiler provided version of alloca(3), by supplying the appropriate
compiler flags (e.g. -std=gnu99).

By making use of __builtin_alloca..

before:

Total Discovered Tests: 353
  Unsupported:  59 (16.71%)
  Passed     :  51 (14.45%)
  Failed     : 243 (68.84%)

after:

Total Discovered Tests: 353
  Unsupported:  59 (16.71%)
  Passed     : 290 (82.15%)
  Failed     :   4 (1.13%)
2023-11-27 13:22:54 -05:00