[llvm] [Offload]: Skip copying of unused kernel-mapped data (PR #124723)
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 17:34:36 PST 2025
================
@@ -1197,6 +1197,82 @@ class PrivateArgumentManagerTy {
}
};
+/// Try to find redundant mappings associated with a kernel launch,
+/// and provide a masked version of the kernel argument types that
+/// avoid redundant to data transfers between the host and device.
+static std::unique_ptr<int64_t[]>
+maskRedundantTransfers(DeviceTy &Device, int32_t ArgNum, int64_t *ArgTypes,
+ int64_t *ArgSizes, map_var_info_t *ArgNames,
+ void **ArgPtrs, void **ArgMappers) {
+ std::unique_ptr<int64_t[]> ArgTypesOverride =
+ std::make_unique<int64_t[]>(ArgNum);
+
+ MappingInfoTy &MappingInfo = Device.getMappingInfo();
+ MappingInfoTy::HDTTMapAccessorTy HDTTMap =
+ MappingInfo.HostDataToTargetMap.getExclusiveAccessor();
+
+ int64_t UnusedArgs = 0;
+
+ for (int32_t I = 0; I < ArgNum; ++I) {
+ tgt_map_type ArgType = (tgt_map_type)ArgTypes[I];
+
+ // Check for unused implicit mappings
+ bool IsArgUnused = ArgType == OMP_TGT_MAPTYPE_NONE;
+
+ // Check for unused `map(buf[0:size])` mappings
+ IsArgUnused |= ArgType == OMP_TGT_MAPTYPE_FROM ||
+ ArgType == OMP_TGT_MAPTYPE_TO ||
+ ArgType == (OMP_TGT_MAPTYPE_FROM | OMP_TGT_MAPTYPE_TO);
----------------
jdoerfert wrote:
Are there no other flags allowed? It might be so, just checking.
https://github.com/llvm/llvm-project/pull/124723
More information about the llvm-commits
mailing list