/home/runner/work/HiCR/HiCR/include/hicr/backends/lpf/communicationManager.hpp Source File
HiCR
|
communicationManager.hpp
Go to the documentation of this file.
77 __INLINE__ uint8_t *serializeGlobalMemorySlot(const std::shared_ptr<HiCR::GlobalMemorySlot> &globalSlot) const override
82 if (lpfSlot == nullptr) HICR_THROW_LOGIC("The memory slot is not compatible with this backend\n");
109 __INLINE__ std::shared_ptr<HiCR::GlobalMemorySlot> deserializeGlobalMemorySlot(uint8_t *buffer, GlobalMemorySlot::tag_t tag) override
111 // first <sizeof(lpf_pid_t)> bytes are the rank, followed by the size of the lpf slot buffer, the rest is the lpf slot buffer
134 __INLINE__ std::shared_ptr<HiCR::GlobalMemorySlot> promoteLocalMemorySlot(const std::shared_ptr<HiCR::LocalMemorySlot> &memorySlot, HiCR::GlobalMemorySlot::tag_t tag) override
147 CHECK(lpf_noc_register(_lpf, lpfSwapSlotPtr, sizeof(uint64_t), &lpfSwapSlot)); // TODO: check if sizeof(uint64_t) is correct
159 __INLINE__ void destroyPromotedGlobalMemorySlot(const std::shared_ptr<HiCR::GlobalMemorySlot> &memorySlot) override
170 if (lpfSlot->getLPFSwapSlot() != LPF_INVALID_MEMSLOT) CHECK(lpf_noc_deregister(_lpf, lpfSlot->getLPFSwapSlot()));
190 std::shared_ptr<HiCR::GlobalMemorySlot> getGlobalMemorySlotImpl(HiCR::GlobalMemorySlot::tag_t tag, HiCR::GlobalMemorySlot::globalKey_t globalKey) override { return nullptr; }
192 __INLINE__ void exchangeGlobalMemorySlotsImpl(HiCR::GlobalMemorySlot::tag_t tag, const std::vector<globalKeyMemorySlotPair_t> &memorySlots) override
227 for (size_t i = 0; i < _size; i++) globalSlotCountsInBytes[i] = globalSlotCounts[i] * sizeof(size_t);
230 for (size_t i = 0; i < _size; i++) globalSlotPidCountsInBytes[i] = globalSlotCounts[i] * sizeof(lpf_pid_t);
252 CHECK(lpf_register_local(_lpf, localSlotSizes.data(), localSlotCount * sizeof(size_t), &slot_local_sizes));
253 CHECK(lpf_register_global(_lpf, globalSlotSizes.data(), globalSlotCount * sizeof(size_t), &slot_global_sizes));
257 CHECK(lpf_collectives_init(_lpf, _rank, _size, 2 /* will call gatherv 2 times */, 0, sizeof(size_t) * globalSlotCount, &coll));
258 CHECK(lpf_allgatherv(coll, slot_local_sizes, slot_global_sizes, globalSlotCountsInBytes.data(), false /*exclude myself*/));
260 CHECK(lpf_register_local(_lpf, localSlotProcessId.data(), localSlotCount * sizeof(lpf_pid_t), &slot_local_process_ids));
261 CHECK(lpf_register_global(_lpf, globalSlotProcessId.data(), globalSlotCount * sizeof(lpf_pid_t), &slot_global_process_ids));
264 CHECK(lpf_allgatherv(coll, slot_local_process_ids, slot_global_process_ids, globalSlotPidCountsInBytes.data(), false /*exclude myself*/));
272 CHECK(lpf_register_local(_lpf, localSlotKeys.data(), localSlotCount * sizeof(size_t), &slot_local_keys));
273 CHECK(lpf_register_global(_lpf, globalSlotKeys.data(), globalSlotCount * sizeof(size_t), &slot_global_keys));
277 CHECK(lpf_allgatherv(coll, slot_local_keys, slot_global_keys, globalSlotCountsInBytes.data(), false /*exclude myself*/));
288 // If the rank associated with this slot is remote, don't store the pointer, otherwise store it.
315 CHECK(lpf_register_global(_lpf, globalSwapSlotPointer, globalSwapSlotSizes[i], &swapValueSlot));
325 auto memorySlot = std::make_shared<lpf::GlobalMemorySlot>(globalSlotProcessId[i], newSlot, swapValueSlot, tag, globalSlotKeys[i], globalSourceSlot);
344 CHECK(lpf_register_global(_lpf, globalDestroySlotCounts.data(), sizeof(size_t) * _size, &dst_slot));
358 // If there are no slots to destroy from any instance, return to avoid a second round of collectives
366 for (size_t i = 0; i < _size; i++) globalDestroySlotCountsInBytes[i] = globalDestroySlotCounts[i] * 2 * sizeof(size_t);
378 if (memorySlot.get() == nullptr) HICR_THROW_FATAL("Trying to use LPF to destroy a non-LPF global slot");
387 CHECK(lpf_register_local(_lpf, localDestroySlotIds.data(), localDestroySlotsCount * sizeof(lpf_memslot_t), &slot_local_ids));
388 CHECK(lpf_register_global(_lpf, globalDestroySlotIds.data(), globalDestroySlotTotalCount * sizeof(lpf_memslot_t), &slot_global_ids));
392 CHECK(lpf_collectives_init(_lpf, _rank, _size, 1, 0, sizeof(lpf_memslot_t) * globalDestroySlotTotalCount, &coll));
393 CHECK(lpf_allgatherv(coll, slot_local_ids, slot_global_ids, globalDestroySlotCountsInBytes.data(), false /* exclude myself */));
401 auto globalDestroySlotIdsSet = std::set<lpf_memslot_t>(globalDestroySlotIds.begin(), globalDestroySlotIds.end());
413 __INLINE__ void destroyGlobalMemorySlotImpl(std::shared_ptr<HiCR::GlobalMemorySlot> memorySlotPtr) override
419 if (memorySlot == nullptr) HICR_THROW_LOGIC("The memory slot is not supported by this backend\n");
436 if (source == nullptr) HICR_THROW_LOGIC("The passed source memory slot is not supported by this backend\n");
442 if (dest == nullptr) HICR_THROW_LOGIC("The passed destination memory slot is not supported by this backend\n");
465 if (src == nullptr) HICR_THROW_LOGIC("The passed source memory slot is not supported by this backend\n");
471 if (dest == nullptr) HICR_THROW_LOGIC("The passed destination memory slot is not supported by this backend\n");
507 HICR_THROW_LOGIC("getGlobalMemorySlots: Requesting a global memory slot for a tag (%lu) that has not been registered.", tag);
518 __INLINE__ void fenceImpl(const std::shared_ptr<HiCR::LocalMemorySlot> &slot, size_t expectedSent, size_t expectedRcvd) override
522 if (lpfSlot == LPF_INVALID_MEMSLOT) { HICR_THROW_LOGIC("This slot is not registered with LPF!"); }
523 CHECK(lpf_counting_sync_per_slot(_lpf, LPF_SYNC_DEFAULT, lpfSlot, memSlot->getMessagesSent() + expectedSent, memSlot->getMessagesRecv() + expectedRcvd));
559 __INLINE__ void queryMemorySlotUpdatesImpl(std::shared_ptr<HiCR::LocalMemorySlot> memorySlot) override { fenceImplSingle(memorySlot); }
564 __INLINE__ bool acquireGlobalLockImpl(std::shared_ptr<HiCR::GlobalMemorySlot> memorySlot) override
569 CHECK(lpf_lock_slot(_lpf, _localSwapSlot, 0, slotRank, lpfSwapSlot, 0, sizeof(uint64_t), LPF_MSG_DEFAULT));
573 __INLINE__ void releaseGlobalLockImpl(std::shared_ptr<HiCR::GlobalMemorySlot> memorySlot) override
578 CHECK(lpf_unlock_slot(_lpf, _localSwapSlot, 0, slotRank, lpfSwapSlot, 0, sizeof(uint64_t), LPF_MSG_DEFAULT));
Definition communicationManager.hpp:54
__INLINE__ auto & getGlobalMemorySlotTagKeyMap()
Definition communicationManager.hpp:643
__INLINE__ void setMessagesSent(HiCR::LocalMemorySlot &memorySlot, const size_t count) noexcept
Definition communicationManager.hpp:675
__INLINE__ void registerGlobalMemorySlot(const std::shared_ptr< GlobalMemorySlot > &memorySlot)
Definition communicationManager.hpp:503
std::map< GlobalMemorySlot::globalKey_t, std::shared_ptr< GlobalMemorySlot > > globalKeyToMemorySlotMap_t
Definition communicationManager.hpp:65
__INLINE__ auto & getGlobalMemorySlotsToDestroyPerTag()
Definition communicationManager.hpp:637
__INLINE__ void setMessagesRecv(HiCR::LocalMemorySlot &memorySlot, const size_t count) noexcept
Definition communicationManager.hpp:667
Definition communicationManager.hpp:46
__INLINE__ uint8_t * serializeGlobalMemorySlot(const std::shared_ptr< HiCR::GlobalMemorySlot > &globalSlot) const override
Definition communicationManager.hpp:77
__INLINE__ void destroyPromotedGlobalMemorySlot(const std::shared_ptr< HiCR::GlobalMemorySlot > &memorySlot) override
Definition communicationManager.hpp:159
__INLINE__ std::shared_ptr< HiCR::GlobalMemorySlot > promoteLocalMemorySlot(const std::shared_ptr< HiCR::LocalMemorySlot > &memorySlot, HiCR::GlobalMemorySlot::tag_t tag) override
Definition communicationManager.hpp:134
__INLINE__ std::shared_ptr< HiCR::GlobalMemorySlot > deserializeGlobalMemorySlot(uint8_t *buffer, GlobalMemorySlot::tag_t tag) override
Definition communicationManager.hpp:109
CommunicationManager(size_t size, size_t rank, lpf_t lpf)
Definition communicationManager.hpp:60
Provides a definition for the base backend's communication manager class.
Provides a definition for a HiCR Global Memory Slot class.
Provides a definition for a HiCR Local Memory Slot class.
Generated by