blob: 0b3d545990484051cb051ea706f49913dea4ec60 [file] [log] [blame]
Jonas Hahnfeld43322802017-12-06 21:59:071//===---------- private.h - Target independent OpenMP target RTL ----------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:403// 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 Hahnfeld43322802017-12-06 21:59:076//
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 Doerfert8327f4a2023-11-28 21:44:5716#include "Shared/Debug.h"
Johannes Doerfert7233e422023-11-28 23:10:0617#include "Shared/SourceInfo.h"
Johannes Doerfert8327f4a2023-11-28 21:44:5718
Johannes Doerfertd1057012023-11-28 23:41:3119#include "OpenMP/InternalTypes.h"
20
Johannes Doerfert44f30222021-02-10 16:50:0921#include "device.h"
Johannes Doerfert8327f4a2023-11-28 21:44:5722#include "omptarget.h"
Jonas Hahnfeld43322802017-12-06 21:59:0723
24#include <cstdint>
25
Johannes Doerfert16a385b2023-01-19 21:40:5826extern int target(ident_t *Loc, DeviceTy &Device, void *HostPtr,
Johannes Doerfert3820d0e2023-01-21 21:43:1027 KernelArgsTy &KernelArgs, AsyncInfoTy &AsyncInfo);
Jonas Hahnfeld43322802017-12-06 21:59:0728
koparasy73cb01d2023-07-19 17:32:0729extern int target_activate_rr(DeviceTy &Device, uint64_t MemorySize,
Johannes Doerfertf48c4d82023-11-17 00:09:0530 void *ReqAddr, bool isRecord, bool SaveOutput,
31 uint64_t &ReqPtrArgOffset);
koparasy73cb01d2023-07-19 17:32:0732
Giorgis Georgakoudis94c772d2023-01-17 23:35:4433extern 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. Dennyd0eb25a2021-03-04 16:19:1339extern void handleTargetOutcome(bool Success, ident_t *Loc);
George Rokos2878c392018-03-16 20:40:0940
Joseph Huberc3e60542020-09-15 19:04:3741////////////////////////////////////////////////////////////////////////////////
Joseph Huberfe5d51a2020-12-18 20:14:4442/// Print out the names and properties of the arguments to each kernel
43static inline void
44printKernelArguments(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 Huberd27d0a62022-07-01 15:48:1548 SourceInfo Info(Loc);
Joseph Huber119a9ea2021-01-21 14:59:2949 INFO(OMP_INFOTYPE_ALL, DeviceId, "%s at %s:%d:%d with %d arguments:\n",
Joseph Huberd27d0a62022-07-01 15:48:1550 RegionType, Info.getFilename(), Info.getLine(), Info.getColumn(),
Joseph Huber119a9ea2021-01-21 14:59:2951 ArgNum);
Joseph Huberfe5d51a2020-12-18 20:14:4452
Joseph Huberd27d0a62022-07-01 15:48:1553 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 Huberfe5d51a2020-12-18 20:14:4470 else
Joseph Huberd27d0a62022-07-01 15:48:1571 Type = "use_address";
Joseph Huberfe5d51a2020-12-18 20:14:4472
Joseph Huberd27d0a62022-07-01 15:48:1573 INFO(OMP_INFOTYPE_ALL, DeviceId, "%s(%s)[%" PRId64 "] %s\n", Type,
74 getNameFromMapping(VarName).c_str(), ArgSizes[I], Implicit);
Joseph Huberc3e60542020-09-15 19:04:3775 }
76}
77
Jonas Hahnfeld43322802017-12-06 21:59:0778#endif