@@ -80,28 +80,56 @@ if(USE_CUDA AND TARGET CUDA::nvperf_host)
8080 message (STATUS "Found NVPERF: Using built-in FindCUDAToolkit target" )
8181endif ()
8282
83- if (NOT ROCM_SOURCE_DIR AND NOT ROCTRACER_INCLUDE_DIR)
84- set (LIBKINETO_NOROCTRACER ON CACHE BOOL "" FORCE)
83+ # Set USE_ROCTRACER to explicitly enable ROCTracer (AMD GPU) support
84+ option (USE_ROCTRACER "Enable ROCTracer support" OFF )
85+
86+ # Backwards compatibility: if LIBKINETO_NOROCTRACER is set, map it to USE_ROCTRACER
87+ if (DEFINED LIBKINETO_NOROCTRACER)
88+ if (LIBKINETO_NOROCTRACER)
89+ set (USE_ROCTRACER OFF CACHE BOOL "Enable ROCTracer support" FORCE)
90+ message (WARNING "LIBKINETO_NOROCTRACER is deprecated. Use USE_ROCTRACER=OFF instead." )
91+ else ()
92+ set (USE_ROCTRACER ON CACHE BOOL "Enable ROCTracer support" FORCE)
93+ message (WARNING "LIBKINETO_NOROCTRACER is deprecated. Use USE_ROCTRACER=ON instead." )
94+ endif ()
95+ endif ()
96+
97+ # Auto-disable ROCTracer if ROCm is not found
98+ if (USE_ROCTRACER AND NOT ROCM_SOURCE_DIR AND NOT ROCTRACER_INCLUDE_DIR)
99+ set (USE_ROCTRACER OFF CACHE BOOL "" FORCE)
100+ message (STATUS "ROCm not found - disabling ROCTracer support" )
101+ endif ()
102+
103+ # Set USE_XPUPTI to explicitly enable XPUPTI (Intel XPU) support
104+ option (USE_XPUPTI "Enable XPUPTI support" OFF )
105+
106+ # Backwards compatibility: if LIBKINETO_NOXPUPTI is set, map it to USE_XPUPTI
107+ if (DEFINED LIBKINETO_NOXPUPTI)
108+ if (LIBKINETO_NOXPUPTI)
109+ set (USE_XPUPTI OFF CACHE BOOL "Enable XPUPTI support" FORCE)
110+ message (WARNING "LIBKINETO_NOXPUPTI is deprecated. Use USE_XPUPTI=OFF instead." )
111+ else ()
112+ set (USE_XPUPTI ON CACHE BOOL "Enable XPUPTI support" FORCE)
113+ message (WARNING "LIBKINETO_NOXPUPTI is deprecated. Use USE_XPUPTI=ON instead." )
114+ endif ()
85115endif ()
86116
87- if (DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI )
117+ if (USE_XPUPTI )
88118 add_subdirectory (src/plugin/xpupti)
89- else ()
90- set (LIBKINETO_NOXPUPTI ON )
91119endif ()
92120
93121# Define file lists
94- if (NOT USE_CUDA AND LIBKINETO_NOROCTRACER AND LIBKINETO_NOXPUPTI )
122+ if (NOT USE_CUDA AND NOT USE_ROCTRACER AND NOT USE_XPUPTI )
95123 get_filelist("get_libkineto_cpu_only_srcs(with_api=False)" LIBKINETO_SRCS)
96124 message (STATUS " CUPTI unavailable or disabled - not building GPU profilers" )
97125else ()
98- if (NOT LIBKINETO_NOROCTRACER )
126+ if (USE_ROCTRACER )
99127 get_filelist("get_libkineto_roctracer_srcs(with_api=False)" LIBKINETO_roc_SRCS)
100128 message (STATUS " Building with roctracer" )
101129 elseif (USE_CUDA)
102130 get_filelist("get_libkineto_cupti_srcs(with_api=False)" LIBKINETO_cuda_SRCS)
103131 endif ()
104- if (DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI )
132+ if (USE_XPUPTI )
105133 get_filelist("get_libkineto_xpupti_srcs(with_api=False)" LIBKINETO_xpu_SRCS)
106134 message (STATUS " Building with xpupti" )
107135 endif ()
@@ -126,7 +154,7 @@ endif()
126154if (USE_CUDA)
127155 list (APPEND KINETO_DEFINITIONS "HAS_CUPTI" )
128156endif ()
129- if (DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI )
157+ if (USE_XPUPTI )
130158 list (APPEND KINETO_COMPILE_OPTIONS ${XPUPTI_BUILD_FLAG} )
131159endif ()
132160if (USE_CUDA AND TARGET CUDA::nvperf_host)
@@ -136,7 +164,7 @@ if(USE_CUDA AND TARGET CUDA::nvperf_host)
136164 endif ()
137165endif ()
138166
139- if (NOT LIBKINETO_NOROCTRACER )
167+ if (USE_ROCTRACER )
140168 list (APPEND KINETO_DEFINITIONS "HAS_ROCTRACER" )
141169 target_compile_definitions (kineto_base PRIVATE "__HIP_PLATFORM_HCC__" )
142170 target_compile_definitions (kineto_base PRIVATE "__HIP_PLATFORM_AMD__" )
@@ -187,7 +215,7 @@ target_include_directories(kineto_base PUBLIC
187215 $<BUILD_INTERFACE:${ROCTRACER_INCLUDE_DIR} >
188216 $<BUILD_INTERFACE:${ROCM_INCLUDE_DIRS} >)
189217
190- if (DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI )
218+ if (USE_XPUPTI )
191219 target_include_directories (kineto_base PUBLIC ${XPUPTI_INCLUDE_DIR} )
192220endif ()
193221target_link_libraries (kineto_base PRIVATE $<BUILD_INTERFACE:fmt::fmt-header-only>)
@@ -222,7 +250,7 @@ target_include_directories(kineto PUBLIC
222250 $<BUILD_INTERFACE:${LIBKINETO_INCLUDE_DIR} >
223251 $<BUILD_INTERFACE:${LIBKINETO_SOURCE_DIR} >)
224252
225- if (NOT LIBKINETO_NOROCTRACER )
253+ if (USE_ROCTRACER )
226254 find_library (ROCTRACER_LIBRARY NAMES libroctracer64.so HINTS
227255 ${ROCM_SOURCE_DIR} /lib)
228256 target_link_libraries (kineto "${ROCTRACER_LIBRARY} " )
@@ -238,7 +266,7 @@ endif()
238266if (USE_CUDA AND TARGET CUDA::nvperf_host)
239267 target_link_libraries (kineto_base PUBLIC CUDA::nvperf_host)
240268endif ()
241- if (DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI )
269+ if (USE_XPUPTI )
242270 target_link_libraries (kineto "${XPU_xpupti_LIBRARY} " )
243271endif ()
244272target_compile_definitions (kineto PUBLIC "${KINETO_DEFINITIONS} " )
0 commit comments