Skip to content

Commit fb36cce

Browse files
zejun-chenfacebook-github-bot
authored andcommitted
introduce new interface to kineto for PTI-0.11 and PTI-0.12 (#1066)
Summary: This PR is used to change the interface for XPTI in kineto to be compatible with the PTI 0.11 release Pull Request resolved: #1066 Reviewed By: davidberard98 Differential Revision: D73046750 Pulled By: sraikund16 fbshipit-source-id: f7b669e70d1492f327badfe04094b93cb6633612
1 parent d82680b commit fb36cce

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

libkineto/src/plugin/xpupti/XpuptiActivityApi.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
19
#include "XpuptiActivityApi.h"
210

311
#include <assert.h>
@@ -170,6 +178,43 @@ void XpuptiActivityApi::bufferCompleted(
170178
}
171179
#endif
172180

181+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
182+
static void enableSpecifcRuntimeAPIsTracing() {
183+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
184+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueUSMFill_id));
185+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
186+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueUSMFill2D_id));
187+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
188+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueUSMMemcpy_id));
189+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
190+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueUSMMemcpy2D_id));
191+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
192+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueKernelLaunch_id));
193+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
194+
1,
195+
pti_api_group_id::PTI_API_GROUP_SYCL,
196+
urEnqueueKernelLaunchCustomExp_id));
197+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
198+
1,
199+
pti_api_group_id::PTI_API_GROUP_SYCL,
200+
urEnqueueCooperativeKernelLaunchExp_id));
201+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
202+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueMemBufferFill_id));
203+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
204+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueMemBufferRead_id));
205+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
206+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueMemBufferWrite_id));
207+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
208+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urEnqueueMemBufferCopy_id));
209+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
210+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urUSMHostAlloc_id));
211+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
212+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urUSMSharedAlloc_id));
213+
XPUPTI_CALL(ptiViewEnableRuntimeApi(
214+
1, pti_api_group_id::PTI_API_GROUP_SYCL, urUSMDeviceAlloc_id));
215+
}
216+
#endif
217+
173218
void XpuptiActivityApi::enableXpuptiActivities(
174219
const std::set<ActivityType>& selected_activities) {
175220
#ifdef HAS_XPUPTI
@@ -192,7 +237,16 @@ void XpuptiActivityApi::enableXpuptiActivities(
192237
externalCorrelationEnabled_ = true;
193238
}
194239
if (activity == ActivityType::XPU_RUNTIME) {
240+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 11
241+
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_RUNTIME_API));
242+
XPUPTI_CALL(ptiViewEnableRuntimeApiClass(
243+
1, PTI_API_CLASS_GPU_OPERATION_CORE, PTI_API_GROUP_ALL));
244+
#elif PTI_VERSION_MAJOR == 0 && PTI_VERSION_MINOR == 11
245+
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_RUNTIME_API));
246+
enableSpecifcRuntimeAPIsTracing();
247+
#else
195248
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_SYCL_RUNTIME_CALLS));
249+
#endif
196250
}
197251
if (activity == ActivityType::OVERHEAD) {
198252
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_COLLECTION_OVERHEAD));
@@ -222,7 +276,12 @@ void XpuptiActivityApi::disablePtiActivities(
222276
XPUPTI_CALL(ptiViewDisable(PTI_VIEW_EXTERNAL_CORRELATION));
223277
}
224278
if (activity == ActivityType::XPU_RUNTIME) {
279+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
280+
XPUPTI_CALL(ptiViewDisable(PTI_VIEW_RUNTIME_API));
281+
#else
282+
225283
XPUPTI_CALL(ptiViewDisable(PTI_VIEW_SYCL_RUNTIME_CALLS));
284+
#endif
226285
}
227286
if (activity == ActivityType::OVERHEAD) {
228287
XPUPTI_CALL(ptiViewDisable(PTI_VIEW_COLLECTION_OVERHEAD));

libkineto/src/plugin/xpupti/XpuptiActivityHandlers.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,29 @@ inline void XpuptiActivityProfilerSession::handleCorrelationActivity(
9898
}
9999

100100
void XpuptiActivityProfilerSession::handleRuntimeActivity(
101+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
102+
const pti_view_record_api* activity,
103+
#else
101104
const pti_view_record_sycl_runtime* activity,
105+
#endif
102106
ActivityLogger* logger) {
103107
traceBuffer_.span.opCount += 1;
104108
traceBuffer_.gpuOpCount += 1;
105109
const ITraceActivity* linked =
106110
linkedActivity(activity->_correlation_id, cpuCorrelationMap_);
111+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
112+
const char* api_name = nullptr;
113+
XPUPTI_CALL(
114+
ptiViewGetApiIdName(activity->_api_group, activity->_api_id, &api_name));
115+
#endif
107116
traceBuffer_.emplace_activity(
108117
traceBuffer_.span,
109118
ActivityType::XPU_RUNTIME,
119+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
120+
std::string(api_name));
121+
#else
110122
std::string(activity->_name));
123+
#endif
111124
auto& runtime_activity = traceBuffer_.activities.back();
112125
runtime_activity->startTime = activity->_start_timestamp;
113126
runtime_activity->endTime = activity->_end_timestamp;
@@ -331,9 +344,15 @@ void XpuptiActivityProfilerSession::handlePtiActivity(
331344
reinterpret_cast<const pti_view_record_external_correlation*>(
332345
record));
333346
break;
347+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
348+
case PTI_VIEW_RUNTIME_API:
349+
handleRuntimeActivity(
350+
reinterpret_cast<const pti_view_record_api*>(record),
351+
#else
334352
case PTI_VIEW_SYCL_RUNTIME_CALLS:
335353
handleRuntimeActivity(
336354
reinterpret_cast<const pti_view_record_sycl_runtime*>(record),
355+
#endif
337356
logger);
338357
break;
339358
case PTI_VIEW_DEVICE_GPU_KERNEL:

libkineto/src/plugin/xpupti/XpuptiActivityProfiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ class XpuptiActivityProfilerSession
5252
void handleCorrelationActivity(
5353
const pti_view_record_external_correlation* correlation);
5454
void handleRuntimeActivity(
55+
#if PTI_VERSION_MAJOR > 0 || PTI_VERSION_MINOR > 10
56+
const pti_view_record_api* activity,
57+
#else
5558
const pti_view_record_sycl_runtime* activity,
59+
#endif
5660
ActivityLogger* logger);
5761
void handleKernelActivity(
5862
const pti_view_record_kernel* activity,

0 commit comments

Comments
 (0)