Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MemoryTracer.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MemoryTracer.h (C) 2000-2026 */
9/* */
10/* Utilities for tracing memory accesses between the accelerator and the */
11/* host. */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCCORE_COMMON_ACCELERATOR_INTERNAL_MEMORYTRACER_H
14#define ARCCORE_COMMON_ACCELERATOR_INTERNAL_MEMORYTRACER_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arccore/common/accelerator/CommonAcceleratorGlobal.h"
19
20#include <tuple>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Accelerator::Impl
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
36class ARCCORE_COMMON_EXPORT MemoryTracer
37{
38 public:
39
40 static void notifyMemoryAllocation(Span<const std::byte> bytes, const String& name, const String& stack_trace, Int64 timestamp);
41 static void notifyMemoryFree(void* ptr, const String& name, const String& stack_trace, Int64 timestamp);
42 static std::pair<String, String> findMemory(const void* ptr);
43};
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
52class ARCCORE_COMMON_EXPORT MemoryTracerWrapper
53{
54 public:
55
56 MemoryTracerWrapper();
57
58 public:
59
60 bool isActive() const { return m_trace_level > 0; }
61 void traceDeallocate(const AllocatedMemoryInfo& mem_info, const MemoryAllocationArgs& args);
62 void traceAllocate(void* p, size_t new_size, MemoryAllocationArgs args);
63 void setTraceLevel(Int32 v) { m_trace_level = v; }
64
65 private:
66
67 Int32 m_trace_level = 0;
68};
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73} // namespace Arcane::Accelerator::Impl
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78#endif
Utility class for tracing memory accesses between the accelerator and the host.
Information about an allocated memory region.
Class containing information to specialize allocations.
View of an array of elements of type T.
Definition Span.h:635
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.