From f46fc2033a468f496916f7a07402f423202e97ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 6 Sep 2018 19:54:46 +0900 Subject: [PATCH] [coco] Support partial shuffling (#1382) Shuffle instruction now uses 'map' instead of 'vector' to store element transfers between two bags. This change allows users to encode partial shuffling in coco IR. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Shuffle.h | 12 +++++++++--- contrib/coco/core/src/IR/Shuffle.cpp | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Shuffle.h b/contrib/coco/core/include/coco/IR/Shuffle.h index 00908c0..759ced7 100644 --- a/contrib/coco/core/include/coco/IR/Shuffle.h +++ b/contrib/coco/core/include/coco/IR/Shuffle.h @@ -9,7 +9,7 @@ #include "coco/ADT/PtrLink.h" -#include +#include namespace coco { @@ -46,7 +46,13 @@ public: void into(Bag *); public: - const ElemID &at(uint32_t n) const { return _content.at(n); } + /** + * Let M be the return of at(N). This means that N-th element in the destination + * bag will be filled with the value of M-th element in the source bag. + * + * NOTE at(n) may be undefined on partial shuffle + */ + const ElemID &at(uint32_t n) const { return _content.at(ElemID{n}); } public: void insert(const ElemID &from, const ElemID &into); @@ -59,7 +65,7 @@ private: UpdateSlot _into; private: - std::vector _content; + std::map _content; }; } // namespace coco diff --git a/contrib/coco/core/src/IR/Shuffle.cpp b/contrib/coco/core/src/IR/Shuffle.cpp index 08926cb..afa1926 100644 --- a/contrib/coco/core/src/IR/Shuffle.cpp +++ b/contrib/coco/core/src/IR/Shuffle.cpp @@ -15,7 +15,7 @@ std::set &operator+=(std::set &res, coco::Bag *b) namespace coco { -void Shuffle::insert(const ElemID &from, const ElemID &into) { _content.at(into.value()) = from; } +void Shuffle::insert(const ElemID &from, const ElemID &into) { _content[into] = from; } std::set Shuffle::reads(void) const { @@ -36,11 +36,6 @@ std::set Shuffle::updates(void) const } void Shuffle::from(Bag *b) { _from.value(b); } - -void Shuffle::into(Bag *b) -{ - _into.value(b); - _content.resize((b == nullptr) ? 0 : b->size()); -} +void Shuffle::into(Bag *b) { _into.value(b); } } // namespace coco -- 2.7.4