Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "libkineto/third_party/googletest"]
path = libkineto/third_party/googletest
url = https://github.com/google/googletest.git
[submodule "libkineto/third_party/fmt"]
path = libkineto/third_party/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "libkineto/third_party/dynolog"]
path = libkineto/third_party/dynolog
url = https://github.com/facebookincubator/dynolog.git
5 changes: 1 addition & 4 deletions libkineto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,10 @@ if (NOT ROCM_INCLUDE_DIRS)
set(ROCM_INCLUDE_DIRS "${ROCM_SOURCE_DIR}/include")
endif()

set(DYNOLOG_INCLUDE_DIR "${LIBKINETO_THIRDPARTY_DIR}/dynolog/")
set(IPCFABRIC_INCLUDE_DIR "${DYNOLOG_INCLUDE_DIR}/dynolog/src/ipcfabric/")
set(IPCFABRIC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ipcfabric/")

message(INFO " CUPTI_INCLUDE_DIR = ${CUPTI_INCLUDE_DIR}")
message(INFO " ROCTRACER_INCLUDE_DIR = ${ROCTRACER_INCLUDE_DIR}")
message(INFO " DYNOLOG_INCLUDE_DIR = ${DYNOLOG_INCLUDE_DIR}")
message(INFO " IPCFABRIC_INCLUDE_DIR = ${IPCFABRIC_INCLUDE_DIR}")

add_subdirectory("${IPCFABRIC_INCLUDE_DIR}")
Expand All @@ -185,7 +183,6 @@ target_link_libraries(kineto_base PRIVATE dynolog_ipcfabric_lib)
target_include_directories(kineto_base PUBLIC
$<BUILD_INTERFACE:${LIBKINETO_INCLUDE_DIR}>
$<BUILD_INTERFACE:${LIBKINETO_SOURCE_DIR}>
$<BUILD_INTERFACE:${DYNOLOG_INCLUDE_DIR}>
$<BUILD_INTERFACE:${FMT_INCLUDE_DIR}>
$<BUILD_INTERFACE:${IPCFABRIC_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CUPTI_INCLUDE_DIR}>
Expand Down
30 changes: 30 additions & 0 deletions libkineto/include/ActivityType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace libkineto {

// Note : All activity types are not enabled by default. Please add them
// at correct position in the enum
#if DIPU_TORCH_VERSION == 20000
enum class ActivityType {
// Activity types enabled by default
CPU_OP = 0, // cpu side ops
Expand All @@ -37,6 +38,35 @@ enum class ActivityType {
ENUM_COUNT, // This is to add buffer and not used for any profiling logic. Add your new type before it.
OPTIONAL_ACTIVITY_TYPE_START = GLOW_RUNTIME,
};
#else
enum class ActivityType {
// Activity types enabled by default
CPU_OP = 0, // cpu side ops
USER_ANNOTATION,
GPU_USER_ANNOTATION,
GPU_MEMCPY,
GPU_MEMSET,
CONCURRENT_KERNEL, // on-device kernels
EXTERNAL_CORRELATION,
CUDA_RUNTIME, // host side cuda runtime events
CUDA_DRIVER, // host side cuda driver events
CPU_INSTANT_EVENT, // host side point-like events
PYTHON_FUNCTION,
OVERHEAD, // CUPTI induced overhead events sampled from its overhead API.

// Optional Activity types
CUDA_SYNC, // synchronization events between runtime and kernels
GLOW_RUNTIME, // host side glow runtime events
MTIA_RUNTIME, // host side MTIA runtime events
CUDA_PROFILER_RANGE, // CUPTI Profiler range for performance metrics
MTIA_CCP_EVENTS, // MTIA ondevice CCP events
HPU_OP, // HPU host side runtime event
XPU_RUNTIME, // host side xpu runtime events

ENUM_COUNT, // This is to add buffer and not used for any profiling logic. Add your new type before it.
OPTIONAL_ACTIVITY_TYPE_START = CUDA_SYNC,
};
#endif

const char* toString(ActivityType t);
ActivityType toActivityType(const std::string& str);
Expand Down
3 changes: 3 additions & 0 deletions libkineto/include/DeviceActivityInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class DeviceActivityInterface {
virtual void enableActivities(const std::set<ActivityType>& selectedActivities) = 0;
virtual void disableActivities(const std::set<ActivityType>& selectedActivities) = 0;
virtual void clearActivities() = 0;

virtual void startTrace(const std::set<ActivityType>& selectedActivities) = 0;
virtual void stopTrace(const std::set<ActivityType>& selectedActivities) = 0;
virtual void teardownContext() = 0;
virtual void setMaxBufferSize(int32_t size) = 0;

Expand Down
25 changes: 25 additions & 0 deletions libkineto/src/ActivityType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct ActivityTypeName {
ActivityType type;
};

#if DIPU_TORCH_VERSION == 20000
static constexpr std::array<ActivityTypeName, activityTypeCount + 1> map{{
{"cpu_op", ActivityType::CPU_OP},
{"user_annotation", ActivityType::USER_ANNOTATION},
Expand All @@ -34,6 +35,30 @@ static constexpr std::array<ActivityTypeName, activityTypeCount + 1> map{{
{"hpu_op", ActivityType::HPU_OP},
{"ENUM_COUNT", ActivityType::ENUM_COUNT}
}};
#else
static constexpr std::array<ActivityTypeName, activityTypeCount + 1> map{{
{"cpu_op", ActivityType::CPU_OP},
{"user_annotation", ActivityType::USER_ANNOTATION},
{"gpu_user_annotation", ActivityType::GPU_USER_ANNOTATION},
{"gpu_memcpy", ActivityType::GPU_MEMCPY},
{"gpu_memset", ActivityType::GPU_MEMSET},
{"kernel", ActivityType::CONCURRENT_KERNEL},
{"external_correlation", ActivityType::EXTERNAL_CORRELATION},
{"cuda_runtime", ActivityType::CUDA_RUNTIME},
{"cuda_driver", ActivityType::CUDA_DRIVER},
{"cpu_instant_event", ActivityType::CPU_INSTANT_EVENT},
{"python_function", ActivityType::PYTHON_FUNCTION},
{"overhead", ActivityType::OVERHEAD},
{"cuda_sync", ActivityType::CUDA_SYNC},
{"glow_runtime", ActivityType::GLOW_RUNTIME},
{"mtia_runtime", ActivityType::MTIA_RUNTIME},
{"cuda_profiler_range", ActivityType::CUDA_PROFILER_RANGE},
{"mtia_ccp_events", ActivityType::MTIA_CCP_EVENTS},
{"hpu_op", ActivityType::HPU_OP},
{"xpu_runtime", ActivityType::XPU_RUNTIME},
{"ENUM_COUNT", ActivityType::ENUM_COUNT}
}};
#endif

static constexpr bool matchingOrder(int idx = 0) {
return map[idx].type == ActivityType::ENUM_COUNT ||
Expand Down
7 changes: 7 additions & 0 deletions libkineto/src/CuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ void CuptiActivityProfiler::startTraceInternal(
session->start();
}
currentRunloopState_ = RunloopState::CollectTrace;

#ifdef HAS_DEVICE_ACTIVITY
cupti_.startTrace(derivedConfig_->profileActivityTypes());
#endif
}

void CuptiActivityProfiler::stopTraceInternal(
Expand All @@ -716,6 +720,9 @@ void CuptiActivityProfiler::stopTraceInternal(
cupti_.disableCuptiActivities(derivedConfig_->profileActivityTypes());
#else
cupti_.disableActivities(derivedConfig_->profileActivityTypes());
#endif
#ifdef HAS_DEVICE_ACTIVITY
cupti_.stopTrace(derivedConfig_->profileActivityTypes());
#endif
if (VLOG_IS_ON(1)) {
auto t2 = system_clock::now();
Expand Down
1 change: 0 additions & 1 deletion libkineto/third_party/dynolog
Submodule dynolog deleted from 7d04a0
1 change: 0 additions & 1 deletion libkineto/third_party/googletest
Submodule googletest deleted from 7aca84