diff --git a/.gitmodules b/.gitmodules index c50e12249..9a6938cc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/libkineto/CMakeLists.txt b/libkineto/CMakeLists.txt index 5f181d858..163c91f2c 100644 --- a/libkineto/CMakeLists.txt +++ b/libkineto/CMakeLists.txt @@ -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}") @@ -185,7 +183,6 @@ target_link_libraries(kineto_base PRIVATE dynolog_ipcfabric_lib) target_include_directories(kineto_base PUBLIC $ $ - $ $ $ $ diff --git a/libkineto/include/ActivityType.h b/libkineto/include/ActivityType.h index 588e47abe..0db5a4dd0 100644 --- a/libkineto/include/ActivityType.h +++ b/libkineto/include/ActivityType.h @@ -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 @@ -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); diff --git a/libkineto/include/DeviceActivityInterface.h b/libkineto/include/DeviceActivityInterface.h index 52cdf4c23..cf8078246 100644 --- a/libkineto/include/DeviceActivityInterface.h +++ b/libkineto/include/DeviceActivityInterface.h @@ -28,6 +28,9 @@ class DeviceActivityInterface { virtual void enableActivities(const std::set& selectedActivities) = 0; virtual void disableActivities(const std::set& selectedActivities) = 0; virtual void clearActivities() = 0; + + virtual void startTrace(const std::set& selectedActivities) = 0; + virtual void stopTrace(const std::set& selectedActivities) = 0; virtual void teardownContext() = 0; virtual void setMaxBufferSize(int32_t size) = 0; diff --git a/libkineto/src/ActivityType.cpp b/libkineto/src/ActivityType.cpp index 2685ba2f9..a5be2a744 100644 --- a/libkineto/src/ActivityType.cpp +++ b/libkineto/src/ActivityType.cpp @@ -17,6 +17,7 @@ struct ActivityTypeName { ActivityType type; }; +#if DIPU_TORCH_VERSION == 20000 static constexpr std::array map{{ {"cpu_op", ActivityType::CPU_OP}, {"user_annotation", ActivityType::USER_ANNOTATION}, @@ -34,6 +35,30 @@ static constexpr std::array map{{ {"hpu_op", ActivityType::HPU_OP}, {"ENUM_COUNT", ActivityType::ENUM_COUNT} }}; +#else +static constexpr std::array 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 || diff --git a/libkineto/src/CuptiActivityProfiler.cpp b/libkineto/src/CuptiActivityProfiler.cpp index fefc0ae59..8fe512609 100644 --- a/libkineto/src/CuptiActivityProfiler.cpp +++ b/libkineto/src/CuptiActivityProfiler.cpp @@ -701,6 +701,10 @@ void CuptiActivityProfiler::startTraceInternal( session->start(); } currentRunloopState_ = RunloopState::CollectTrace; + +#ifdef HAS_DEVICE_ACTIVITY + cupti_.startTrace(derivedConfig_->profileActivityTypes()); +#endif } void CuptiActivityProfiler::stopTraceInternal( @@ -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(); diff --git a/libkineto/third_party/dynolog b/libkineto/third_party/dynolog deleted file mode 160000 index 7d04a0053..000000000 --- a/libkineto/third_party/dynolog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7d04a0053a845370ae06ce317a22a48e9edcc74e diff --git a/libkineto/third_party/googletest b/libkineto/third_party/googletest deleted file mode 160000 index 7aca84427..000000000 --- a/libkineto/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7aca84427f224eeed3144123d5230d5871e93347