11#pragma once
22
3+ #include < memory_resource>
34#include < new>
45#include < vector>
5- #include < memory_resource>
66
77#include < catch2/catch.hpp>
88
99namespace nvdetail = nvexec::_strm;
1010
11- namespace {
11+ namespace
12+ {
1213
13- struct tracer_resource : public std ::pmr::memory_resource {
14- struct allocation_info_t {
15- void * ptr;
14+ struct tracer_resource : public std ::pmr::memory_resource
15+ {
16+ struct allocation_info_t
17+ {
18+ void * ptr;
1619 size_t bytes;
1720 size_t alignment;
1821
19- bool operator ==(const allocation_info_t & other) const noexcept {
22+ bool operator ==(allocation_info_t const & other) const noexcept
23+ {
2024 return ptr == other.ptr && bytes == other.bytes && alignment == other.alignment ;
2125 }
2226 };
2327
2428 std::vector<allocation_info_t > allocations;
2529
26- void * do_allocate (size_t bytes, size_t alignment) override {
30+ void * do_allocate (size_t bytes, size_t alignment) override
31+ {
2732 INFO (" Allocate: " << bytes << " bytes, " << alignment << " alignment" );
2833 void * ptr = ::operator new [](bytes, std::align_val_t (alignment));
2934 allocations.push_back (allocation_info_t {ptr, bytes, alignment});
3035 return ptr;
3136 }
3237
33- void do_deallocate (void * ptr, size_t bytes, size_t alignment) override {
38+ void do_deallocate (void * ptr, size_t bytes, size_t alignment) override
39+ {
3440 INFO (" Deallocate: " << bytes << " bytes, " << alignment << " alignment" );
3541
36- auto it =
37- std::find (allocations.begin (), allocations.end (), allocation_info_t {ptr, bytes, alignment});
42+ auto it = std::find (allocations.begin (),
43+ allocations.end (),
44+ allocation_info_t {ptr, bytes, alignment});
3845
3946 REQUIRE (it != allocations.end ());
4047
41- if (it != allocations.end ()) {
48+ if (it != allocations.end ())
49+ {
4250 allocations.erase (it);
4351 ::operator delete[] (ptr, std::align_val_t (alignment));
4452 }
4553 }
4654
47- bool do_is_equal (const std::pmr::memory_resource& other) const noexcept override {
55+ bool do_is_equal (std::pmr::memory_resource const & other) const noexcept override
56+ {
4857 return this == &other;
4958 }
5059 };
51- } // namespace
60+ } // namespace
0 commit comments