mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Summary: Some jobs in the next diff in stack (D48229150) fail with the following message: ``` stderr: In file included from xplat/caffe2/c10/cuda/CUDACachingAllocator.cpp:9: xplat/caffe2/c10/util/static_tracepoint.h:4:6: error: 'TORCH_DISABLE_SDT' is not defined, evaluates to 0 [-Werror,-Wundef] !TORCH_DISABLE_SDT ``` When porting USDT macros to PyTorch in D47159249, I must have not hit a codepath which treated warnings as errors during testing. This diff fixes the issue by first checking whether the `TORCH_DISABLE_SDT` macro is defined before trying to access it in the `static_tracepoint.h` header. Test Plan: Similar to D47159249, tested the following macro on test scripts with `libbpf` USDTs: * `CAFFE_DISABLE_SDT` Reviewed By: chaekit Differential Revision: D48251736 Pull Request resolved: https://github.com/pytorch/pytorch/pull/107149 Approved by: https://github.com/chaekit
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
#pragma once
|
|
|
|
#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) && \
|
|
!(defined(TORCH_DISABLE_SDT) && TORCH_DISABLE_SDT)
|
|
|
|
#define TORCH_HAVE_SDT 1
|
|
|
|
#include <c10/util/static_tracepoint_elfx86.h>
|
|
|
|
#define TORCH_SDT(name, ...) \
|
|
TORCH_SDT_PROBE_N( \
|
|
pytorch, name, 0, TORCH_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
|
|
// Use TORCH_SDT_DEFINE_SEMAPHORE(name) to define the semaphore
|
|
// as global variable before using the TORCH_SDT_WITH_SEMAPHORE macro
|
|
#define TORCH_SDT_WITH_SEMAPHORE(name, ...) \
|
|
TORCH_SDT_PROBE_N( \
|
|
pytorch, name, 1, TORCH_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
|
|
#define TORCH_SDT_IS_ENABLED(name) (TORCH_SDT_SEMAPHORE(pytorch, name) > 0)
|
|
|
|
#else
|
|
|
|
#define TORCH_HAVE_SDT 0
|
|
|
|
#define TORCH_SDT(name, ...) \
|
|
do { \
|
|
} while (0)
|
|
#define TORCH_SDT_WITH_SEMAPHORE(name, ...) \
|
|
do { \
|
|
} while (0)
|
|
#define TORCH_SDT_IS_ENABLED(name) (false)
|
|
#define TORCH_SDT_DEFINE_SEMAPHORE(name)
|
|
#define TORCH_SDT_DECLARE_SEMAPHORE(name)
|
|
|
|
#endif
|