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 <jh1302.park@samsung.com>
#include "coco/ADT/PtrLink.h"
-#include <vector>
+#include <map>
namespace coco
{
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);
UpdateSlot<Bag> _into;
private:
- std::vector<ElemID> _content;
+ std::map<ElemID /* DST */, ElemID /* SRC */> _content;
};
} // namespace coco
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<Bag *> Shuffle::reads(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