diff --git a/openmp/libomptarget/include/device.h b/openmp/libomptarget/include/device.h --- a/openmp/libomptarget/include/device.h +++ b/openmp/libomptarget/include/device.h @@ -22,7 +22,6 @@ #include #include #include -#include #include "ExclusiveAccess.h" #include "omptarget.h" @@ -484,14 +483,14 @@ std::list> Images; /// Devices associated with RTLs - std::vector> Devices; + llvm::SmallVector> Devices; std::mutex RTLsMtx; ///< For RTLs and Devices /// Translation table retreived from the binary HostEntriesBeginToTransTableTy HostEntriesBeginToTransTable; std::mutex TrlTblMtx; ///< For Translation Table /// Host offload entries in order of image registration - std::vector<__tgt_offload_entry *> HostEntriesBeginRegistrationOrder; + llvm::SmallVector<__tgt_offload_entry *> HostEntriesBeginRegistrationOrder; /// Map from ptrs on the host to an entry in the Translation Table HostPtrToTableMapTy HostPtrToTableMap; diff --git a/openmp/libomptarget/include/rtl.h b/openmp/libomptarget/include/rtl.h --- a/openmp/libomptarget/include/rtl.h +++ b/openmp/libomptarget/include/rtl.h @@ -14,6 +14,7 @@ #define _OMPTARGET_RTL_H #include "omptarget.h" +#include "llvm/ADT/SmallVector.h" #include #include #include @@ -137,7 +138,7 @@ // Array of pointers to the detected runtime libraries that have compatible // binaries. - std::vector UsedRTLs; + llvm::SmallVector UsedRTLs; int64_t RequiresFlags = OMP_REQ_UNDEFINED; @@ -172,10 +173,12 @@ __tgt_target_table HostTable; // Image assigned to a given device. - std::vector<__tgt_device_image *> TargetsImages; // One image per device ID. + llvm::SmallVector<__tgt_device_image *> + TargetsImages; // One image per device ID. // Table of entry points or NULL if it was not already computed. - std::vector<__tgt_target_table *> TargetsTable; // One table per device ID. + llvm::SmallVector<__tgt_target_table *> + TargetsTable; // One table per device ID. }; typedef std::map<__tgt_offload_entry *, TranslationTable> HostEntriesBeginToTransTableTy; diff --git a/openmp/libomptarget/src/LegacyAPI.cpp b/openmp/libomptarget/src/LegacyAPI.cpp --- a/openmp/libomptarget/src/LegacyAPI.cpp +++ b/openmp/libomptarget/src/LegacyAPI.cpp @@ -173,8 +173,8 @@ DP("__kmpc_push_target_tripcount(%" PRId64 ", %" PRIu64 ")\n", DeviceId, LoopTripcount); PM->TblMapMtx.lock(); - PM->Devices[DeviceId]->LoopTripCnt.emplace(__kmpc_global_thread_num(NULL), - LoopTripcount); + PM->Devices[DeviceId]->LoopTripCnt[__kmpc_global_thread_num(NULL)] = + LoopTripcount; PM->TblMapMtx.unlock(); } diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -384,11 +384,11 @@ // Construct new arrays for args_base, args, arg_sizes and arg_types // using the information in MapperComponents and call the corresponding // targetData* function using these new arrays. - std::vector MapperArgsBase(MapperComponents.Components.size()); - std::vector MapperArgs(MapperComponents.Components.size()); - std::vector MapperArgSizes(MapperComponents.Components.size()); - std::vector MapperArgTypes(MapperComponents.Components.size()); - std::vector MapperArgNames(MapperComponents.Components.size()); + llvm::SmallVector MapperArgsBase(MapperComponents.Components.size()); + llvm::SmallVector MapperArgs(MapperComponents.Components.size()); + llvm::SmallVector MapperArgSizes(MapperComponents.Components.size()); + llvm::SmallVector MapperArgTypes(MapperComponents.Components.size()); + llvm::SmallVector MapperArgNames(MapperComponents.Components.size()); for (unsigned I = 0, E = MapperComponents.Components.size(); I < E; ++I) { auto &C = MapperComponents.Components[I]; @@ -679,7 +679,7 @@ int64_t *ArgTypes, map_var_info_t *ArgNames, void **ArgMappers, AsyncInfoTy &AsyncInfo, bool FromMapper) { int Ret; - std::vector PostProcessingPtrs; + llvm::SmallVector PostProcessingPtrs; void *FromMapperBase = nullptr; // process each input. for (int32_t I = ArgNum - 1; I >= 0; --I) { @@ -883,7 +883,9 @@ // If the struct is to be deallocated, remove the shadow entry. if (Info.DelEntry) { DP("Removing shadow pointer " DPxMOD "\n", DPxPTR((void **)Itr->first)); - Itr = Device.ShadowPtrMap.erase(Itr); + auto OldItr = Itr; + Itr++; + Device.ShadowPtrMap.erase(OldItr); } else { ++Itr; } @@ -1171,12 +1173,12 @@ }; /// A vector of target pointers for all private arguments - std::vector TgtPtrs; + llvm::SmallVector TgtPtrs; /// A vector of information of all first-private arguments to be packed - std::vector FirstPrivateArgInfo; + llvm::SmallVector FirstPrivateArgInfo; /// Host buffer for all arguments to be packed - std::vector FirstPrivateArgBuffer; + llvm::SmallVector FirstPrivateArgBuffer; /// The total size of all arguments to be packed int64_t FirstPrivateArgSize = 0; @@ -1255,7 +1257,7 @@ /// Pack first-private arguments, replace place holder pointers in \p TgtArgs, /// and start the transfer. - int packAndTransfer(std::vector &TgtArgs) { + int packAndTransfer(llvm::SmallVector &TgtArgs) { if (!FirstPrivateArgInfo.empty()) { assert(FirstPrivateArgSize != 0 && "FirstPrivateArgSize is 0 but FirstPrivateArgInfo is empty"); @@ -1323,8 +1325,8 @@ int32_t ArgNum, void **ArgBases, void **Args, int64_t *ArgSizes, int64_t *ArgTypes, map_var_info_t *ArgNames, void **ArgMappers, - std::vector &TgtArgs, - std::vector &TgtOffsets, + llvm::SmallVector &TgtArgs, + llvm::SmallVector &TgtOffsets, PrivateArgumentManagerTy &PrivateArgumentManager, AsyncInfoTy &AsyncInfo) { TIMESCOPE_WITH_NAME_AND_IDENT("mappingBeforeTargetRegion", Loc); @@ -1337,7 +1339,7 @@ } // List of (first-)private arrays allocated for this target region - std::vector TgtArgsPositions(ArgNum, -1); + llvm::SmallVector TgtArgsPositions(ArgNum, -1); for (int32_t I = 0; I < ArgNum; ++I) { if (!(ArgTypes[I] & OMP_TGT_MAPTYPE_TARGET_PARAM)) { @@ -1521,8 +1523,8 @@ // begin addresses, not bases. That's why we pass args and offsets as two // separate entities so that each plugin can do what it needs. This behavior // was introdued via https://reviews.llvm.org/D33028 and commit 1546d319244c. - std::vector TgtArgs; - std::vector TgtOffsets; + llvm::SmallVector TgtArgs; + llvm::SmallVector TgtOffsets; PrivateArgumentManagerTy PrivateArgumentManager(Device, AsyncInfo); @@ -1547,11 +1549,11 @@ TIMESCOPE_WITH_NAME_AND_IDENT( IsTeamConstruct ? "runTargetTeamRegion" : "runTargetRegion", Loc); if (IsTeamConstruct) - Ret = Device.runTeamRegion(TgtEntryPtr, &TgtArgs[0], &TgtOffsets[0], + Ret = Device.runTeamRegion(TgtEntryPtr, TgtArgs.data(), TgtOffsets.data(), TgtArgs.size(), TeamNum, ThreadLimit, Tripcount, AsyncInfo); else - Ret = Device.runRegion(TgtEntryPtr, &TgtArgs[0], &TgtOffsets[0], + Ret = Device.runRegion(TgtEntryPtr, TgtArgs.data(), TgtOffsets.data(), TgtArgs.size(), AsyncInfo); } diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -67,7 +67,7 @@ // components are dynamically decided, so we utilize C++ STL vector // implementation here. struct MapperComponentsTy { - std::vector Components; + llvm::SmallVector Components; int32_t size() { return Components.size(); } };