1 | //===---------- private.h - Target independent OpenMP target RTL ----------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // Private function declarations and helper macros for debugging output. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef _OMPTARGET_PRIVATE_H |
14 | #define _OMPTARGET_PRIVATE_H |
15 | |
16 | #include "Shared/Debug.h" |
17 | #include "Shared/SourceInfo.h" |
18 | |
19 | #include "OpenMP/InternalTypes.h" |
20 | |
21 | #include "device.h" |
22 | #include "omptarget.h" |
23 | |
24 | #include <cstdint> |
25 | |
26 | extern int target(ident_t *Loc, DeviceTy &Device, void *HostPtr, |
27 | KernelArgsTy &KernelArgs, AsyncInfoTy &AsyncInfo); |
28 | |
29 | extern int target_activate_rr(DeviceTy &Device, uint64_t MemorySize, |
30 | void *ReqAddr, bool isRecord, bool SaveOutput, |
31 | uint64_t &ReqPtrArgOffset); |
32 | |
33 | extern int target_replay(ident_t *Loc, DeviceTy &Device, void *HostPtr, |
34 | void *DeviceMemory, int64_t DeviceMemorySize, |
35 | void **TgtArgs, ptrdiff_t *TgtOffsets, int32_t NumArgs, |
36 | int32_t NumTeams, int32_t ThreadLimit, |
37 | uint64_t LoopTripCount, AsyncInfoTy &AsyncInfo); |
38 | |
39 | extern void handleTargetOutcome(bool Success, ident_t *Loc); |
40 | extern bool checkDeviceAndCtors(int64_t &DeviceID, ident_t *Loc); |
41 | |
42 | //////////////////////////////////////////////////////////////////////////////// |
43 | /// Print out the names and properties of the arguments to each kernel |
44 | static inline void |
45 | printKernelArguments(const ident_t *Loc, const int64_t DeviceId, |
46 | const int32_t ArgNum, const int64_t *ArgSizes, |
47 | const int64_t *ArgTypes, const map_var_info_t *ArgNames, |
48 | const char *RegionType) { |
49 | SourceInfo Info(Loc); |
50 | INFO(OMP_INFOTYPE_ALL, DeviceId, "%s at %s:%d:%d with %d arguments:\n" , |
51 | RegionType, Info.getFilename(), Info.getLine(), Info.getColumn(), |
52 | ArgNum); |
53 | |
54 | for (int32_t I = 0; I < ArgNum; ++I) { |
55 | const map_var_info_t VarName = (ArgNames) ? ArgNames[I] : nullptr; |
56 | const char *Type = nullptr; |
57 | const char *Implicit = |
58 | (ArgTypes[I] & OMP_TGT_MAPTYPE_IMPLICIT) ? "(implicit)" : "" ; |
59 | if (ArgTypes[I] & OMP_TGT_MAPTYPE_TO && ArgTypes[I] & OMP_TGT_MAPTYPE_FROM) |
60 | Type = "tofrom" ; |
61 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_TO) |
62 | Type = "to" ; |
63 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_FROM) |
64 | Type = "from" ; |
65 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_PRIVATE) |
66 | Type = "private" ; |
67 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_LITERAL) |
68 | Type = "firstprivate" ; |
69 | else if (ArgSizes[I] != 0) |
70 | Type = "alloc" ; |
71 | else |
72 | Type = "use_address" ; |
73 | |
74 | INFO(OMP_INFOTYPE_ALL, DeviceId, "%s(%s)[%" PRId64 "] %s\n" , Type, |
75 | getNameFromMapping(VarName).c_str(), ArgSizes[I], Implicit); |
76 | } |
77 | } |
78 | |
79 | #endif |
80 | |