Skip to content

Commit 60121e3

Browse files
vlad-scherbichpytorchmergebot
authored andcommitted
[caffe2] Replace CAFFE_ prefixes in static_tracepoint.h macros with TORCH_ (pytorch#106380)
Summary: Rename static tracepoint macros to better describe their targeted usage. Test Plan: Same as for D47159249: Tested the following macros on test scripts with libbpf USDTs: * `CAFFE_SDT` * `CAFFE_DISABLE_SDT` * `CAFFE_SDT_WITH_SEMAPHORE` Reviewed By: chaekit Differential Revision: D47727339 Pull Request resolved: pytorch#106380 Approved by: https://github.com/chaekit
1 parent 1642dae commit 60121e3

7 files changed

+114
-116
lines changed

c10/util/static_tracepoint.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
#pragma once
22

33
#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) && \
4-
!CAFFE_DISABLE_SDT
4+
!TORCH_DISABLE_SDT
55

6-
#define CAFFE_HAVE_SDT 1
6+
#define TORCH_HAVE_SDT 1
77

88
#include <c10/util/static_tracepoint_elfx86.h>
99

10-
#define CAFFE_SDT(name, ...) \
11-
CAFFE_SDT_PROBE_N( \
12-
caffe2, name, 0, CAFFE_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
13-
// Use CAFFE_SDT_DEFINE_SEMAPHORE(name) to define the semaphore
14-
// as global variable before using the CAFFE_SDT_WITH_SEMAPHORE macro
15-
#define CAFFE_SDT_WITH_SEMAPHORE(name, ...) \
16-
CAFFE_SDT_PROBE_N( \
17-
caffe2, name, 1, CAFFE_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
18-
#define CAFFE_SDT_IS_ENABLED(name) (CAFFE_SDT_SEMAPHORE(caffe2, name) > 0)
10+
#define TORCH_SDT(name, ...) \
11+
TORCH_SDT_PROBE_N( \
12+
pytorch, name, 0, TORCH_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
13+
// Use TORCH_SDT_DEFINE_SEMAPHORE(name) to define the semaphore
14+
// as global variable before using the TORCH_SDT_WITH_SEMAPHORE macro
15+
#define TORCH_SDT_WITH_SEMAPHORE(name, ...) \
16+
TORCH_SDT_PROBE_N( \
17+
pytorch, name, 1, TORCH_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
18+
#define TORCH_SDT_IS_ENABLED(name) (TORCH_SDT_SEMAPHORE(pytorch, name) > 0)
1919

2020
#else
2121

22-
#define CAFFE_HAVE_SDT 0
22+
#define TORCH_HAVE_SDT 0
2323

24-
#define CAFFE_SDT(name, ...) \
24+
#define TORCH_SDT(name, ...) \
2525
do { \
2626
} while (0)
27-
#define CAFFE_SDT_WITH_SEMAPHORE(name, ...) \
27+
#define TORCH_SDT_WITH_SEMAPHORE(name, ...) \
2828
do { \
2929
} while (0)
30-
#define CAFFE_SDT_IS_ENABLED(name) (false)
31-
#define CAFFE_SDT_DEFINE_SEMAPHORE(name)
32-
#define CAFFE_SDT_DECLARE_SEMAPHORE(name)
30+
#define TORCH_SDT_IS_ENABLED(name) (false)
31+
#define TORCH_SDT_DEFINE_SEMAPHORE(name)
32+
#define TORCH_SDT_DECLARE_SEMAPHORE(name)
3333

3434
#endif

c10/util/static_tracepoint_elfx86.h

+85-85
Original file line numberDiff line numberDiff line change
@@ -4,130 +4,130 @@
44
#include <cstddef>
55

66
// Default constraint for the probe arguments as operands.
7-
#ifndef CAFFE_SDT_ARG_CONSTRAINT
8-
#define CAFFE_SDT_ARG_CONSTRAINT "nor"
7+
#ifndef TORCH_SDT_ARG_CONSTRAINT
8+
#define TORCH_SDT_ARG_CONSTRAINT "nor"
99
#endif
1010

1111
// Instruction to emit for the probe.
12-
#define CAFFE_SDT_NOP nop
12+
#define TORCH_SDT_NOP nop
1313

1414
// Note section properties.
15-
#define CAFFE_SDT_NOTE_NAME "stapsdt"
16-
#define CAFFE_SDT_NOTE_TYPE 3
15+
#define TORCH_SDT_NOTE_NAME "stapsdt"
16+
#define TORCH_SDT_NOTE_TYPE 3
1717

1818
// Semaphore variables are put in this section
19-
#define CAFFE_SDT_SEMAPHORE_SECTION ".probes"
19+
#define TORCH_SDT_SEMAPHORE_SECTION ".probes"
2020

2121
// Size of address depending on platform.
2222
#ifdef __LP64__
23-
#define CAFFE_SDT_ASM_ADDR .8byte
23+
#define TORCH_SDT_ASM_ADDR .8byte
2424
#else
25-
#define CAFFE_SDT_ASM_ADDR .4byte
25+
#define TORCH_SDT_ASM_ADDR .4byte
2626
#endif
2727

2828
// Assembler helper Macros.
29-
#define CAFFE_SDT_S(x) #x
30-
#define CAFFE_SDT_ASM_1(x) CAFFE_SDT_S(x) "\n"
31-
#define CAFFE_SDT_ASM_2(a, b) CAFFE_SDT_S(a) "," CAFFE_SDT_S(b) "\n"
32-
#define CAFFE_SDT_ASM_3(a, b, c) CAFFE_SDT_S(a) "," CAFFE_SDT_S(b) "," \
33-
CAFFE_SDT_S(c) "\n"
34-
#define CAFFE_SDT_ASM_STRING(x) CAFFE_SDT_ASM_1(.asciz CAFFE_SDT_S(x))
29+
#define TORCH_SDT_S(x) #x
30+
#define TORCH_SDT_ASM_1(x) TORCH_SDT_S(x) "\n"
31+
#define TORCH_SDT_ASM_2(a, b) TORCH_SDT_S(a) "," TORCH_SDT_S(b) "\n"
32+
#define TORCH_SDT_ASM_3(a, b, c) TORCH_SDT_S(a) "," TORCH_SDT_S(b) "," \
33+
TORCH_SDT_S(c) "\n"
34+
#define TORCH_SDT_ASM_STRING(x) TORCH_SDT_ASM_1(.asciz TORCH_SDT_S(x))
3535

3636
// Helper to determine the size of an argument.
37-
#define CAFFE_SDT_IS_ARRAY_POINTER(x) ((__builtin_classify_type(x) == 14) || \
37+
#define TORCH_SDT_IS_ARRAY_POINTER(x) ((__builtin_classify_type(x) == 14) || \
3838
(__builtin_classify_type(x) == 5))
39-
#define CAFFE_SDT_ARGSIZE(x) (CAFFE_SDT_IS_ARRAY_POINTER(x) \
39+
#define TORCH_SDT_ARGSIZE(x) (TORCH_SDT_IS_ARRAY_POINTER(x) \
4040
? sizeof(void*) \
4141
: sizeof(x))
4242

4343
// Format of each probe arguments as operand.
44-
// Size of the argument tagged with CAFFE_SDT_Sn, with "n" constraint.
45-
// Value of the argument tagged with CAFFE_SDT_An, with configured constraint.
46-
#define CAFFE_SDT_ARG(n, x) \
47-
[CAFFE_SDT_S##n] "n" ((size_t)CAFFE_SDT_ARGSIZE(x)), \
48-
[CAFFE_SDT_A##n] CAFFE_SDT_ARG_CONSTRAINT (x)
44+
// Size of the argument tagged with TORCH_SDT_Sn, with "n" constraint.
45+
// Value of the argument tagged with TORCH_SDT_An, with configured constraint.
46+
#define TORCH_SDT_ARG(n, x) \
47+
[TORCH_SDT_S##n] "n" ((size_t)TORCH_SDT_ARGSIZE(x)), \
48+
[TORCH_SDT_A##n] TORCH_SDT_ARG_CONSTRAINT (x)
4949

5050
// Templates to append arguments as operands.
51-
#define CAFFE_SDT_OPERANDS_0() [__sdt_dummy] "g" (0)
52-
#define CAFFE_SDT_OPERANDS_1(_1) CAFFE_SDT_ARG(1, _1)
53-
#define CAFFE_SDT_OPERANDS_2(_1, _2) \
54-
CAFFE_SDT_OPERANDS_1(_1), CAFFE_SDT_ARG(2, _2)
55-
#define CAFFE_SDT_OPERANDS_3(_1, _2, _3) \
56-
CAFFE_SDT_OPERANDS_2(_1, _2), CAFFE_SDT_ARG(3, _3)
57-
#define CAFFE_SDT_OPERANDS_4(_1, _2, _3, _4) \
58-
CAFFE_SDT_OPERANDS_3(_1, _2, _3), CAFFE_SDT_ARG(4, _4)
59-
#define CAFFE_SDT_OPERANDS_5(_1, _2, _3, _4, _5) \
60-
CAFFE_SDT_OPERANDS_4(_1, _2, _3, _4), CAFFE_SDT_ARG(5, _5)
61-
#define CAFFE_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6) \
62-
CAFFE_SDT_OPERANDS_5(_1, _2, _3, _4, _5), CAFFE_SDT_ARG(6, _6)
63-
#define CAFFE_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7) \
64-
CAFFE_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6), CAFFE_SDT_ARG(7, _7)
65-
#define CAFFE_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8) \
66-
CAFFE_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7), CAFFE_SDT_ARG(8, _8)
67-
#define CAFFE_SDT_OPERANDS_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) \
68-
CAFFE_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8), CAFFE_SDT_ARG(9, _9)
51+
#define TORCH_SDT_OPERANDS_0() [__sdt_dummy] "g" (0)
52+
#define TORCH_SDT_OPERANDS_1(_1) TORCH_SDT_ARG(1, _1)
53+
#define TORCH_SDT_OPERANDS_2(_1, _2) \
54+
TORCH_SDT_OPERANDS_1(_1), TORCH_SDT_ARG(2, _2)
55+
#define TORCH_SDT_OPERANDS_3(_1, _2, _3) \
56+
TORCH_SDT_OPERANDS_2(_1, _2), TORCH_SDT_ARG(3, _3)
57+
#define TORCH_SDT_OPERANDS_4(_1, _2, _3, _4) \
58+
TORCH_SDT_OPERANDS_3(_1, _2, _3), TORCH_SDT_ARG(4, _4)
59+
#define TORCH_SDT_OPERANDS_5(_1, _2, _3, _4, _5) \
60+
TORCH_SDT_OPERANDS_4(_1, _2, _3, _4), TORCH_SDT_ARG(5, _5)
61+
#define TORCH_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6) \
62+
TORCH_SDT_OPERANDS_5(_1, _2, _3, _4, _5), TORCH_SDT_ARG(6, _6)
63+
#define TORCH_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7) \
64+
TORCH_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6), TORCH_SDT_ARG(7, _7)
65+
#define TORCH_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8) \
66+
TORCH_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7), TORCH_SDT_ARG(8, _8)
67+
#define TORCH_SDT_OPERANDS_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) \
68+
TORCH_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8), TORCH_SDT_ARG(9, _9)
6969

7070
// Templates to reference the arguments from operands in note section.
71-
#define CAFFE_SDT_ARGFMT(no) %n[CAFFE_SDT_S##no]@%[CAFFE_SDT_A##no]
72-
#define CAFFE_SDT_ARG_TEMPLATE_0 /*No arguments*/
73-
#define CAFFE_SDT_ARG_TEMPLATE_1 CAFFE_SDT_ARGFMT(1)
74-
#define CAFFE_SDT_ARG_TEMPLATE_2 CAFFE_SDT_ARG_TEMPLATE_1 CAFFE_SDT_ARGFMT(2)
75-
#define CAFFE_SDT_ARG_TEMPLATE_3 CAFFE_SDT_ARG_TEMPLATE_2 CAFFE_SDT_ARGFMT(3)
76-
#define CAFFE_SDT_ARG_TEMPLATE_4 CAFFE_SDT_ARG_TEMPLATE_3 CAFFE_SDT_ARGFMT(4)
77-
#define CAFFE_SDT_ARG_TEMPLATE_5 CAFFE_SDT_ARG_TEMPLATE_4 CAFFE_SDT_ARGFMT(5)
78-
#define CAFFE_SDT_ARG_TEMPLATE_6 CAFFE_SDT_ARG_TEMPLATE_5 CAFFE_SDT_ARGFMT(6)
79-
#define CAFFE_SDT_ARG_TEMPLATE_7 CAFFE_SDT_ARG_TEMPLATE_6 CAFFE_SDT_ARGFMT(7)
80-
#define CAFFE_SDT_ARG_TEMPLATE_8 CAFFE_SDT_ARG_TEMPLATE_7 CAFFE_SDT_ARGFMT(8)
81-
#define CAFFE_SDT_ARG_TEMPLATE_9 CAFFE_SDT_ARG_TEMPLATE_8 CAFFE_SDT_ARGFMT(9)
71+
#define TORCH_SDT_ARGFMT(no) %n[TORCH_SDT_S##no]@%[TORCH_SDT_A##no]
72+
#define TORCH_SDT_ARG_TEMPLATE_0 /*No arguments*/
73+
#define TORCH_SDT_ARG_TEMPLATE_1 TORCH_SDT_ARGFMT(1)
74+
#define TORCH_SDT_ARG_TEMPLATE_2 TORCH_SDT_ARG_TEMPLATE_1 TORCH_SDT_ARGFMT(2)
75+
#define TORCH_SDT_ARG_TEMPLATE_3 TORCH_SDT_ARG_TEMPLATE_2 TORCH_SDT_ARGFMT(3)
76+
#define TORCH_SDT_ARG_TEMPLATE_4 TORCH_SDT_ARG_TEMPLATE_3 TORCH_SDT_ARGFMT(4)
77+
#define TORCH_SDT_ARG_TEMPLATE_5 TORCH_SDT_ARG_TEMPLATE_4 TORCH_SDT_ARGFMT(5)
78+
#define TORCH_SDT_ARG_TEMPLATE_6 TORCH_SDT_ARG_TEMPLATE_5 TORCH_SDT_ARGFMT(6)
79+
#define TORCH_SDT_ARG_TEMPLATE_7 TORCH_SDT_ARG_TEMPLATE_6 TORCH_SDT_ARGFMT(7)
80+
#define TORCH_SDT_ARG_TEMPLATE_8 TORCH_SDT_ARG_TEMPLATE_7 TORCH_SDT_ARGFMT(8)
81+
#define TORCH_SDT_ARG_TEMPLATE_9 TORCH_SDT_ARG_TEMPLATE_8 TORCH_SDT_ARGFMT(9)
8282

8383
// Semaphore define, declare and probe note format
8484

85-
#define CAFFE_SDT_SEMAPHORE(provider, name) \
86-
caffe_sdt_semaphore_##provider##_##name
85+
#define TORCH_SDT_SEMAPHORE(provider, name) \
86+
torch_sdt_semaphore_##provider##_##name
8787

88-
#define CAFFE_SDT_DEFINE_SEMAPHORE(name) \
88+
#define TORCH_SDT_DEFINE_SEMAPHORE(name) \
8989
extern "C" { \
90-
volatile unsigned short CAFFE_SDT_SEMAPHORE(caffe2, name) \
91-
__attribute__((section(CAFFE_SDT_SEMAPHORE_SECTION), used)) = 0; \
90+
volatile unsigned short TORCH_SDT_SEMAPHORE(pytorch, name) \
91+
__attribute__((section(TORCH_SDT_SEMAPHORE_SECTION), used)) = 0; \
9292
}
9393

94-
#define CAFFE_SDT_DECLARE_SEMAPHORE(name) \
95-
extern "C" volatile unsigned short CAFFE_SDT_SEMAPHORE(caffe2, name)
94+
#define TORCH_SDT_DECLARE_SEMAPHORE(name) \
95+
extern "C" volatile unsigned short TORCH_SDT_SEMAPHORE(pytorch, name)
9696

97-
#define CAFFE_SDT_SEMAPHORE_NOTE_0(provider, name) \
98-
CAFFE_SDT_ASM_1( CAFFE_SDT_ASM_ADDR 0) /*No Semaphore*/ \
97+
#define TORCH_SDT_SEMAPHORE_NOTE_0(provider, name) \
98+
TORCH_SDT_ASM_1( TORCH_SDT_ASM_ADDR 0) /*No Semaphore*/ \
9999

100-
#define CAFFE_SDT_SEMAPHORE_NOTE_1(provider, name) \
101-
CAFFE_SDT_ASM_1(CAFFE_SDT_ASM_ADDR CAFFE_SDT_SEMAPHORE(provider, name))
100+
#define TORCH_SDT_SEMAPHORE_NOTE_1(provider, name) \
101+
TORCH_SDT_ASM_1(TORCH_SDT_ASM_ADDR TORCH_SDT_SEMAPHORE(provider, name))
102102

103103
// Structure of note section for the probe.
104-
#define CAFFE_SDT_NOTE_CONTENT(provider, name, has_semaphore, arg_template) \
105-
CAFFE_SDT_ASM_1(990: CAFFE_SDT_NOP) \
106-
CAFFE_SDT_ASM_3( .pushsection .note.stapsdt,"","note") \
107-
CAFFE_SDT_ASM_1( .balign 4) \
108-
CAFFE_SDT_ASM_3( .4byte 992f-991f, 994f-993f, CAFFE_SDT_NOTE_TYPE) \
109-
CAFFE_SDT_ASM_1(991: .asciz CAFFE_SDT_NOTE_NAME) \
110-
CAFFE_SDT_ASM_1(992: .balign 4) \
111-
CAFFE_SDT_ASM_1(993: CAFFE_SDT_ASM_ADDR 990b) \
112-
CAFFE_SDT_ASM_1( CAFFE_SDT_ASM_ADDR 0) /*Reserved for Base Address*/ \
113-
CAFFE_SDT_SEMAPHORE_NOTE_##has_semaphore(provider, name) \
114-
CAFFE_SDT_ASM_STRING(provider) \
115-
CAFFE_SDT_ASM_STRING(name) \
116-
CAFFE_SDT_ASM_STRING(arg_template) \
117-
CAFFE_SDT_ASM_1(994: .balign 4) \
118-
CAFFE_SDT_ASM_1( .popsection)
104+
#define TORCH_SDT_NOTE_CONTENT(provider, name, has_semaphore, arg_template) \
105+
TORCH_SDT_ASM_1(990: TORCH_SDT_NOP) \
106+
TORCH_SDT_ASM_3( .pushsection .note.stapsdt,"","note") \
107+
TORCH_SDT_ASM_1( .balign 4) \
108+
TORCH_SDT_ASM_3( .4byte 992f-991f, 994f-993f, TORCH_SDT_NOTE_TYPE) \
109+
TORCH_SDT_ASM_1(991: .asciz TORCH_SDT_NOTE_NAME) \
110+
TORCH_SDT_ASM_1(992: .balign 4) \
111+
TORCH_SDT_ASM_1(993: TORCH_SDT_ASM_ADDR 990b) \
112+
TORCH_SDT_ASM_1( TORCH_SDT_ASM_ADDR 0) /*Reserved for Base Address*/ \
113+
TORCH_SDT_SEMAPHORE_NOTE_##has_semaphore(provider, name) \
114+
TORCH_SDT_ASM_STRING(provider) \
115+
TORCH_SDT_ASM_STRING(name) \
116+
TORCH_SDT_ASM_STRING(arg_template) \
117+
TORCH_SDT_ASM_1(994: .balign 4) \
118+
TORCH_SDT_ASM_1( .popsection)
119119

120120
// Main probe Macro.
121-
#define CAFFE_SDT_PROBE(provider, name, has_semaphore, n, arglist) \
121+
#define TORCH_SDT_PROBE(provider, name, has_semaphore, n, arglist) \
122122
__asm__ __volatile__ ( \
123-
CAFFE_SDT_NOTE_CONTENT( \
124-
provider, name, has_semaphore, CAFFE_SDT_ARG_TEMPLATE_##n) \
125-
:: CAFFE_SDT_OPERANDS_##n arglist \
123+
TORCH_SDT_NOTE_CONTENT( \
124+
provider, name, has_semaphore, TORCH_SDT_ARG_TEMPLATE_##n) \
125+
:: TORCH_SDT_OPERANDS_##n arglist \
126126
) \
127127

128128
// Helper Macros to handle variadic arguments.
129-
#define CAFFE_SDT_NARG_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N
130-
#define CAFFE_SDT_NARG(...) \
131-
CAFFE_SDT_NARG_(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
132-
#define CAFFE_SDT_PROBE_N(provider, name, has_semaphore, N, ...) \
133-
CAFFE_SDT_PROBE(provider, name, has_semaphore, N, (__VA_ARGS__))
129+
#define TORCH_SDT_NARG_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N
130+
#define TORCH_SDT_NARG(...) \
131+
TORCH_SDT_NARG_(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
132+
#define TORCH_SDT_PROBE_N(provider, name, has_semaphore, N, ...) \
133+
TORCH_SDT_PROBE(provider, name, has_semaphore, N, (__VA_ARGS__))

caffe2/core/net_dag_utils.cc

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <unordered_set>
77

88
#include "caffe2/core/operator.h"
9-
#include "c10/util/static_tracepoint.h"
109
#include "caffe2/core/timer.h"
1110
#include "caffe2/proto/caffe2_pb.h"
1211
#include "caffe2/utils/proto_utils.h"

caffe2/core/net_simple.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ bool SimpleNet::Run() {
6262
const auto& op_type = op->debug_def().type().c_str();
6363
auto* op_ptr = op.get();
6464
const auto& net_name = name_.c_str();
65-
CAFFE_SDT(operator_start, net_name, op_name, op_type, op_ptr);
65+
TORCH_SDT(operator_start, net_name, op_name, op_type, op_ptr);
6666
#endif
6767
bool res = op->Run();
6868
#ifdef CAFFE2_ENABLE_SDT
69-
CAFFE_SDT(operator_done, net_name, op_name, op_type, op_ptr);
69+
TORCH_SDT(operator_done, net_name, op_name, op_type, op_ptr);
7070
#endif
7171
// workaround for async cpu ops, we need to explicitly wait for them
7272
if (res && op->HasAsyncPart() &&

caffe2/core/net_simple_refcount.cc

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <unordered_set>
88

99
#include "caffe2/core/operator.h"
10-
#include "c10/util/static_tracepoint.h"
1110
#include "caffe2/core/timer.h"
1211
#include "caffe2/proto/caffe2_pb.h"
1312
#include "caffe2/utils/proto_utils.h"

caffe2/core/stats.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ _ScopeGuard<T> ScopeGuard(T f) {
343343
#define CAFFE_EVENT(stats, field, ...) \
344344
{ \
345345
auto __caffe_event_value_ = stats.field.increment(__VA_ARGS__); \
346-
CAFFE_SDT( \
346+
TORCH_SDT( \
347347
field, \
348348
stats.field.groupName.c_str(), \
349349
__caffe_event_value_, \

caffe2/queue/blobs_queue.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool BlobsQueue::blockingRead(
6262
Timer readTimer;
6363
auto keeper = this->shared_from_this();
6464
C10_UNUSED const auto& name = name_.c_str();
65-
CAFFE_SDT(queue_read_start, name, (void*)this, SDT_BLOCKING_OP);
65+
TORCH_SDT(queue_read_start, name, (void*)this, SDT_BLOCKING_OP);
6666
std::unique_lock<std::mutex> g(mutex_);
6767
auto canRead = [this]() {
6868
CAFFE_ENFORCE_LE(reader_, writer_);
@@ -81,9 +81,9 @@ bool BlobsQueue::blockingRead(
8181
if (!canRead()) {
8282
if (timeout_secs > 0 && !closing_) {
8383
LOG(ERROR) << "DequeueBlobs timed out in " << timeout_secs << " secs";
84-
CAFFE_SDT(queue_read_end, name, (void*)this, SDT_TIMEOUT);
84+
TORCH_SDT(queue_read_end, name, (void*)this, SDT_TIMEOUT);
8585
} else {
86-
CAFFE_SDT(queue_read_end, name, (void*)this, SDT_CANCEL);
86+
TORCH_SDT(queue_read_end, name, (void*)this, SDT_CANCEL);
8787
}
8888
return false;
8989
}
@@ -96,7 +96,7 @@ bool BlobsQueue::blockingRead(
9696
using std::swap;
9797
swap(*(inputs[i]), *(result[i]));
9898
}
99-
CAFFE_SDT(queue_read_end, name, (void*)this, writer_ - reader_);
99+
TORCH_SDT(queue_read_end, name, (void*)this, writer_ - reader_);
100100
CAFFE_EVENT(stats_, queue_dequeued_records);
101101
++reader_;
102102
cv_.notify_all();
@@ -108,10 +108,10 @@ bool BlobsQueue::tryWrite(const std::vector<Blob*>& inputs) {
108108
Timer writeTimer;
109109
auto keeper = this->shared_from_this();
110110
C10_UNUSED const auto& name = name_.c_str();
111-
CAFFE_SDT(queue_write_start, name, (void*)this, SDT_NONBLOCKING_OP);
111+
TORCH_SDT(queue_write_start, name, (void*)this, SDT_NONBLOCKING_OP);
112112
std::unique_lock<std::mutex> g(mutex_);
113113
if (!canWrite()) {
114-
CAFFE_SDT(queue_write_end, name, (void*)this, SDT_ABORT);
114+
TORCH_SDT(queue_write_end, name, (void*)this, SDT_ABORT);
115115
return false;
116116
}
117117
// Increase queue balance before writing to indicate queue write pressure is
@@ -127,14 +127,14 @@ bool BlobsQueue::blockingWrite(const std::vector<Blob*>& inputs) {
127127
Timer writeTimer;
128128
auto keeper = this->shared_from_this();
129129
C10_UNUSED const auto& name = name_.c_str();
130-
CAFFE_SDT(queue_write_start, name, (void*)this, SDT_BLOCKING_OP);
130+
TORCH_SDT(queue_write_start, name, (void*)this, SDT_BLOCKING_OP);
131131
std::unique_lock<std::mutex> g(mutex_);
132132
// Increase queue balance before writing to indicate queue write pressure is
133133
// being increased (+ve queue balance indicates more writes than reads)
134134
CAFFE_EVENT(stats_, queue_balance, 1);
135135
cv_.wait(g, [this]() { return closing_ || canWrite(); });
136136
if (!canWrite()) {
137-
CAFFE_SDT(queue_write_end, name, (void*)this, SDT_ABORT);
137+
TORCH_SDT(queue_write_end, name, (void*)this, SDT_ABORT);
138138
return false;
139139
}
140140
DCHECK(canWrite());
@@ -167,7 +167,7 @@ void BlobsQueue::doWrite(const std::vector<Blob*>& inputs) {
167167
using std::swap;
168168
swap(*(inputs[i]), *(result[i]));
169169
}
170-
CAFFE_SDT(
170+
TORCH_SDT(
171171
queue_write_end, name, (void*)this, reader_ + queue_.size() - writer_);
172172
++writer_;
173173
cv_.notify_all();

0 commit comments

Comments
 (0)