Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ada4008
Put HeartbeatMonitor in a detail namespace (#143)
bertmaher Mar 29, 2021
fda47c7
Fix C++14 compile error (#144)
gdankel Mar 30, 2021
d3e80cd
add JSON-formatted metadata for ClientTraceActivity (#164)
chaekit Apr 14, 2021
b0872a0
deprecate metdata args from ClientTraceActivity (#55988)
chaekit Apr 15, 2021
3cf5ebf
deprecate pthreadid (#56209)
chaekit Apr 16, 2021
753d0d3
Fix empty metadata invalid json (#173)
Apr 17, 2021
b4e71c3
Fix OSS compilation error (#176)
Apr 20, 2021
5bc9386
Support for trace metadata (#192)
Apr 28, 2021
f60aa9d
Fix TraceActivity forward declaration (#199)
malfet Apr 29, 2021
71ff16a
Deprecate ClientTraceActivity and merge it with GenericTraceActivity …
chaekit Apr 29, 2021
2caeb94
Expand Kineto profiler support (part 1) (#57333)
Apr 30, 2021
c8692f6
Refactor CuptiActivityBuffer
gdankel Apr 30, 2021
60a1313
Fix a couple of trace collection corner cases
gdankel Apr 30, 2021
2395f04
Minor refactoring of per-op metadata
gdankel Apr 30, 2021
0a5e486
Allow specifying CPU_OP as activity type via config
gdankel Apr 30, 2021
5431ed9
Shorten default warmup period
gdankel Apr 30, 2021
a409be7
Remove distinction between active and inactive profiler interval (#201)
gdankel Apr 30, 2021
07344e6
add 2 kernel metrics (#185)
gaoteng-git May 3, 2021
87c2a83
Fix empty metadata invalid json (#205)
May 5, 2021
f28e764
set the correct device id for GenericTraceActivity
chaekit May 6, 2021
de7cb43
Fix clock discrepancy (#207)
May 7, 2021
1dbf6e8
Support for memory allocs/deallocs in the traces (#57835)
May 8, 2021
d492d29
Rename theoretical occupancy to est. achieved occupancy (#210)
gdankel May 11, 2021
1e9a1a9
Log compute properties to trace file (#211)
gdankel May 12, 2021
582aefa
Kineto cmake fix (#216)
May 12, 2021
a631215
Call [Get|Set]ThreadDescription via runtime linking (#224)
malfet May 13, 2021
f0b2e2e
Get rid of tautological check (#225)
malfet May 13, 2021
3968183
Remove dependency on CuptiInterface from loggers
gdankel May 27, 2021
cbae600
Add support for multiple protocols in client API (#251)
gdankel May 27, 2021
61210aa
Invert ConfigLoader -> profiler dependency (#271)
gdankel Jun 3, 2021
5345cb1
Revert verbose logging
gdankel Jun 5, 2021
24d5620
Back out "Invert ConfigLoader -> profiler dependency"
Jun 5, 2021
6f9c0ee
Refactor trace activities (#59360)
gdankel Jun 8, 2021
34f66a6
add activity profiler plugin interface and test (#202)
Jun 9, 2021
897a49c
Do not leak file descriptors in processName() (#281)
malfet Jun 9, 2021
be239c0
Merge Plugin/0.2 (#284)
guyang3532 Jun 11, 2021
fc6a2c1
Read base config via daemon (#291)
gdankel Jun 15, 2021
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: 3 additions & 3 deletions .github/workflows/tb_plugin_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
branches:
- master
- release/**
- tb_plugin
- plugin/**

pull_request:
branches:
- master
- release/**
- tb_plugin
- plugin/**

jobs:
build:
Expand All @@ -37,6 +37,6 @@ jobs:
set -e
cd tb_plugin
sh ./ci_scripts/install_env.sh
pip install .
pip install .[gs]
cd test
pytest
37 changes: 25 additions & 12 deletions libkineto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ endif()

# Set LIBKINETO_NOCUPTI to explicitly disable CUPTI
# Otherwise, CUPTI is disabled if not found
IF (NOT CUDA_SOURCE_DIR AND NOT CUPTI_INCLUDE_DIR)
IF (NOT CUDA_SOURCE_DIR OR NOT CUPTI_INCLUDE_DIR OR NOT CUDA_cupti_LIBRARY)
set(LIBKINETO_NOCUPTI ON CACHE BOOL "" FORCE)
endif()

# Define file lists
if (LIBKINETO_NOCUPTI)
get_filelist("get_libkineto_cpu_only_srcs()" LIBKINETO_SRCS)
get_filelist("get_libkineto_cpu_only_srcs(with_api=False)" LIBKINETO_SRCS)
message(INFO " CUPTI unavailable or disabled - not building GPU profilers")
else()
get_filelist("get_libkineto_srcs()" LIBKINETO_SRCS)
get_filelist("get_libkineto_srcs(with_api=False)" LIBKINETO_SRCS)
endif()
get_filelist("get_libkineto_public_headers()" LIBKINETO_PUBLIC_HEADERS)
set(LIBKINETO_API_SRCS "${LIBKINETO_SOURCE_DIR}/libkineto_api.cpp")
get_filelist("get_libkineto_api_srcs()" LIBKINETO_API_SRCS)

add_library(kineto_base OBJECT ${LIBKINETO_SRCS})
add_library(kineto_api OBJECT ${LIBKINETO_API_SRCS})
Expand All @@ -69,13 +69,22 @@ set_target_properties(kineto_base kineto_api PROPERTIES
CXX_EXTENSIONS NO
CXX_VISIBILITY_PRESET hidden)

target_compile_options(kineto_base PRIVATE "-DKINETO_NAMESPACE=libkineto"
"-std=gnu++14")
target_compile_options(kineto_api PRIVATE "-std=gnu++14")
set(KINETO_COMPILE_OPTIONS "-DKINETO_NAMESPACE=libkineto")
list(APPEND KINETO_COMPILE_OPTIONS "-DFMT_HEADER_ONLY")
if(NOT MSVC)
list(APPEND KINETO_COMPILE_OPTIONS "-std=c++14")
else()
list(APPEND KINETO_COMPILE_OPTIONS "/std:c++14")
list(APPEND KINETO_COMPILE_OPTIONS "-DWIN32_LEAN_AND_MEAN")
list(APPEND KINETO_COMPILE_OPTIONS "-DNOGDI")
endif()
if (NOT LIBKINETO_NOCUPTI)
target_compile_options(kineto_base PRIVATE "-DHAS_CUPTI")
list(APPEND KINETO_COMPILE_OPTIONS "-DHAS_CUPTI")
endif()

target_compile_options(kineto_base PRIVATE "${KINETO_COMPILE_OPTIONS}")
target_compile_options(kineto_api PRIVATE "${KINETO_COMPILE_OPTIONS}")

if(NOT TARGET fmt)
if(NOT FMT_SOURCE_DIR)
set(FMT_SOURCE_DIR "${LIBKINETO_THIRDPARTY_DIR}/fmt"
Expand All @@ -95,6 +104,8 @@ if(NOT TARGET fmt)
endif()

set(FMT_INCLUDE_DIR "${FMT_SOURCE_DIR}/include")
message(STATUS "Kineto: FMT_SOURCE_DIR = ${FMT_SOURCE_DIR}")
message(STATUS "Kineto: FMT_INCLUDE_DIR = ${FMT_INCLUDE_DIR}")
if (NOT CUPTI_INCLUDE_DIR)
set(CUPTI_INCLUDE_DIR "${CUDA_SOURCE_DIR}/extras/CUPTI/include")
endif()
Expand All @@ -112,6 +123,7 @@ target_include_directories(kineto_base PUBLIC
$<BUILD_INTERFACE:${CUDA_INCLUDE_DIRS}>)

target_include_directories(kineto_api PUBLIC
$<BUILD_INTERFACE:${FMT_INCLUDE_DIR}>
$<BUILD_INTERFACE:${LIBKINETO_INCLUDE_DIR}>)

if(KINETO_LIBRARY_TYPE STREQUAL "default")
Expand All @@ -132,10 +144,11 @@ else()
message(FATAL_ERROR "Unsupported library type ${KINETO_LIBRARY_TYPE}")
endif()

target_link_libraries(kineto "${CUDA_cupti_LIBRARY}")

target_link_libraries(kineto $<BUILD_INTERFACE:fmt>)
add_dependencies(kineto fmt)
if(NOT LIBKINETO_NOCUPTI)
target_link_libraries(kineto "${CUDA_cupti_LIBRARY}")
endif()
target_link_libraries(kineto $<BUILD_INTERFACE:fmt::fmt-header-only>)
add_dependencies(kineto fmt::fmt-header-only)

install(TARGETS kineto EXPORT kinetoLibraryConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
11 changes: 10 additions & 1 deletion libkineto/include/ActivityProfilerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <memory>
#include <set>
#include <thread>
#include <vector>

#include "ActivityType.h"
Expand All @@ -17,7 +18,7 @@
namespace libkineto {

class ActivityProfilerController;
class CpuTraceBuffer;
struct CpuTraceBuffer;
class Config;

class ActivityProfilerInterface {
Expand Down Expand Up @@ -76,6 +77,14 @@ class ActivityProfilerInterface {
virtual bool enableForRegion(const std::string& match) {
return true;
}

// Saves information for the current thread to be used in profiler output
// Client must record any new kernel thread where the activity has occured.
virtual void recordThreadInfo() {}

// Record trace metadata, currently supporting only string key and values,
// values with the same key are overwritten
virtual void addMetadata(const std::string& key, const std::string& value) = 0;
};

} // namespace libkineto
2 changes: 1 addition & 1 deletion libkineto/include/ActivityTraceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace libkineto {

class TraceActivity;
struct TraceActivity;

class ActivityTraceInterface {
public:
Expand Down
21 changes: 18 additions & 3 deletions libkineto/include/ActivityType.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@

#pragma once

#include <array>
#include <string>

namespace libkineto {

enum class ActivityType {
CPU_OP,
CPU_OP = 0, // cpu side ops
USER_ANNOTATION,
GPU_USER_ANNOTATION,
GPU_MEMCPY,
GPU_MEMSET,
CONCURRENT_KERNEL,
CONCURRENT_KERNEL, // on-device kernels
EXTERNAL_CORRELATION,
CUDA_RUNTIME
CUDA_RUNTIME, // host side cuda runtime events
GLOW_RUNTIME, // host side glow runtime events
CPU_INSTANT_EVENT, // host side point-like events
ENUM_COUNT
};

const char* toString(ActivityType t);
ActivityType toActivityType(const std::string& str);

// Return an array of all activity types except COUNT
constexpr int activityTypeCount = (int)ActivityType::ENUM_COUNT;
const std::array<ActivityType, activityTypeCount> activityTypes();

} // namespace libkineto
77 changes: 0 additions & 77 deletions libkineto/include/ClientTraceActivity.h

This file was deleted.

95 changes: 95 additions & 0 deletions libkineto/include/GenericTraceActivity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#include <fmt/format.h>
#include <string>
#include <thread>
#include <vector>

#include "ThreadUtil.h"
#include "TraceActivity.h"
#include "TraceSpan.h"

namespace libkineto {

// @lint-ignore-every CLANGTIDY cppcoreguidelines-non-private-member-variables-in-classes
// @lint-ignore-every CLANGTIDY cppcoreguidelines-pro-type-member-init
class GenericTraceActivity : public TraceActivity {

public:
GenericTraceActivity() = delete;

GenericTraceActivity(
const TraceSpan& trace, ActivityType type, const std::string& name)
: activityType(type), activityName(name), traceSpan_(&trace) {
}

int64_t deviceId() const override {
return device;
}

int64_t resourceId() const override {
return resource;
}

int64_t timestamp() const override {
return startTime;
}

int64_t duration() const override {
return endTime - startTime;
}

int64_t correlationId() const override {
return id;
}

ActivityType type() const override {
return activityType;
}

const std::string name() const override {
return activityName;
}

const TraceActivity* linkedActivity() const override {
return nullptr;
}

const TraceSpan* traceSpan() const override {
return traceSpan_;
}

void log(ActivityLogger& logger) const override;

//Encode client side metadata as a key/value string.
void addMetadata(const std::string& key, const std::string& value) {
metadata_.push_back(fmt::format("\"{}\": {}", key, value));
}

const std::string getMetadata() const {
return fmt::format("{}", fmt::join(metadata_, ", "));
}

virtual ~GenericTraceActivity() {};

int64_t startTime{0};
int64_t endTime{0};
int32_t id{0};
int32_t device{0};
int32_t resource{0};
ActivityType activityType;
std::string activityName;

private:
const TraceSpan* traceSpan_;
std::vector<std::string> metadata_;
};

} // namespace libkineto
Loading