Skip to content

Commit

Permalink
[libkineto] Create a new port with the latest commit (#303)
Browse files Browse the repository at this point in the history
* [libkineto] create a new port

* pytorch/kineto@7a2a167
* patch for linux build

* [libkineto] use more later commit

* facebookincubator/dynolog@7570766

* pytorch/kineto@596126c
  • Loading branch information
luncliff authored Nov 24, 2024
1 parent 724c009 commit c1b1823
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
37 changes: 37 additions & 0 deletions ports/libkineto/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/libkineto/CMakeLists.txt b/libkineto/CMakeLists.txt
index 140ee68..bc4d540 100644
--- a/libkineto/CMakeLists.txt
+++ b/libkineto/CMakeLists.txt
@@ -52,6 +52,13 @@ if (NOT ROCM_SOURCE_DIR)
message(INFO " ROCM_SOURCE_DIR = ${ROCM_SOURCE_DIR}")
endif()

+if(NOT LIBKINETO_NOCUPTI)
+ find_package(CUDAToolkit REQUIRED)
+ math(EXPR CUDA_VERSION "${CUDAToolkit_VERSION_MAJOR}000 + ${CUDAToolkit_VERSION_MINOR}0" OUTPUT_FORMAT DECIMAL)
+ add_compile_definitions(CUDA_VERSION=${CUDA_VERSION})
+ get_target_property(CUPTI_INCLUDE_DIR CUDA::cupti INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(CUDA_cupti_LIBRARY CUDA::cupti IMPORTED_LOCATION)
+endif()
if (KINETO_BUILD_TESTS)
enable_testing()
if (NOT CUDA_SOURCE_DIR)
@@ -193,7 +200,8 @@ endif()
target_compile_options(kineto_base PRIVATE "${KINETO_COMPILE_OPTIONS}")
target_compile_options(kineto_api PRIVATE "${KINETO_COMPILE_OPTIONS}")

-if(NOT TARGET fmt)
+find_package(fmt CONFIG REQUIRED)
+if(FALSE)
if(NOT FMT_SOURCE_DIR)
set(FMT_SOURCE_DIR "${LIBKINETO_THIRDPARTY_DIR}/fmt"
CACHE STRING "fmt source directory from submodules")
@@ -211,7 +219,7 @@ if(NOT TARGET fmt)
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
endif()

-set(FMT_INCLUDE_DIR "${FMT_SOURCE_DIR}/include")
+find_path(FMT_INCLUDE_DIR NAMES "fmt/format.h" REQUIRED)
message(STATUS "Kineto: FMT_SOURCE_DIR = ${FMT_SOURCE_DIR}")
message(STATUS "Kineto: FMT_INCLUDE_DIR = ${FMT_INCLUDE_DIR}")
if (NOT CUPTI_INCLUDE_DIR)
31 changes: 31 additions & 0 deletions ports/libkineto/fix-sources.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/libkineto/src/CuptiCallbackApi.cpp b/libkineto/src/CuptiCallbackApi.cpp
index 9c8e0f4..e7e6226 100644
--- a/libkineto/src/CuptiCallbackApi.cpp
+++ b/libkineto/src/CuptiCallbackApi.cpp
@@ -100,10 +100,12 @@ void CuptiCallbackApi::__callback_switchboard(
if (cbInfo->callbackSite == CUPTI_API_EXIT) {
LOG(INFO) << " Calling cuptiFinalize in exit callsite";
// Teardown CUPTI calling cuptiFinalize()
+#ifdef HAS_CUPTI
CUPTI_CALL(cuptiUnsubscribe(subscriber_));
CUPTI_CALL(cuptiFinalize());
initSuccess_ = false;
subscriber_ = nullptr;
+#endif
CuptiActivityApi::singleton().teardownCupti_ = 0;
CuptiActivityApi::singleton().finalizeCond_.notify_all();
return;
diff --git a/libkineto/src/Logger.h b/libkineto/src/Logger.h
index 3b9caaf..5b33b87 100644
--- a/libkineto/src/Logger.h
+++ b/libkineto/src/Logger.h
@@ -47,6 +47,9 @@
// unset a predefined ERROR (windows)
#undef ERROR
#endif // _MSC_VER
+#ifdef __linux__
+using libkineto::ERROR;
+#endif

namespace KINETO_NAMESPACE {

44 changes: 44 additions & 0 deletions ports/libkineto/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pytorch/kineto
REF 596126cba98181ce4a88e06aa1d602b6afd966dd
SHA512 5f7916a914e78afba56d47c6589eccf7303a7bdf9a55fcbbeef8733f49e554bce00a4829fb50813736913433a35cdedcccd942c79b1ebb9cae6c76693aae6648
HEAD_REF main
PATCHES
fix-cmake.patch
fix-sources.patch
)

vcpkg_from_github(
OUT_SOURCE_PATH DYNOLOG_SOURCE_PATH
REPO facebookincubator/dynolog
REF 7570766213484a926908c884888cfb701577a9cb # 2024-11-12
SHA512 548b51276dfc924ab513406810b90a19de7e0557bfc185cc6e1e285dbaefa685fb8664524c0a04b5802f87911e68e30db675cb1d6bbecc269b441c5972b9dea2
HEAD_REF main
)
file(REMOVE_RECURSE "${SOURCE_PATH}/libkineto/third_party/dynolog")
file(RENAME "${DYNOLOG_SOURCE_PATH}" "${SOURCE_PATH}/libkineto/third_party/dynolog")

vcpkg_find_acquire_program(PYTHON3)
message(STATUS "Using Python3: ${PYTHON3}")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/libkineto"
OPTIONS
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON3}
-DKINETO_BUILD_TESTS=OFF
-DLIBKINETO_NOCUPTI=ON # todo: support CUDA feature
-DLIBKINETO_NOROCTRACER=ON
-DLIBKINETO_NOXPUPTI=ON
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME kinetoLibrary CONFIG_PATH "share/cmake/kineto")

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
19 changes: 19 additions & 0 deletions ports/libkineto/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "libkineto",
"version-date": "2024-11-22",
"description": "A CPU+GPU Profiling library that provides access to timeline traces and hardware performance counters",
"homepage": "https://github.com/pytorch/kineto",
"license": "BSD-3-Clause",
"dependencies": [
"fmt",
"glog",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
"baseline": "5.10.1",
"port-version": 0
},
"libkineto": {
"baseline": "2024-11-22",
"port-version": 0
},
"liblzma": {
"baseline": "5.6.2",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/libkineto.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "b058e6125b7c3e64ccd0b45e726f668b7f39d002",
"version-date": "2024-11-22",
"port-version": 0
}
]
}

0 comments on commit c1b1823

Please sign in to comment.