Skip to content

Commit

Permalink
fixing events
Browse files Browse the repository at this point in the history
  • Loading branch information
kab163 committed Oct 25, 2024
1 parent 7601037 commit 9ee6b00
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/umpire/Allocator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ inline void* Allocator::do_resource_allocate(camp::resources::Resource const& r,
}

umpire::event::record<umpire::event::allocate_resource>(
[&](auto& event) { event.size(bytes).ref((void*)m_allocator).ptr(ret).res(r); });
[&](auto& event) { event.size(bytes).ref((void*)m_allocator).ptr(ret).res(camp::resources::to_string(r)); });
return ret;
}

Expand Down Expand Up @@ -149,7 +149,7 @@ inline void Allocator::do_deallocate(void* ptr)
inline void Allocator::do_resource_deallocate(camp::resources::Resource const& r, void* ptr)
{
umpire::event::record<umpire::event::deallocate_resource>(
[&](auto& event) { event.ref((void*)m_allocator).ptr(ptr).res(r); });
[&](auto& event) { event.ref((void*)m_allocator).ptr(ptr).res(camp::resources::to_string(r)); });

UMPIRE_LOG(Debug, "(" << ptr << ")");

Expand Down
10 changes: 5 additions & 5 deletions src/umpire/event/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace camp {
namespace resources {
inline namespace v1 {

inline std::string to_string(camp::resources::Resource& r)
inline std::string to_string(const camp::resources::Resource& r)
{
switch (r.get_platform()) {
case camp::resources::Platform::cuda:
Expand Down Expand Up @@ -94,7 +94,7 @@ struct allocate_resource {
std::size_t size;
void* ref;
void* ptr;
camp::resources::Resource res;
std::string res;
std::chrono::time_point<std::chrono::system_clock> timestamp{std::chrono::system_clock::now()};
};

Expand All @@ -107,7 +107,7 @@ struct deallocate {
struct deallocate_resource {
void* ref;
void* ptr;
camp::resources::Resource res;
std::string res;
std::chrono::time_point<std::chrono::system_clock> timestamp{std::chrono::system_clock::now()};
};

Expand Down Expand Up @@ -319,7 +319,7 @@ class builder<allocate_resource> {
return *this;
}

builder& res(camp::resources::Resource res)
builder& res(const std::string& res)
{
e.res = res;
return *this;
Expand Down Expand Up @@ -375,7 +375,7 @@ class builder<deallocate_resource> {
return *this;
}

builder& res(camp::resources::Resource res)
builder& res(const std::string& res)
{
e.res = res;
return *this;
Expand Down
4 changes: 2 additions & 2 deletions src/umpire/event/json_file_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void json_file_store::insert(const allocate_resource& e)
R"(,"tags":{"replay":"true"})"
R"(,"timestamp":%lld})"
"\n",
e.size, e.ref, e.ptr, camp::resources::to_string(e.res),
e.size, e.ref, e.ptr, e.res.c_str(),
static_cast<long long>(
std::chrono::time_point_cast<std::chrono::nanoseconds>(e.timestamp).time_since_epoch().count()));
}
Expand All @@ -99,7 +99,7 @@ void json_file_store::insert(const deallocate_resource& e)
R"(,"tags":{"replay":"true"})"
R"(,"timestamp":%lld})"
"\n",
e.ref, e.ptr, camp::resources::to_string(e.res),
e.ref, e.ptr, e.res.c_str(),
static_cast<long long>(
std::chrono::time_point_cast<std::chrono::nanoseconds>(e.timestamp).time_since_epoch().count()));
}
Expand Down
4 changes: 2 additions & 2 deletions src/umpire/event/sqlite_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void sqlite_database::insert(const allocate_resource& e)
"INSERT INTO EVENTS VALUES(json('"
R"({"category":"operation","name":"allocate_resource")"
R"(,"numeric_args":{"size":%ld})"
R"(,"string_args":{"allocator_ref":"%p","pointer":"%p","resource":"%p"})"
R"(,"string_args":{"allocator_ref":"%p","pointer":"%p","resource":"%s"})"
R"(,"tags":{"replay":"true"})"
R"(,"timestamp":%lld})"
"'));",
Expand Down Expand Up @@ -143,7 +143,7 @@ void sqlite_database::insert(const deallocate_resource& e)
sprintf(buffer,
"INSERT INTO EVENTS VALUES(json('"
R"({"category":"operation","name":"deallocate")"
R"(,"string_args":{"allocator_ref":"%p","pointer":"%p", "resource":"%p"})"
R"(,"string_args":{"allocator_ref":"%p","pointer":"%p", "resource":"%s"})"
R"(,"tags":{"replay":"true"})"
R"(,"timestamp":%lld})"
"'));",
Expand Down

0 comments on commit 9ee6b00

Please sign in to comment.