Commit Graph

113 Commits

Author SHA1 Message Date
Alexey Bataev c029fb7612 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341093 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 18:56:11 +00:00
Alexey Bataev 38d46ffb86 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341073 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 14:45:24 +00:00
Alexey Bataev d9c61e0b62 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340953 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 18:32:21 +00:00
Alexey Bataev a24c755e26 [OPENMP] Fix processing of declare target construct.
The attribute marked as inheritable since OpenMP 5.0 supports it +
additional fixes to support new functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339704 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 18:31:20 +00:00
Stephen Kelly d7b659b592 Port getLocStart -> getBeginLoc
Reviewers: teemperor!

Subscribers: jholewinski, whisperity, jfb, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:08:08 +00:00
Alexey Bataev a465f7c8c4 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337957 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-25 20:03:01 +00:00
Alexey Bataev 953bf58982 [OPENMP, NVPTX] Globalize only captured variables.
Sometimes we can try to globalize non-variable declarations, which may
lead to compiler crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337191 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-16 16:49:20 +00:00
Gheorghe-Teodor Bercea 2fc21c4f2b [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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337015 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-13 16:18:24 +00:00
Alexey Bataev 4a1455fb1c [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336567 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 17:43:58 +00:00
Alexey Bataev ad2ab0a634 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335632 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:24:03 +00:00
Alexey Bataev ccd9acb5ef [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335377 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 19:10:38 +00:00
Alexey Bataev e7e696b260 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335285 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 20:26:33 +00:00
Alexey Bataev 6ec623490a [OPENMP, NVPTX] Emit simple reduction if requested.
If simple reduction is requested, use the simple reduction instead of
the runtime functions calls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334962 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-18 17:11:45 +00:00
Alexey Bataev 113c3c7156 [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.
```

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333301 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 20:16:03 +00:00
Alexey Bataev b168e23012 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332467 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 13:36:30 +00:00
Alexey Bataev a48ed89527 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332380 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 18:01:01 +00:00
Alexey Bataev dbfe08683c [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332129 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-11 19:45:14 +00:00
Alexey Bataev a32046b1f4 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332016 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-10 18:32:08 +00:00
Adrian Prantl 647be32c60 Remove \brief commands from doxygen comments.
This is similar to the LLVM change https://reviews.llvm.org/D46290.

We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 01:00:01 +00:00
Alexey Bataev 70c1258116 [OPENMP, NVPTX] Codegen for critical construct.
Added correct codegen for the critical construct on NVPTX devices.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331652 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-07 17:23:05 +00:00
Alexey Bataev c452e7c5b1 [OPENMP, NVPTX] Added support for L2 parallelism.
Added initial codegen for level 2, 3 etc. parallelism. Currently, all
the second, the third etc. parallel regions will run sequentially.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331642 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-07 14:50:05 +00:00
Alexey Bataev 3dc7ebda15 [OPENMP] Add support for reductions on simd directives in target
regions.

Added codegen for `simd reduction()` constructs in target directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-02 20:03:27 +00:00
Alexey Bataev 08aa612e26 [OPENMP] Emit names of the globals depending on target.
Some symbols are not allowed to be used as names on some targets. Patch
ries to unify the emission of the names of LLVM globals so they could be
used on different targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331358 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-02 14:20:50 +00:00
Alexey Bataev 6727779002 [OPENMP] Do not cast captured by value variables with pointer types in
NVPTX target.

When generating the wrapper function for the offloading region, we need
to call the outlined function and cast the arguments correctly to follow
the ABI. Usually, variables captured by value are casted to `uintptr_t`
type. But this should not performed for the variables with pointer type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330620 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-23 17:33:41 +00:00
Alexey Bataev c541223ebd [OPENMP] General code improvements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330154 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-16 20:16:21 +00:00
Alexey Bataev 6d12dfba81 [OPENMP] Additional attributes for the pointer parameters.
Added attributes for better optimization of the OpenMP code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329751 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 20:10:53 +00:00
Alexey Bataev b7d1036581 [OPENMP, NVPTX] Fix codegen for the teams reduction.
Added NUW flags for all the add|mul|sub operations + replaced sdiv by udiv
as we operate on unsigned values only (addresses, converted to integers)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329411 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 16:03:36 +00:00
Alexey Bataev 37a2cfd5dd [OPENMP] Added emission of offloading data sections for declare target
variables.

Added emission of the offloading data sections for the variables within
declare target regions + fixes emission of the declare target variables
marked as declare target not within the declare target region.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328888 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-30 18:31:07 +00:00
Gheorghe-Teodor Bercea 14d3260e44 [OpenMP][Clang] Add call to global data sharing stack initialization on the workers side
Summary: The workers also need to initialize the global stack. The call to the initialization function needs to happen after the kernel_init() function is called by the master. This ensures that the per-team data structures of the runtime have been initialized.

Reviewers: ABataev, grokos, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328219 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-22 17:33:27 +00:00
Alexey Bataev 2c97b35e76 [OPENMP, NVPTX] Codegen for target distribute parallel combined
constructs in generic mode.

Fixed codegen for distribute parallel combined constructs. We have to
pass and read the shared lower and upper bound from the distribute
region in the inner parallel region. Patch is for generic mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327990 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 15:41:05 +00:00
Alexey Bataev 53912bffa0 [OPENMP, NVPTX] Globalization of the private redeclarations.
If the generic codegen is enabled and private copy of the original
variable escapes the declaration context, this private copy should be
globalized just like it was the original variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327985 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 14:45:59 +00:00
Alexey Bataev 0d77b40bff [OPENMP, NVPTX] Reworked castToType() function, NFC.
Reworked function castToType to use more frontend functionality rather
than the backend.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327873 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 17:53:56 +00:00
Alexey Bataev d4d6e97339 [OPENMP] Fix build with MSVC, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327868 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 17:18:13 +00:00
Alexey Bataev 15183f0cd2 [OPENMP, NVPTX] Emit correct thread id.
We emitted fake thread id for the outined function in NVPTX codegen.
Patch adds emission of the real thread id.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327867 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 17:04:07 +00:00
Mikael Holmen 290cc27fe2 Fix compilation warning introduced in r327654
The compiler complained about

../tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:184:15: error: unused variable 'CSI' [-Werror,-Wunused-variable]
    if (auto *CSI = CGF.CapturedStmtInfo) {
              ^
1 error generated.

I don't know this code but it seems like an easy fix so I push it anyway
to get rid of the warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327694 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-16 07:27:57 +00:00
Alexey Bataev 75f6d61488 [OPENMP, NVPTX] Improve globalization of the variables captured by value.
If the variable is captured by value and the corresponding parameter in
the outlined function escapes its declaration context, this parameter
must be globalized. To globalize it we need to get the address of the
original parameter, load the value, store it to the global address and
use this global address instead of the original.

Patch improves globalization for parallel|teams regions + functions in
declare target regions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327654 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 18:10:54 +00:00
Gheorghe-Teodor Bercea f4806a953b [OpenMP] Add OpenMP data sharing infrastructure using global memory
Summary:
This patch handles the Clang code generation phase for the OpenMP data sharing infrastructure.

TODO: add a more detailed description.

Reviewers: ABataev, carlo.bertolli, caomhin, hfinkel, Hahnfeld

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327513 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 14:17:45 +00:00
Gheorghe-Teodor Bercea 843ace7a25 [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory
Summary: Remove this scheme for now since it will be covered by another more generic scheme using global memory. This code will be worked into an optimization for the generic data sharing scheme. Removing this completely and then adding it via future patches will make all future data sharing patches cleaner.

Reviewers: ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326948 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-07 21:59:50 +00:00
Rafael Espindola 5c8bad2616 Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.
This just reduces the noise in a followup patch.

Part of D43900.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-28 23:46:35 +00:00
Carlo Bertolli c6c9776cf9 [OpenMP] Extend NVPTX SPMD implementation of combined constructs
Differential Revision: https://reviews.llvm.org/D43852

This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326368 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-28 20:48:35 +00:00
Sander de Smalen 6804b86ee9 Recommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.
Fixed build issue when building with g++-4.8 (specialization after instantiation).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324173 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-03 13:55:59 +00:00
Sander de Smalen 294a4f68ff Reverting patch rL323952 due to build errors that I
haven't encountered in local builds.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323956 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 12:27:13 +00:00
Sander de Smalen 835a31e2ef [DebugInfo] Enable debug information for C99 VLA types
Summary:
This patch enables debugging of C99 VLA types by generating more precise
LLVM Debug metadata, using the extended DISubrange 'count' field that
takes a DIVariable.
    
This should implement:
  Bug 30553: Debug info generated for arrays is not what GDB expects (not as good as GCC's)
https://bugs.llvm.org/show_bug.cgi?id=30553

Reviewers: echristo, aprantl, dexonsmith, clayborg, pcc, kristof.beyls, dblaikie

Reviewed By: aprantl

Subscribers: jholewinski, schweitz, davide, fhahn, JDevlieghere, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323952 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-01 11:25:10 +00:00
Alexey Bataev 960241680b [OPENMP] Remove more empty SourceLocations() from the code.
Removed more empty SourceLocations() from the OpenMP code and replaced
with the correct locations for better debug info emission.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323232 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 18:12:38 +00:00
Alexey Bataev a65cfe004d [OPENMP] Replace calls of getAssociatedStmt().
getAssociatedStmt() returns the outermost captured statement for the
OpenMP directive. It may return incorrect region in case of combined
constructs. Reworked the code to reduce the number of calls of
getAssociatedStmt() and used getInnermostCapturedStmt() and
getCapturedStmt() functions instead.
In case of firstprivate variables it may lead to an extra allocas
generation for private copies even if the variable is passed by value
into outlined function and could be used directly as private copy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-12 19:39:11 +00:00
Alexey Bataev 5de7cbc4db [OPENMP] Fix debug info for outlined functions in NVPTX + add more tests.
Fixed name of emitted outlined functions in NVPTX target + extra tests
for the debug info.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322022 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-08 20:09:47 +00:00
Alexey Bataev 27fbdd8738 [OPENMP] Fix casting in NVPTX support library.
If the reduction required shuffle in the NVPTX codegen, we may need to
cast the reduced value to the integer type. This casting was implemented
incorrectly and may cause compiler crash. Patch fixes this problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321818 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 20:18:55 +00:00
Alexey Bataev 34662fb33d [OPENMP] Add debug info for generated functions.
Most of the generated functions for the OpenMP were generated with
disabled debug info. Patch fixes this for better user experience.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321816 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 19:45:16 +00:00
Jonas Hahnfeld 46a2237cfa [OpenMP] Further adjustments of nvptx runtime functions
Pass in default value of 1, similar to previous commit r318836.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321486 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-27 10:39:56 +00:00
Gheorghe-Teodor Bercea be56d0e7af [OpenMP] Add function attribute for triggering data sharing.
Summary:
The backend should only emit data sharing code for the cases where it is needed.
A new function attribute is used by Clang to enable data sharing only for the cases where OpenMP semantics require it and there are variables that need to be shared.

Reviewers: hfinkel, Hahnfeld, ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: cfe-commits, jholewinski

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320527 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-12 21:38:43 +00:00