Skip to content

Commit ba8f2b7

Browse files
q10facebook-github-bot
authored andcommitted
Migrate SourceContext macros to source_context.h (#4392)
Summary: X-link: facebookresearch/FBGEMM#1463 Pull Request resolved: #4392 - Migrate SourceContext macros to source_context.h Reviewed By: r-barnes Differential Revision: D77118718 fbshipit-source-id: 6d39b1da4fa6cf686c9cd30bf8a99d4fdd69dc53
1 parent 1663528 commit ba8f2b7

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

fbgemm_gpu/include/fbgemm_gpu/utils/kernel_launcher.cuh

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -394,34 +394,6 @@ struct KernelLauncher {
394394

395395
} // namespace fbgemm_gpu::utils
396396

397-
////////////////////////////////////////////////////////////////////////////////
398-
// Macro to create a compile-time concatenation of __TEMPLATE_SOURCE_FILE__ and
399-
// __FILE__
400-
//
401-
// This is used for reporting the template filename into to Torch DSA. Runtime
402-
// strings cannot be used here because the Torch DSA error reporting mechanism
403-
// is located higher in the stack than where the DSA launch_registry.insert() is
404-
// called, and requires a compile-timme defined char * for the reporting to work
405-
// correctly.
406-
////////////////////////////////////////////////////////////////////////////////
407-
408-
#ifdef __TEMPLATE_SOURCE_FILE__
409-
#define DSA_FILESRC_IMPL "[" __TEMPLATE_SOURCE_FILE__ "] " __FILE__
410-
#else
411-
#define DSA_FILESRC_IMPL __FILE__
412-
#endif
413-
414-
////////////////////////////////////////////////////////////////////////////////
415-
// Macro to define _FKL_TFILE_ to be __TEMPLATE_SOURCE_FILE__ if it is defined,
416-
// else empty string
417-
////////////////////////////////////////////////////////////////////////////////
418-
419-
#ifdef __TEMPLATE_SOURCE_FILE__
420-
#define _FKL_TFILE_ __TEMPLATE_SOURCE_FILE__
421-
#else
422-
#define _FKL_TFILE_ ""
423-
#endif
424-
425397
////////////////////////////////////////////////////////////////////////////////
426398
// Enable Kernel Barrier Isolation
427399
//
@@ -453,25 +425,6 @@ struct KernelLauncher {
453425
#define _FKL_TENSORCHECK_ false
454426
#endif
455427

456-
////////////////////////////////////////////////////////////////////////////////
457-
// SourceContext Builder Macro
458-
//
459-
// This macro is used to build a SourceContext object for the kernel launcher,
460-
// can be used elsewhere as well.
461-
//
462-
// NOTE: The builder is defined as a macro in specifically in this header file ,
463-
// instead of static class method in source_context.h, so that __FILE__ and
464-
// __TEMPLATE_SOURCE_FILE__ can be correctly expanded to point to actual call
465-
// site.
466-
////////////////////////////////////////////////////////////////////////////////
467-
468-
#define SOURCE_CONTEXT_CURRENT(KERNEL) \
469-
fbgemm_gpu::utils::SourceContext( \
470-
fbgemm_gpu::utils::source_location::current(), \
471-
#KERNEL, \
472-
_FKL_TFILE_, \
473-
DSA_FILESRC_IMPL);
474-
475428
////////////////////////////////////////////////////////////////////////////////
476429
// Kernel Launcher Macros for FBGEMM GPU Kernels
477430
//

fbgemm_gpu/include/fbgemm_gpu/utils/source_context.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,50 @@ struct SourceContext {
9494
};
9595

9696
} // namespace fbgemm_gpu::utils
97+
98+
////////////////////////////////////////////////////////////////////////////////
99+
// Macro create a compile-time concatenation of __TEMPLATE_SOURCE_FILE__ and
100+
// __FILE__
101+
//
102+
// This is used for reporting the template filename into to Torch DSA. Runtime
103+
// strings cannot be used here because the Torch DSA error reporting mechanism
104+
// is located higher in the stack than where the DSA launch_registry.insert() is
105+
// called, and requires a compile-timme defined char * for the reporting to work
106+
// correctly.
107+
////////////////////////////////////////////////////////////////////////////////
108+
109+
#ifdef __TEMPLATE_SOURCE_FILE__
110+
#define _FBGEMM_DSA_FILESRC_ "[" __TEMPLATE_SOURCE_FILE__ "] " __FILE__
111+
#else
112+
#define _FBGEMM_DSA_FILESRC_ __FILE__
113+
#endif
114+
115+
////////////////////////////////////////////////////////////////////////////////
116+
// Macro to define _FKL_TFILE_ to be __TEMPLATE_SOURCE_FILE__ if it is defined,
117+
// else empty string
118+
////////////////////////////////////////////////////////////////////////////////
119+
120+
#ifdef __TEMPLATE_SOURCE_FILE__
121+
#define _FBGEMM_TFILE_ __TEMPLATE_SOURCE_FILE__
122+
#else
123+
#define _FBGEMM_TFILE_ ""
124+
#endif
125+
126+
////////////////////////////////////////////////////////////////////////////////
127+
// SourceContext Builder Macro
128+
//
129+
// This macro is used to build a SourceContext object for the kernel launcher,
130+
// can be used elsewhere as well.
131+
//
132+
// NOTE: The builder is defined as a macro in specifically in this header file ,
133+
// instead of static class method in source_context.h, so that __FILE__ and
134+
// __TEMPLATE_SOURCE_FILE__ can be correctly expanded to point to actual call
135+
// site.
136+
////////////////////////////////////////////////////////////////////////////////
137+
138+
#define SOURCE_CONTEXT_CURRENT(LABEL) \
139+
fbgemm_gpu::utils::SourceContext( \
140+
fbgemm_gpu::utils::source_location::current(), \
141+
#LABEL, \
142+
_FBGEMM_TFILE_, \
143+
_FBGEMM_DSA_FILESRC_);

0 commit comments

Comments
 (0)