Mneme
Mneme a tool allowing recording the execution of a GPU (CUDA/HIP) kernel and replaying that kernel as an independent executable.
Loading...
Searching...
No Matches
MnemeUtils.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstddef>
3#include <cstdint>
4#include <iomanip>
5#include <iostream>
6#include <string>
7
8#if MNEME_ENABLE_DEBUG
9#define MNEME_DBG(x) x;
10#else
11#define MNEME_DBG(x)
12#endif
13
14namespace mneme {
15namespace util {
16template <typename Ty> Ty roundUp(Ty Size, Ty Divider) {
17 return (Size + Divider - 1) & ~(Divider - 1);
18}
19template <typename Ty> Ty extractScalar(const char *&Buffer) {
20 Ty Value = *reinterpret_cast<const Ty *>(Buffer);
21 Buffer += sizeof(Ty);
22 return Value;
23}
24template <typename Ty> Ty extractScalar(char *&Buffer) {
25 Ty Value = *reinterpret_cast<const Ty *>(Buffer);
26 Buffer += sizeof(Ty);
27 return Value;
28}
29
30inline std::string readSizedString(const char *&Buffer) {
31 size_t StrLen = extractScalar<size_t>(Buffer);
32 std::string Name{Buffer, StrLen};
33 Buffer += StrLen;
34 return Name;
35}
36
37} // namespace util
38} // namespace mneme
int64_t u64 Size
Definition cupti_profile.cpp:179
std::string readSizedString(const char *&Buffer)
Definition MnemeUtils.hpp:30
Ty extractScalar(const char *&Buffer)
Definition MnemeUtils.hpp:19
Ty roundUp(Ty Size, Ty Divider)
Definition MnemeUtils.hpp:16
Definition MnemeAnnotation.cpp:3