Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 | [diff] [blame] | 1 | //===---------- private.h - Target independent OpenMP target RTL ----------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 | [diff] [blame] | 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 |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 | [diff] [blame] | 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 | |
Johannes Doerfert | 8327f4a | 2023-11-28 21:44:57 | [diff] [blame] | 16 | #include "Shared/Debug.h" |
Johannes Doerfert | 7233e42 | 2023-11-28 23:10:06 | [diff] [blame] | 17 | #include "Shared/SourceInfo.h" |
Johannes Doerfert | 8327f4a | 2023-11-28 21:44:57 | [diff] [blame] | 18 | |
Johannes Doerfert | d105701 | 2023-11-28 23:41:31 | [diff] [blame] | 19 | #include "OpenMP/InternalTypes.h" |
| 20 | |
Johannes Doerfert | 44f3022 | 2021-02-10 16:50:09 | [diff] [blame] | 21 | #include "device.h" |
Johannes Doerfert | 8327f4a | 2023-11-28 21:44:57 | [diff] [blame] | 22 | #include "omptarget.h" |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 | [diff] [blame] | 23 | |
| 24 | #include <cstdint> |
| 25 | |
Johannes Doerfert | 16a385b | 2023-01-19 21:40:58 | [diff] [blame] | 26 | extern int target(ident_t *Loc, DeviceTy &Device, void *HostPtr, |
Johannes Doerfert | 3820d0e | 2023-01-21 21:43:10 | [diff] [blame] | 27 | KernelArgsTy &KernelArgs, AsyncInfoTy &AsyncInfo); |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 | [diff] [blame] | 28 | |
koparasy | 73cb01d | 2023-07-19 17:32:07 | [diff] [blame] | 29 | extern int target_activate_rr(DeviceTy &Device, uint64_t MemorySize, |
Johannes Doerfert | f48c4d8 | 2023-11-17 00:09:05 | [diff] [blame] | 30 | void *ReqAddr, bool isRecord, bool SaveOutput, |
| 31 | uint64_t &ReqPtrArgOffset); |
koparasy | 73cb01d | 2023-07-19 17:32:07 | [diff] [blame] | 32 | |
Giorgis Georgakoudis | 94c772d | 2023-01-17 23:35:44 | [diff] [blame] | 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 | |
Joel E. Denny | d0eb25a | 2021-03-04 16:19:13 | [diff] [blame] | 39 | extern void handleTargetOutcome(bool Success, ident_t *Loc); |
George Rokos | 2878c39 | 2018-03-16 20:40:09 | [diff] [blame] | 40 | |
Joseph Huber | c3e6054 | 2020-09-15 19:04:37 | [diff] [blame] | 41 | //////////////////////////////////////////////////////////////////////////////// |
Joseph Huber | fe5d51a | 2020-12-18 20:14:44 | [diff] [blame] | 42 | /// Print out the names and properties of the arguments to each kernel |
| 43 | static inline void |
| 44 | printKernelArguments(const ident_t *Loc, const int64_t DeviceId, |
| 45 | const int32_t ArgNum, const int64_t *ArgSizes, |
| 46 | const int64_t *ArgTypes, const map_var_info_t *ArgNames, |
| 47 | const char *RegionType) { |
Joseph Huber | d27d0a6 | 2022-07-01 15:48:15 | [diff] [blame] | 48 | SourceInfo Info(Loc); |
Joseph Huber | 119a9ea | 2021-01-21 14:59:29 | [diff] [blame] | 49 | INFO(OMP_INFOTYPE_ALL, DeviceId, "%s at %s:%d:%d with %d arguments:\n", |
Joseph Huber | d27d0a6 | 2022-07-01 15:48:15 | [diff] [blame] | 50 | RegionType, Info.getFilename(), Info.getLine(), Info.getColumn(), |
Joseph Huber | 119a9ea | 2021-01-21 14:59:29 | [diff] [blame] | 51 | ArgNum); |
Joseph Huber | fe5d51a | 2020-12-18 20:14:44 | [diff] [blame] | 52 | |
Joseph Huber | d27d0a6 | 2022-07-01 15:48:15 | [diff] [blame] | 53 | for (int32_t I = 0; I < ArgNum; ++I) { |
| 54 | const map_var_info_t VarName = (ArgNames) ? ArgNames[I] : nullptr; |
| 55 | const char *Type = nullptr; |
| 56 | const char *Implicit = |
| 57 | (ArgTypes[I] & OMP_TGT_MAPTYPE_IMPLICIT) ? "(implicit)" : ""; |
| 58 | if (ArgTypes[I] & OMP_TGT_MAPTYPE_TO && ArgTypes[I] & OMP_TGT_MAPTYPE_FROM) |
| 59 | Type = "tofrom"; |
| 60 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_TO) |
| 61 | Type = "to"; |
| 62 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_FROM) |
| 63 | Type = "from"; |
| 64 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_PRIVATE) |
| 65 | Type = "private"; |
| 66 | else if (ArgTypes[I] & OMP_TGT_MAPTYPE_LITERAL) |
| 67 | Type = "firstprivate"; |
| 68 | else if (ArgSizes[I] != 0) |
| 69 | Type = "alloc"; |
Joseph Huber | fe5d51a | 2020-12-18 20:14:44 | [diff] [blame] | 70 | else |
Joseph Huber | d27d0a6 | 2022-07-01 15:48:15 | [diff] [blame] | 71 | Type = "use_address"; |
Joseph Huber | fe5d51a | 2020-12-18 20:14:44 | [diff] [blame] | 72 | |
Joseph Huber | d27d0a6 | 2022-07-01 15:48:15 | [diff] [blame] | 73 | INFO(OMP_INFOTYPE_ALL, DeviceId, "%s(%s)[%" PRId64 "] %s\n", Type, |
| 74 | getNameFromMapping(VarName).c_str(), ArgSizes[I], Implicit); |
Joseph Huber | c3e6054 | 2020-09-15 19:04:37 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 | [diff] [blame] | 78 | #endif |