Commit Graph

952 Commits

Author SHA1 Message Date
Alexey Bataev bd8ff9bd70 [OPENMP] Fix PR38710: static functions are not emitted as implicitly
'declare target'.

All the functions, referenced in implicit|explicit target regions must
be emitted during code emission for the device.

llvm-svn: 341093
2018-08-30 18:56:11 +00:00
Alexey Bataev 80a9a61ded [OPENMP][NVPTX] Add options -f[no-]openmp-cuda-force-full-runtime.
Added options -f[no-]openmp-cuda-force-full-runtime to [not] force use
of the full runtime for OpenMP offloading to CUDA devices.

llvm-svn: 341073
2018-08-30 14:45:24 +00:00
Alexey Bataev b4dd6d24d7 [OPENMP] Do not create offloading entry for declare target variables
declarations.

We should not create offloading entries for declare target var
declarations as it causes compiler crash.

llvm-svn: 340968
2018-08-29 20:41:37 +00:00
Alexey Bataev 8d8e1235ab [OPENMP][NVPTX] Add support for lightweight runtime.
If the target construct can be executed in SPMD mode + it is a loop
based directive with static scheduling, we can use lightweight runtime
support.

llvm-svn: 340953
2018-08-29 18:32:21 +00:00
Mike Rice e1ca7b614f [OPENMP] Create non-const ident_t objects.
Currently ident_t objects are created const when debug info is not
enabled, but the libittnotify libray in the OpenMP runtime writes to
the reserved_2 field (See __kmp_itt_region_forking in
openmp/runtime/src/kmp_itt.inl).  Now create ident_t objects non-const.

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

llvm-svn: 340934
2018-08-29 15:45:11 +00:00
Alexey Bataev 7f792cab12 [OPENMP] Fix crash on the emission of the weak function declaration.
If the function is actually a weak reference, it should not be marked as
deferred definition as this is only a declaration. Patch adds checks for
the definitions if they must be emitted. Otherwise, only declaration is
emitted.

llvm-svn: 340191
2018-08-20 18:03:40 +00:00
Alexey Bataev d01b74974b [OPENMP] FIx processing of declare target variables.
The compiler may produce unexpected error messages/crashes when declare
target variables were used. Patch fixes problems with the declarations
marked as declare target to or link.

llvm-svn: 339805
2018-08-15 19:45:12 +00:00
Alexey Bataev 97b722121e [OPENMP] Fix processing of declare target construct.
The attribute marked as inheritable since OpenMP 5.0 supports it +
additional fixes to support new functionality.

llvm-svn: 339704
2018-08-14 18:31:20 +00:00
Alexey Bataev f138fda5ed [OPENMP] Fix emission of the loop doacross constructs.
The number of loops associated with the OpenMP loop constructs should
not be considered as the number loops to collapse.

llvm-svn: 339603
2018-08-13 19:04:24 +00:00
Alexey Bataev 23647171ea Revert "[OPENMP] Fix emission of the loop doacross constructs."
This reverts commit r339568 because of the problems with the buildbots.

llvm-svn: 339574
2018-08-13 14:42:18 +00:00
Alexey Bataev 0ce6360e0e [OPENMP] Fix emission of the loop doacross constructs.
The number of loops associated with the OpenMP loop constructs should
not be considered as the number loops to collapse.

llvm-svn: 339568
2018-08-13 14:05:43 +00:00
Alexey Bataev bf8fe71b91 [OPENMP] Mark variables captured in declare target region as implicitly
declare target.

According to OpenMP 5.0, variables captured in lambdas in declare target
regions must be considered as implicitly declare target.

llvm-svn: 339152
2018-08-07 16:14:36 +00:00
Sergey Dmitriev bde9cf942b [OpenMP] Encode offload target triples into comdat key for offload initialization code
Encoding offload target triples onto comdat group key for offload initialization
code guarantees that it will be executed once per each unique combination of
offload targets.

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

llvm-svn: 338916
2018-08-03 20:19:28 +00:00
Alexey Bataev 62a4cb06a9 [OPENMP] Change linkage of offloading symbols to support dropping
offload targets.

Changed the linkage of omp_offloading.img_start.<triple> and omp_offloading.img_end.<triple> symbols from external to external weak to allow dropping of some targets during linking.

llvm-svn: 338413
2018-07-31 18:27:42 +00:00
Alexey Bataev 3823514b56 [OPENMP] Prevent problems with linking of the static variables.
No need to change the linkage, we can avoid the problem using special variable. That points to the original variable and, thus, prevent some of the optimizations that might break the compilation.

llvm-svn: 338399
2018-07-31 16:40:15 +00:00
Alexey Bataev 2f5b2671da [OPENMP] Static variables on device must be externally visible.
Do not mark static variable as internal on the device as they must be
visible from the host to be mapped correctly.

llvm-svn: 338139
2018-07-27 17:37:32 +00:00
Alexey Bataev 77403dee05 [OPENMP] Force OpenMP 4.5 when compiling for offloading.
If the user requested compilation for OpenMP with the offloading
support, force the version of the OpenMP standard to 4.5 by default.

llvm-svn: 338032
2018-07-26 15:17:38 +00:00
Alexey Bataev 8521ff6ec4 [OPENMP] ThreadId in serialized parallel regions is 0.
The first argument for the parallel outlined functions, called as
serialized parallel regions, should be a pointer to the global thread id
that always is 0.

llvm-svn: 337957
2018-07-25 20:03:01 +00:00
Alexey Bataev a36aec9f83 [OPENMP] Exclude service expressions/statements from the list of
the children.

Special internal helper expressions/statements for the OpenMP directives
should not be exposed as children, only the main substatement must be
represented as the child.

llvm-svn: 337941
2018-07-25 17:27:45 +00:00
Jonas Hahnfeld 3f659e8731 Revert "[OPENMP] Fix PR38026: Link -latomic when -fopenmp is used."
This reverts commit r336467: libatomic is not available on all Linux
systems and this commit completely breaks OpenMP on them, even if there
are no atomic operations or all of them can be lowered to hardware
instructions.

See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180716/234816.html
for post-commit discussion.

llvm-svn: 337722
2018-07-23 18:27:09 +00:00
Alexey Bataev b363813543 The patch adds support for the new map interface between clang and libomptarget. The changes in the interface are the following:
device IDs are now 64-bit integers (as opposed to 32-bit)
map flags are 64-bit long (used to be 32-bit)
mappings for partially mapped structs are now calculated at compile time and members of partially mapped structs are flagged using the MEMBER_OF field
Support for is_device_ptr on struct members was dropped - this functionality is not supported by the OpenMP standard and its implementation is technically infeasible (however, use_device_ptr on struct members works as a non-standard extension of the compiler)

llvm-svn: 337468
2018-07-19 16:34:13 +00:00
Alexey Bataev c52f01d1d7 [OPENMP] Fix checks for declare target link entries.
If the declare target link entries are created but not used, the
compiler will produce an error message. Patch improves handling of such
situations + improves checks for possibly lost declare target variables.

llvm-svn: 337207
2018-07-16 20:05:25 +00:00
Alexey Bataev 7f01d20993 [OPENMP] Fix syntactic errors in error messages.
Fixed spelling of the offloading error messages.

llvm-svn: 337196
2018-07-16 18:12:18 +00:00
Alexey Bataev 3dd1f9d61d [OPENMP, NVPTX] Globalize only captured variables.
Sometimes we can try to globalize non-variable declarations, which may
lead to compiler crash.

llvm-svn: 337191
2018-07-16 16:49:20 +00:00
Gheorghe-Teodor Bercea ad4e579407 [OpenMP] Initialize data sharing stack for SPMD case
Summary: In the SPMD case, we need to initialize the data sharing and globalization infrastructure. This covers the case when an SPMD region calls a function in a different compilation unit.

Reviewers: ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: Hahnfeld, jholewinski, guansong, cfe-commits

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

llvm-svn: 337015
2018-07-13 16:18:24 +00:00
Joel E. Denny 72c2783012 [FileCheck] Add -allow-deprecated-dag-overlap to failing clang tests
See https://reviews.llvm.org/D47106 for details.

Reviewed By: probinson

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

llvm-svn: 336844
2018-07-11 20:26:20 +00:00
Alexey Bataev c1943e75c7 [OPENMP] Do not mark local variables as declare target.
When the parsing of the functions happens inside of the declare target
region, we may erroneously mark local variables as declare target
thought they are not. This attribute can be applied only to global
variables.

llvm-svn: 336592
2018-07-09 19:58:08 +00:00
Alexey Bataev b99dcb5f31 [OPENMP, NVPTX] Do not globalize local variables in parallel regions.
In generic data-sharing mode we are allowed to not globalize local
variables that escape their declaration context iff they are declared
inside of the parallel region. We can do this because L2 parallel
regions are executed sequentially and, thus, we do not need to put
shared local variables in the global memory.

llvm-svn: 336567
2018-07-09 17:43:58 +00:00
Alexey Bataev f5d8b841ce [OPENMP] Fix PR38026: Link -latomic when -fopenmp is used.
On Linux atomic constructs in OpenMP require libatomic library. Patch
links libatomic when -fopenmp is used.

llvm-svn: 336467
2018-07-06 21:13:41 +00:00
Alexey Bataev dbc72c9009 [OPENMP] Make clauses closing loc point to right bracket.
For some of the clauses the closing location erroneously points to the
beginning of the next clause rather than on the location of the closing
bracket of the clause.

llvm-svn: 336460
2018-07-06 19:35:42 +00:00
Joel E. Denny 3cabf73270 [OPENMP] Fix incomplete type check for array reductions
A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

Reviewed By: ABataev

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

llvm-svn: 335911
2018-06-28 19:54:49 +00:00
Joel E. Denny e0e7a8ae58 Revert r335907: [OPENMP] Fix incomplete type check for array reductions
Sorry, forgot to add commit log attributes again.

llvm-svn: 335910
2018-06-28 19:54:27 +00:00
Joel E. Denny 82e9ea5b49 [OPENMP] Fix incomplete type check for array reductions
A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

llvm-svn: 335907
2018-06-28 19:46:10 +00:00
Alexey Bataev 91433f6877 [OPENMP, NVPTX] Reduce the number of the globalized variables.
Patch tries to make better analysis of the variables that should be
globalized. From now, instead of all parallel directives it will check
only distribute parallel .. directives and check only for
firstprivte/lastprivate variables if they must be globalized.

llvm-svn: 335632
2018-06-26 17:24:03 +00:00
Alexey Bataev 96edb2e37e [OPENMP] Do not consider address constant vars as possibly
threadprivate.

Do not delay emission of the address constant variables in OpenMP mode
as they cannot be defined as threadprivate.

llvm-svn: 335483
2018-06-25 15:32:05 +00:00
Alexey Bataev 12c62908b5 [OPENMP, NVPTX] Fix reduction of the big data types/structures.
If the shuffle is required for the reduced structures/big data type,
current code may cause compiler crash because of the loading of the
aggregate values. Patch fixes this problem.

llvm-svn: 335377
2018-06-22 19:10:38 +00:00
Alexey Bataev 4065b9ae48 [OPENMP, NVPTX] Fix globalization of the variables passed to orphaned
parallel region.

If the current construct requires sharing of the local variable in the
inner parallel region, this variable must be globalized to avoid
runtime crash.

llvm-svn: 335285
2018-06-21 20:26:33 +00:00
Alexey Bataev 7b55d2d554 [OPENMP, NVPTX] Emit simple reduction if requested.
If simple reduction is requested, use the simple reduction instead of
the runtime functions calls.

llvm-svn: 334962
2018-06-18 17:11:45 +00:00
Alexey Bataev 0baba9e728 [OPENMP, NVPTX] Fixed codegen for orphaned parallel region.
If orphaned parallel region is found, the next code must be emitted:
```
if(__kmpc_is_spmd_exec_mode() || __kmpc_parallel_level(loc, gtid))
  Serialized execution.
else if (IsMasterThread())
  Prepare and signal worker.
else
  Outined function call.
```

llvm-svn: 333301
2018-05-25 20:16:03 +00:00
Alexey Bataev 66f9577f09 [OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.
if `-fopenmp-simd` is specified alone, `_OPENMP` macro should not be
  defined. If `-fopenmp-simd` is specified along with the `-fopenmp`,
  `_OPENMP` macro should be defined with the value `201511`.

llvm-svn: 332852
2018-05-21 16:40:32 +00:00
Alexey Bataev 4ac68a210c [OPENMP] DO not crash on combined constructs in declare target
functions.

If the combined construct is specified in the declare target function
and the device code is emitted, the compiler crashes because of the
incorrectly chosen captured stmt. We should choose the innermost
captured statement, not the outermost.

llvm-svn: 332477
2018-05-16 15:08:32 +00:00
Alexey Bataev 673110d5d5 [OPENMP, NVPTX] Add check for SPMD mode in orphaned parallel directives.
If the orphaned directive is executed in SPMD mode, we need to emit the
check for the SPMD mode and run the orphaned parallel directive in
sequential mode.

llvm-svn: 332467
2018-05-16 13:36:30 +00:00
Alexey Bataev 2a3320a928 [OPENMP, NVPTX] Do not globalize variables with reference/pointer types.
In generic data-sharing mode we do not need to globalize
variables/parameters of reference/pointer types. They already are placed
in the global memory.

llvm-svn: 332380
2018-05-15 18:01:01 +00:00
Alexey Bataev df093e7b45 [OPENMP, NVPTX] Do not use SPMD mode for target simd and target teams
distribute simd directives.

Directives `target simd` and `target teams distribute simd` must be
executed in non-SPMD mode.

llvm-svn: 332129
2018-05-11 19:45:14 +00:00
Alexey Bataev bf5c84861c [OPENMP, NVPTX] Initial support for L2 parallelism in SPMD mode.
Added initial support for L2 parallelism in SPMD mode. Note, though,
that the orphaned parallel directives are not currently supported in
SPMD mode.

llvm-svn: 332016
2018-05-10 18:32:08 +00:00
Alexey Bataev c15ea70b1f [OPENMP] Generate unique names for offloading regions id.
It is required to emit unique names for offloading regions ids. Required
to support compilation and linking of several compilation units.

llvm-svn: 331899
2018-05-09 18:02:37 +00:00
Alexey Bataev e253f2f886 [OPENMP] Mark global tors/dtors as used.
If the global variables are marked as declare target and they need
ctors/dtors, these ctors/dtors are emitted and then invoked by the
offloading runtime library. They are not explicitly used in the emitted
code and thus can be optimized out. Patch marks these functions as used,
so the optimizer cannot remove these function during the optimization
phase.

llvm-svn: 331879
2018-05-09 14:15:18 +00:00
Alexey Bataev 9a70017537 [OPENMP, NVPTX] Fix linkage of the global entries.
The linkage of the global entries must be weak to enable support of
redefinition of the same target regions in multiple compilation units.

llvm-svn: 331768
2018-05-08 14:16:57 +00:00
Alexey Bataev c661186cca [OPENMP, NVPTX] Small test fix, NFC.
llvm-svn: 331654
2018-05-07 17:38:13 +00:00
Alexey Bataev 504fc2d0cd [OPENMP, NVPTX] Codegen for critical construct.
Added correct codegen for the critical construct on NVPTX devices.

llvm-svn: 331652
2018-05-07 17:23:05 +00:00