8#include <unordered_map>
12#include <llvm/ADT/ArrayRef.h>
13#include <llvm/ADT/SmallVector.h>
14#include <llvm/ADT/StringRef.h>
15#include <llvm/Support/MemoryBuffer.h>
16#include <llvm/Support/raw_ostream.h>
25#include <proteus/KernelMetadata.h>
40 delete[]
static_cast<uint8_t *
>(
HostAddr);
49 Other.HostAddr =
nullptr;
54 this->HostAddr = Other.HostAddr;
55 this->DevAddr = Other.DevAddr;
56 this->VarSize = Other.VarSize;
57 Other.HostAddr =
nullptr;
65template <DeviceVendors VendorTypes>
struct Snapshot {
66 std::shared_ptr<KernelInfo>
KInfo;
67 std::unordered_map<std::string, ReplayGlobalVar>
GlobalVars;
71inline std::pair<std::string, ReplayGlobalVar>
75 std::memcpy(
const_cast<void *
>(RGV.
HostAddr), Buffer, Header.
Size);
76 Buffer += Header.
Size;
77 LOG_DEBUG(
"Loaded from buffer Global, Name:{}, VarSize:{}, RecoredAddr:{}",
79 return std::pair<std::string, ReplayGlobalVar>(std::move(Header.
Name),
85 std::unordered_map<std::string, std::vector<uint8_t>>;
94 static constexpr char Magic[8] = {
'M',
'N',
'E',
'M',
'E',
'S',
'N',
'P'};
95 static constexpr size_t Size = 16;
98 static std::pair<SnapshotHeader, size_t>
parse(llvm::StringRef Buffer);
99 void write(llvm::raw_ostream &OS)
const;
103 static constexpr char LegacyDiffMagic[] =
"MNEME_DIFF_V1";
104 static constexpr size_t LegacyDiffMagicSize =
sizeof(LegacyDiffMagic) - 1;
107inline std::pair<SnapshotHeader, size_t>
109 if (Buffer.size() >=
Size &&
110 Buffer.starts_with(llvm::StringRef(
Magic,
sizeof(
Magic)))) {
113 std::memcpy(&
Kind, Buffer.data() +
sizeof(
Magic),
sizeof(
Kind));
119 if (Buffer.starts_with(llvm::StringRef(LegacyDiffMagic, LegacyDiffMagicSize)))
138 std::unique_ptr<llvm::MemoryBuffer>
Buffer,
148 read(
const std::string &KernelName,
157 std::unique_ptr<llvm::MemoryBuffer>
Buffer;
166 : Filename(std::move(Filename)) {}
168 bool empty()
const {
return Filename.empty(); }
173 std::string Filename;
184 std::unordered_map<std::string, ReplayGlobalVar> &GlobalVars) {
186 LOG_DEBUG(
"Snapshot contains {} Globals", TotalGlobals);
187 for (
size_t I = 0; I < TotalGlobals; ++I) {
189 GlobalVars.try_emplace(Name, std::move(RGV));
195 LOG_DEBUG(
"Snapshot contains {} total arguments", TotalArguments);
197 KInfo.
ArgData.resize(TotalArguments);
198 for (
size_t A = 0; A < TotalArguments; ++A) {
204template <DeviceVendors VendorTypes>
206 const std::string &KernelName,
207 const std::string &Filename) {
209 LOG_FATAL(
"Mneme diff snapshot " + Filename +
210 " requires a base prologue snapshot");
211 return Base.
load(KernelName);
215 const std::string &Filename,
const char *What) {
216 if (Actual != Expected)
217 LOG_FATAL(
"Mneme diff " + Filename +
" does not match prologue " + What +
223 llvm::MutableArrayRef<uint8_t> Target) {
225 for (
size_t R = 0; R < NumRanges; ++R) {
228 if (Offset > Target.size() ||
Size > Target.size() - Offset)
229 LOG_FATAL(
"Malformed Mneme diff range: offset " + std::to_string(Offset) +
230 " size " + std::to_string(
Size) +
" exceeds target size " +
231 std::to_string(Target.size()));
232 std::memcpy(Target.data() + Offset, Buffer,
Size);
239 std::unordered_map<std::string, ReplayGlobalVar> &GlobalVars,
240 const std::string &Filename) {
242 expectCount(TotalGlobals, GlobalVars.size(), Filename,
"global");
243 for (
size_t I = 0; I < TotalGlobals; ++I) {
245 auto It = GlobalVars.find(GVH.
Name);
246 if (It == GlobalVars.end())
247 LOG_FATAL(
"Mneme diff references global missing from prologue: " +
249 if (It->second.VarSize != GVH.
Size)
250 LOG_FATAL(
"Mneme diff global size mismatch for: " + GVH.
Name);
251 It->second.DevAddr = GVH.
DevAddr;
253 static_cast<uint8_t *
>(It->second.HostAddr),
254 It->second.VarSize));
259template <DeviceVendors VendorTypes>
264 auto It = DeviceMemory.find(BH.
DevAddr);
265 if (It == DeviceMemory.end())
266 LOG_FATAL(
"Mneme diff references device allocation missing from "
268 auto &Blob = It->second;
269 if (Blob.getActualSize() != BH.
ActualSize || Blob.getSize() != BH.
Size)
270 LOG_FATAL(
"Mneme diff memory blob size mismatch");
274template <DeviceVendors VendorTypes>
280 const std::string &Filename) {
281 if (Buffer != File.getBufferEnd())
282 LOG_FATAL(
"Unexpected trailing bytes in Mneme snapshot " + Filename);
287template <DeviceVendors VendorTypes>
297 read(
const std::string &KernelName,
300 Snap.
KInfo = std::make_shared<KernelInfo>(KernelName);
301 const char *CurrentPtr = this->
payload();
305 for (
size_t I = 0; I < TotalMemBlobs; ++I)
314template <DeviceVendors VendorTypes>
324 read(
const std::string &KernelName,
327 Snap.
KInfo = std::make_shared<KernelInfo>(KernelName);
328 const char *CurrentPtr = this->
payload();
332 for (
size_t I = 0; I < TotalMemBlobs; ++I)
344template <DeviceVendors VendorTypes>
354 read(
const std::string &KernelName,
358 const char *CurrentPtr = this->
payload();
364 this->Filename,
"memory blob");
365 for (
size_t I = 0; I < TotalMemBlobs; ++I) {
368 Blob.readWholeBlobMetadata(CurrentPtr);
378template <DeviceVendors VendorTypes>
388 read(
const std::string &KernelName,
392 const char *CurrentPtr = this->
payload();
398 this->Filename,
"memory blob");
399 for (
size_t I = 0; I < TotalMemBlobs; ++I) {
402 Blob.readAnnotations(CurrentPtr);
417 static std::unique_ptr<SnapshotReader<VendorTypes>>
418 open(
const std::string &Filename) {
419 LOG_DEBUG(
"Opening snapshot file {}", Filename);
420 auto Buffer = openSnapshotFile(Filename);
424 const Entry *Table = table(Count);
425 for (
size_t I = 0; I < Count; ++I)
426 if (Table[I].Kind == Header.Kind && Table[I].Version == Header.Version)
427 return Table[I].Make(Filename, std::move(Buffer), PayloadOffset);
429 LOG_FATAL(
"Unsupported Mneme snapshot format in " + Filename +
": kind " +
430 std::to_string(
static_cast<uint32_t
>(Header.Kind)) +
" version " +
431 std::to_string(Header.Version));
435 using Factory = std::unique_ptr<SnapshotReader<VendorTypes>> (*)(
436 std::string, std::unique_ptr<llvm::MemoryBuffer>,
size_t);
444 template <
typename ReaderT>
445 static std::unique_ptr<SnapshotReader<VendorTypes>>
446 make(std::string Filename, std::unique_ptr<llvm::MemoryBuffer> Buffer,
447 size_t PayloadOffset) {
448 return std::make_unique<ReaderT>(std::move(Filename), std::move(Buffer),
452 template <
typename ReaderT>
static constexpr Entry entry() {
453 return {ReaderT::Layout.Kind, ReaderT::Layout.Version, &make<ReaderT>};
456 static const Entry *table(
size_t &Count) {
457 static const Entry Table[] = {
458 entry<BytesReaderV0<VendorTypes>>(),
459 entry<BytesReaderV1<VendorTypes>>(),
460 entry<DiffReaderV1<VendorTypes>>(),
461 entry<DiffReaderV2<VendorTypes>>(),
463 Count =
sizeof(Table) /
sizeof(Table[0]);
467 static std::unique_ptr<llvm::MemoryBuffer>
468 openSnapshotFile(
const std::string &Filename) {
469 if (!std::filesystem::exists(Filename))
470 LOG_FATAL(
"Mneme Snapshot file does not exist");
472 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> BufferOrErr =
473 llvm::MemoryBuffer::getFile(Filename);
474 if (std::error_code EC = BufferOrErr.getError())
475 LOG_FATAL(
"Error when opening file " + EC.message());
477 return std::move(BufferOrErr.get());
481template <DeviceVendors VendorTypes>
485 LOG_FATAL(
"No base snapshot was provided");
488 if (Reader->requiresBaseSnapshot())
490 " cannot be used as a base because it itself requires a base");
506 const proteus::runtime::GlobalMetadata &GV) {
507 return GlobalVarHeader{Name, GV.VarSize,
const_cast<void *
>(GV.DevAddr)};
511template <DeviceVendors VendorTypes>
514 std::vector<uint8_t> HostData(GV.VarSize);
517 HostData.data(),
const_cast<void *
>(GV.DevAddr), GV.VarSize,
520 LOG_FATAL(
"Copying from device to host for global variable failed");
531 virtual std::filesystem::path
532 write(
const std::filesystem::path &Filename,
540template <DeviceVendors VendorTypes>
543 std::filesystem::path
544 write(
const std::filesystem::path &Filename,
546 LOG_DEBUG(
"Storing mneme snapshot: {}", Filename.string());
550 llvm::raw_fd_ostream OS(Filename.string(), EC);
552 LOG_FATAL(
"Cannot write Mneme snapshot: " + EC.message());
556 return Filename.filename();
574 bool UpdateBase)
const = 0;
583 LOG_FATAL(
"Synchronizing stream failed before snapshot");
589 void write_impl(
const char *,
size_t Size)
override { Pos +=
Size; }
590 uint64_t current_pos()
const override {
return Pos; }
598template <DeviceVendors VendorTypes>
603 std::shared_ptr<GlobalSnapshotData> CaptureGlobals =
nullptr)
604 : CaptureGlobals(std::move(CaptureGlobals)) {}
613 Size +=
sizeof(size_t);
614 for (
const auto &[VarName, GV] : In.
GlobalVars) {
619 Size +=
sizeof(size_t);
621 Size += Blob.serializedSize();
623 Size +=
sizeof(size_t);
625 Size +=
sizeof(size_t);
641 void **Args = In.
Args;
644 size_t TotalGlobals = GlobalVars.size();
645 OutBC << llvm::StringRef(reinterpret_cast<const char *>(&TotalGlobals),
648 LOG_DEBUG(
"Number of Globals in snapshot:{} stored at position:{}",
649 TotalGlobals, OutBC.tell());
651 for (
const auto &[VarName, GV] : GlobalVars) {
657 (*CaptureGlobals)[VarName] = std::move(HostData);
660 size_t TotalBlobs = DeviceMemory.size();
661 LOG_DEBUG(
"Number of Memory Blobs in snapshot:{} stored at position:{}",
662 TotalBlobs, OutBC.tell());
664 OutBC << llvm::StringRef(reinterpret_cast<const char *>(&TotalBlobs),
668 for (
auto &[Ptr, Blob] : DeviceMemory)
669 Blob.writeWithAnnotations(OutBC);
671 size_t NumArgs = KernelArgSizes.size();
672 LOG_DEBUG(
"Number of Kernel Arguments in snapshot:{} stored at position:{}",
673 NumArgs, OutBC.tell());
675 OutBC << llvm::StringRef(reinterpret_cast<const char *>(&NumArgs),
678 for (
int I = 0; I < NumArgs; I++) {
679 OutBC << llvm::StringRef(
680 reinterpret_cast<const char *
>(&KernelArgSizes[I]),
sizeof(
size_t));
681 OutBC << llvm::StringRef(reinterpret_cast<const char *>(Args[I]),
687 std::shared_ptr<GlobalSnapshotData> CaptureGlobals;
690template <DeviceVendors VendorTypes>
693 explicit DiffWriter(std::shared_ptr<const GlobalSnapshotData> PrologueGlobals)
694 : PrologueGlobals(std::move(PrologueGlobals)) {
695 if (!this->PrologueGlobals)
696 LOG_FATAL(
"A Mneme diff snapshot needs the prologue globals to diff "
707 bool UpdateBaseData)
const override {
711 size_t TotalGlobals = GlobalVars.size();
713 for (
const auto &[VarName, GV] : GlobalVars) {
714 auto BaseIt = PrologueGlobals->find(VarName);
715 if (BaseIt == PrologueGlobals->end())
716 LOG_FATAL(
"Cannot diff global missing from prologue: " + VarName);
717 if (BaseIt->second.size() != GV.VarSize)
718 LOG_FATAL(
"Cannot diff global with size mismatch: " + VarName);
724 llvm::SmallVector<char, 0> DiffBytes;
725 llvm::raw_svector_ostream DiffOS(DiffBytes);
726 size_t NumRanges = writeChangedRanges(DiffOS, BaseIt->second, Current, 0);
727 emitRanges(OutBC, NumRanges, DiffBytes);
730 size_t TotalBlobs = DeviceMemory.size();
732 for (
auto &[Ptr, Blob] : DeviceMemory) {
733 BlobHeader{Blob.getActualSize(), Blob.getSize(), Blob.getBlobAddr()}
737 writeCountAndWriteChangedRanges(OutBC, Blob, UpdateBaseData);
742 static constexpr size_t DiffChunkSize = 1 << 20;
746 static void emitRanges(llvm::raw_ostream &OS,
size_t NumRanges,
747 const llvm::SmallVectorImpl<char> &DiffBytes) {
753 writeChangedRanges(llvm::raw_ostream &OS, llvm::ArrayRef<uint8_t> Base,
754 llvm::ArrayRef<uint8_t> Current,
size_t BaseOffset,
755 llvm::MutableArrayRef<uint8_t> UpdateBase = {}) {
756 if (Base.size() != Current.size())
757 LOG_FATAL(
"Cannot diff buffers with different sizes");
758 if (!UpdateBase.empty() && UpdateBase.size() != Base.size())
759 LOG_FATAL(
"Cannot update diff base with mismatched buffer size");
765 while (I < Base.size()) {
766 while (I < Base.size() && Base[I] == Current[I])
768 if (I == Base.size())
772 while (I < Base.size() && Base[I] != Current[I])
775 size_t Offset = BaseOffset + Start;
776 size_t Len = I - Start;
780 if (!UpdateBase.empty())
781 std::memcpy(UpdateBase.data() + Start, Current.data() + Start, Len);
788 writeCountAndWriteChangedRanges(llvm::raw_ostream &OS,
789 MnemeMemoryBlob<VendorTypes> &Blob,
790 bool UpdateBaseData =
true) {
791 auto Size = Blob.getSize();
795 size_t NumRanges = 0;
800 std::unique_ptr<uint8_t[]> Scratch(
new uint8_t[DiffChunkSize]);
801 llvm::SmallVector<char, 0> DiffBytes;
802 llvm::raw_svector_ostream DiffOS(DiffBytes);
803 auto *Base = Blob.getHostData();
804 auto *DevAddr =
static_cast<uint8_t *
>(Blob.getBlobAddr());
805 size_t NumRanges = 0;
807 for (
size_t Offset = 0; Offset <
Size; Offset += DiffChunkSize) {
808 size_t ChunkSize = std::min(DiffChunkSize,
Size - Offset);
809 auto EC = DeviceTraits<VendorTypes>::DeviceErrorCheck(
810 DeviceTraits<VendorTypes>::DeviceCopy(
811 Scratch.get(), DevAddr + Offset, ChunkSize,
812 DeviceTraits<VendorTypes>::MemcpyDeviceToHostKind()));
814 LOG_FATAL(
"Error in copying data from device when writing diff\n"
815 "Device Error Msg: " +
818 llvm::ArrayRef<uint8_t> ChunkBase(Base + Offset, ChunkSize);
819 llvm::ArrayRef<uint8_t> ChunkCurrent(Scratch.get(), ChunkSize);
820 if (UpdateBaseData) {
821 llvm::MutableArrayRef<uint8_t> UpdateBase(Base + Offset, ChunkSize);
822 NumRanges += writeChangedRanges(DiffOS, ChunkBase, ChunkCurrent, Offset,
826 writeChangedRanges(DiffOS, ChunkBase, ChunkCurrent, Offset);
830 emitRanges(OS, NumRanges, DiffBytes);
833 std::shared_ptr<const GlobalSnapshotData> PrologueGlobals;
837template <DeviceVendors VendorTypes>
840 explicit BestWriter(std::shared_ptr<const GlobalSnapshotData> PrologueGlobals)
841 : Diff(std::move(PrologueGlobals)) {}
843 std::filesystem::path
844 write(
const std::filesystem::path &Filename,
846 size_t DiffSize = Diff.measure(In);
847 size_t BytesSize = Bytes.measure(In);
849 if (DiffSize <= BytesSize)
850 return Diff.write(Filename, In);
852 return Bytes.write(Filename, In);
856 return std::min(Diff.measure(In), Bytes.measure(In));
865template <DeviceVendors VendorTypes>
866std::unique_ptr<SnapshotWriter<VendorTypes>>
868 std::shared_ptr<const GlobalSnapshotData> PrologueGlobals) {
871 return std::make_unique<BytesWriter<VendorTypes>>();
873 return std::make_unique<DiffWriter<VendorTypes>>(
874 std::move(PrologueGlobals));
876 return std::make_unique<BestWriter<VendorTypes>>(
877 std::move(PrologueGlobals));
880 LOG_FATAL(
"Unknown Mneme epilogue snapshot type");
#define LOG_DEBUG(...)
Definition MnemeLogger.hpp:109
#define LOG_FATAL(...)
Definition MnemeLogger.hpp:113
Definition MnemeSnapshotFormat.hpp:162
BaseSnapshotSource(std::string Filename="")
Definition MnemeSnapshotFormat.hpp:165
bool empty() const
Definition MnemeSnapshotFormat.hpp:168
Snapshot< VendorTypes > load(const std::string &KernelName) const
Definition MnemeSnapshotFormat.hpp:483
size_t measure(const SnapshotInput< VendorTypes > &In) const override
Definition MnemeSnapshotFormat.hpp:855
std::filesystem::path write(const std::filesystem::path &Filename, const SnapshotInput< VendorTypes > &In) const override
Definition MnemeSnapshotFormat.hpp:844
BestWriter(std::shared_ptr< const GlobalSnapshotData > PrologueGlobals)
Definition MnemeSnapshotFormat.hpp:840
Definition MnemeSnapshotFormat.hpp:288
static constexpr SnapshotHeader Layout
Definition MnemeSnapshotFormat.hpp:292
bool requiresBaseSnapshot() const override
Definition MnemeSnapshotFormat.hpp:294
Snapshot< VendorTypes > read(const std::string &KernelName, const BaseSnapshotSource< VendorTypes > &) const override
Definition MnemeSnapshotFormat.hpp:297
Definition MnemeSnapshotFormat.hpp:315
static constexpr SnapshotHeader Layout
Definition MnemeSnapshotFormat.hpp:319
bool requiresBaseSnapshot() const override
Definition MnemeSnapshotFormat.hpp:321
Snapshot< VendorTypes > read(const std::string &KernelName, const BaseSnapshotSource< VendorTypes > &) const override
Definition MnemeSnapshotFormat.hpp:324
Definition MnemeSnapshotFormat.hpp:599
size_t measure(const SnapshotInput< VendorTypes > &In) const override
Definition MnemeSnapshotFormat.hpp:608
BytesWriter(std::shared_ptr< GlobalSnapshotData > CaptureGlobals=nullptr)
Definition MnemeSnapshotFormat.hpp:602
SnapshotHeader header() const override
Definition MnemeSnapshotFormat.hpp:632
void writePayload(llvm::raw_ostream &OutBC, const SnapshotInput< VendorTypes > &In, bool) const override
Definition MnemeSnapshotFormat.hpp:636
Definition MnemeSnapshotFormat.hpp:345
static constexpr SnapshotHeader Layout
Definition MnemeSnapshotFormat.hpp:349
bool requiresBaseSnapshot() const override
Definition MnemeSnapshotFormat.hpp:351
Snapshot< VendorTypes > read(const std::string &KernelName, const BaseSnapshotSource< VendorTypes > &Base) const override
Definition MnemeSnapshotFormat.hpp:354
Definition MnemeSnapshotFormat.hpp:379
static constexpr SnapshotHeader Layout
Definition MnemeSnapshotFormat.hpp:383
Snapshot< VendorTypes > read(const std::string &KernelName, const BaseSnapshotSource< VendorTypes > &Base) const override
Definition MnemeSnapshotFormat.hpp:388
bool requiresBaseSnapshot() const override
Definition MnemeSnapshotFormat.hpp:385
Definition MnemeSnapshotFormat.hpp:691
DiffWriter(std::shared_ptr< const GlobalSnapshotData > PrologueGlobals)
Definition MnemeSnapshotFormat.hpp:693
SnapshotHeader header() const override
Definition MnemeSnapshotFormat.hpp:701
void writePayload(llvm::raw_ostream &OutBC, const SnapshotInput< VendorTypes > &In, bool UpdateBaseData) const override
Definition MnemeSnapshotFormat.hpp:705
Definition MnemeMemory.hpp:227
static std::pair< void *, MnemeMemoryBlob< VendorTypes > > readWithAnnotations(const char *&Buffer)
Definition MnemeMemory.hpp:479
uint8_t * getHostData() const
Definition MnemeMemory.hpp:547
static std::pair< void *, MnemeMemoryBlob< VendorTypes > > readWithMetadata(const char *&Buffer)
Definition MnemeMemory.hpp:468
uint64_t getSize() const
Definition MnemeMemory.hpp:545
SnapshotReader(std::string Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer, size_t PayloadOffset)
Definition MnemeSnapshotFormat.hpp:137
virtual Snapshot< VendorTypes > read(const std::string &KernelName, const BaseSnapshotSource< VendorTypes > &Base) const =0
virtual ~SnapshotReader()=default
virtual bool requiresBaseSnapshot() const =0
std::string Filename
Definition MnemeSnapshotFormat.hpp:156
const char * payload() const
Definition MnemeSnapshotFormat.hpp:152
std::unique_ptr< llvm::MemoryBuffer > Buffer
Definition MnemeSnapshotFormat.hpp:157
size_t PayloadOffset
Definition MnemeSnapshotFormat.hpp:158
Definition MnemeSnapshotFormat.hpp:526
virtual ~SnapshotWriter()=default
virtual size_t measure(const SnapshotInput< VendorTypes > &In) const =0
virtual std::filesystem::path write(const std::filesystem::path &Filename, const SnapshotInput< VendorTypes > &In) const =0
int64_t u64 Size
Definition cupti_profile.cpp:179
Definition attribute.cpp:39
Definition MnemeSnapshotFormat.hpp:176
llvm::MutableArrayRef< uint8_t > hostBytes(MnemeMemoryBlob< VendorTypes > &Blob)
Definition MnemeSnapshotFormat.hpp:275
void applyDiffRanges(const char *&Buffer, llvm::MutableArrayRef< uint8_t > Target)
Definition MnemeSnapshotFormat.hpp:222
void expectPayloadEnd(const char *Buffer, const llvm::MemoryBuffer &File, const std::string &Filename)
Definition MnemeSnapshotFormat.hpp:279
void applyGlobalDiffs(const char *&Buffer, std::unordered_map< std::string, ReplayGlobalVar > &GlobalVars, const std::string &Filename)
Definition MnemeSnapshotFormat.hpp:238
MnemeMemoryBlob< VendorTypes > & readDiffBlobHeader(const char *&Buffer, BlobsByAddress< VendorTypes > &DeviceMemory)
Definition MnemeSnapshotFormat.hpp:261
void readGlobals(const char *&Buffer, std::unordered_map< std::string, ReplayGlobalVar > &GlobalVars)
Definition MnemeSnapshotFormat.hpp:183
void expectCount(size_t Actual, size_t Expected, const std::string &Filename, const char *What)
Definition MnemeSnapshotFormat.hpp:214
Snapshot< VendorTypes > loadDiffBase(const BaseSnapshotSource< VendorTypes > &Base, const std::string &KernelName, const std::string &Filename)
Definition MnemeSnapshotFormat.hpp:205
void readArgs(const char *&Buffer, KernelInfo &KInfo)
Definition MnemeSnapshotFormat.hpp:193
void writeBytes(llvm::raw_ostream &OS, llvm::StringRef Data)
Definition MnemeLLVMUtils.hpp:44
Ty extractScalar(const char *&Buffer)
Definition MnemeUtils.hpp:19
void writeScalar(llvm::raw_ostream &OS, const Ty &Value)
Definition MnemeLLVMUtils.hpp:40
Definition MnemeAnnotation.cpp:3
std::pair< std::string, ReplayGlobalVar > readGlobalVarRecord(const char *&Buffer)
Definition MnemeSnapshotFormat.hpp:72
void writeAnnotationsToStream(llvm::raw_ostream &OS, const std::vector< MemoryAnnotation > &Annotations)
Definition MnemeMemory.hpp:75
std::unique_ptr< SnapshotWriter< VendorTypes > > makeEpilogueWriter(EpilogueSnapshotType Type, std::shared_ptr< const GlobalSnapshotData > PrologueGlobals)
Definition MnemeSnapshotFormat.hpp:867
std::vector< uint8_t > readGlobalFromDevice(const proteus::runtime::GlobalMetadata &GV)
Definition MnemeSnapshotFormat.hpp:513
std::unordered_map< std::string, std::vector< uint8_t > > GlobalSnapshotData
Definition MnemeSnapshotFormat.hpp:84
GlobalVarHeader globalVarHeader(const std::string &Name, const proteus::runtime::GlobalMetadata &GV)
Definition MnemeSnapshotFormat.hpp:505
EpilogueSnapshotType
Definition MnemeConfig.hpp:24
@ Diff
Definition MnemeConfig.hpp:24
@ Bytes
Definition MnemeConfig.hpp:24
@ Best
Definition MnemeConfig.hpp:24
SnapshotKind
Definition MnemeSnapshotFormat.hpp:87
@ Diff
Definition MnemeSnapshotFormat.hpp:87
@ Bytes
Definition MnemeSnapshotFormat.hpp:87
std::map< void *, MnemeMemoryBlob< VendorTypes > > BlobsByAddress
Definition MnemeMemory.hpp:605
Definition DeviceTraits.hpp:73
Definition MnemeKernelInfo.hpp:13
void setArgData(const char *&Data, int Index)
Definition MnemeKernelInfo.hpp:39
llvm::SmallVector< size_t > KernelArgSizes
Definition MnemeKernelInfo.hpp:17
llvm::SmallVector< std::unique_ptr< uint8_t[]> > ArgData
Definition MnemeKernelInfo.hpp:21
Definition MnemeSnapshotFormat.hpp:29
ReplayGlobalVar(void *DevAddr, uint64_t VarSize)
Definition MnemeSnapshotFormat.hpp:33
void * HostAddr
Definition MnemeSnapshotFormat.hpp:30
void * DevAddr
Definition MnemeSnapshotFormat.hpp:31
ReplayGlobalVar & operator=(const ReplayGlobalVar &)=delete
~ReplayGlobalVar()
Definition MnemeSnapshotFormat.hpp:38
ReplayGlobalVar & operator=(ReplayGlobalVar &&Other)
Definition MnemeSnapshotFormat.hpp:52
uint64_t VarSize
Definition MnemeSnapshotFormat.hpp:32
ReplayGlobalVar(const ReplayGlobalVar &)=delete
ReplayGlobalVar(ReplayGlobalVar &&Other)
Definition MnemeSnapshotFormat.hpp:46
ReplayGlobalVar(void *HostAddr, void *DevAddr, uint64_t VarSize)
Definition MnemeSnapshotFormat.hpp:35
Definition MnemeSnapshotFormat.hpp:65
BlobsByAddress< VendorTypes > DeviceMemory
Definition MnemeSnapshotFormat.hpp:68
std::shared_ptr< KernelInfo > KInfo
Definition MnemeSnapshotFormat.hpp:66
std::unordered_map< std::string, ReplayGlobalVar > GlobalVars
Definition MnemeSnapshotFormat.hpp:67