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
2 changes: 1 addition & 1 deletion libkineto/include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Config : public AbstractConfig {
return profileStartIteration_ - activitiesWarmupIterations_;
}

const std::chrono::seconds maxRequestAge() const;
static std::chrono::seconds maxRequestAge();

// All VLOG* macros will log if the verbose log level is >=
// the verbosity specified for the verbose log message.
Expand Down
7 changes: 4 additions & 3 deletions libkineto/include/libkineto.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ class LibkinetoApi {
}

void initProfilerIfRegistered() {
static std::once_flag once;
if (activityProfiler_) {
std::call_once(once, [this] {
static bool once_flag = [this] {
if (!activityProfiler_->isInitialized()) {
activityProfiler_->init();
initChildActivityProfilers();
}
});
return true;
}();
(void)once_flag;
}
}

Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ uint8_t Config::createDeviceMask(const string& val) {
return res;
}

const seconds Config::maxRequestAge() const {
seconds Config::maxRequestAge() {
return kMaxRequestAge;
}

Expand Down
6 changes: 3 additions & 3 deletions libkineto/src/ConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ConfigLoader& ConfigLoader::instance() {

// return an empty string if polling gets any errors. Otherwise a config string.
std::string ConfigLoader::readOnDemandConfigFromDaemon(
time_point<system_clock> now) {
time_point<system_clock> /*now*/) {
if (!daemonConfigLoader_) {
return "";
}
Expand Down Expand Up @@ -222,7 +222,7 @@ const char* ConfigLoader::customConfigFileName() {
return getenv(kConfigFileEnvVar);
}

const std::string ConfigLoader::getConfString() {
std::string ConfigLoader::getConfString() {
return readConfigFromConfigFile(configFileName(), false);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ void ConfigLoader::updateBaseConfig() {
}

void ConfigLoader::configureFromSignal(
time_point<system_clock> now,
time_point<system_clock> /*now*/,
Config& config) {
LOG(INFO) << "Received on-demand profiling signal, " << "reading config from "
<< kOnDemandConfigFile;
Expand Down
6 changes: 3 additions & 3 deletions libkineto/src/ConfigLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConfigLoader {
enum ConfigKind { ActivityProfiler = 0, EventProfiler, NumConfigKinds };

struct ConfigHandler {
virtual ~ConfigHandler() {}
virtual ~ConfigHandler() = default;
virtual bool canAcceptConfig() = 0;
virtual void acceptConfig(const Config& cfg) = 0;
};
Expand Down Expand Up @@ -85,7 +85,7 @@ class ConfigLoader {
}
}

inline std::unique_ptr<Config> getConfigCopy() {
std::unique_ptr<Config> getConfigCopy() {
std::lock_guard<std::mutex> lock(configLock_);
return config_->clone();
}
Expand All @@ -98,7 +98,7 @@ class ConfigLoader {
static void setDaemonConfigLoaderFactory(
std::function<std::unique_ptr<IDaemonConfigLoader>()> factory);

const std::string getConfString();
static std::string getConfString();

private:
ConfigLoader();
Expand Down
9 changes: 5 additions & 4 deletions libkineto/src/CuptiActivityApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ namespace KINETO_NAMESPACE {
constexpr size_t kBufSize(4 * 1024 * 1024);

#ifdef HAS_CUPTI
inline bool cuptiTearDown_() {
static inline bool cuptiTearDown_() {
auto teardown_env = getenv("TEARDOWN_CUPTI");
return teardown_env != nullptr && strcmp(teardown_env, "1") == 0;
}

inline bool cuptiLazyInit_() {
static inline bool cuptiLazyInit_() {
return cuptiTearDown_() && getenv("DISABLE_CUPTI_LAZY_REINIT") == nullptr;
}

inline void reenableCuptiCallbacks_(std::shared_ptr<CuptiCallbackApi>& cbapi_) {
static inline void reenableCuptiCallbacks_(
std::shared_ptr<CuptiCallbackApi>& cbapi_) {
// Re-enable callbacks from the past if they exist.
LOG(INFO) << "Re-enable previous CUPTI callbacks - Starting";
VLOG(1) << " CUPTI subscriber before reinit:"
Expand Down Expand Up @@ -234,7 +235,7 @@ int CuptiActivityApi::processActivitiesForBuffer(
}
#endif

const std::pair<int, size_t> CuptiActivityApi::processActivities(
std::pair<int, size_t> CuptiActivityApi::processActivities(
CuptiActivityBufferMap& buffers,
const std::function<void(const CUpti_Activity*)>& handler) {
std::pair<int, size_t> res{0, 0};
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/CuptiCallbackApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void CuptiCallbackApi::initCallbackApi() {
CuptiCallbackApi::CallbackList* CuptiCallbackApi::CallbackTable::lookup(
CUpti_CallbackDomain domain,
CuptiCallBackID cbid) {
size_t idx;
size_t idx = 0;

switch (domain) {
case CUPTI_CB_DOMAIN_RESOURCE:
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/CuptiRangeProfilerApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ void CuptiRBProfilerSession::asyncStartAndEnable(
CUpti_ProfilerRange /*profilerRange*/,
CUpti_ProfilerReplayMode /*profilerReplayMode*/) {}
void CuptiRBProfilerSession::asyncDisableAndStop() {}
CuptiProfilerResult CuptiRBProfilerSession::evaluateMetrics(bool verbose) {
CuptiProfilerResult CuptiRBProfilerSession::evaluateMetrics(bool /*verbose*/) {
static CuptiProfilerResult res;
return res;
};
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/DeviceProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace KINETO_NAMESPACE {
#if defined(HAS_CUPTI) || defined(HAS_ROCTRACER)
static const std::vector<gpuDeviceProp> createDeviceProps() {
std::vector<gpuDeviceProp> props;
int device_count;
int device_count = 0;
gpuError_t error_id = gpuGetDeviceCount(&device_count);
// Return empty vector if error.
if (error_id != gpuSuccess) {
Expand Down
29 changes: 13 additions & 16 deletions libkineto/src/DeviceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,36 @@

#include "DeviceUtil.h"

#include <mutex>

namespace KINETO_NAMESPACE {

bool amdGpuAvailable = false;
bool cudaGpuAvailable = false;

bool isAMDGpuAvailable() {
#ifdef HAS_ROCTRACER
static std::once_flag once;
std::call_once(once, [] {
static bool amdGpuAvailable = [] {
// determine AMD GPU availability on the system
hipError_t error;
int deviceCount;
error = hipGetDeviceCount(&deviceCount);
amdGpuAvailable = (error == hipSuccess && deviceCount > 0);
});
#endif
return (error == hipSuccess && deviceCount > 0);
}();
return amdGpuAvailable;
#else
return false;
#endif
}

bool isCUDAGpuAvailable() {
#ifdef HAS_CUPTI
static std::once_flag once;
std::call_once(once, [] {
static bool cudaGpuAvailable = [] {
// determine CUDA GPU availability on the system
cudaError_t error;
int deviceCount;
int deviceCount = 0;
error = cudaGetDeviceCount(&deviceCount);
cudaGpuAvailable = (error == cudaSuccess && deviceCount > 0);
});
#endif
return (error == cudaSuccess && deviceCount > 0);
}();
return cudaGpuAvailable;
#else
return false;
#endif
}

bool isGpuAvailable() {
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/IpcFabricConfigClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace KINETO_NAMESPACE {

namespace uuid {
std::string generate_uuid_v4() {
static std::string generate_uuid_v4() {
static std::random_device rd;
static std::mt19937 gen(rd());
static std::uniform_int_distribution<> dis(0, 15);
Expand Down
4 changes: 2 additions & 2 deletions libkineto/src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void initProfilers() {
#endif // __linux__ || defined(HAS_CUPTI)

#ifdef HAS_CUPTI
bool enableEventProfiler() {
static bool enableEventProfiler() {
if (getenv("KINETO_ENABLE_EVENT_PROFILER") != nullptr) {
return true;
} else {
Expand Down Expand Up @@ -81,7 +81,7 @@ static bool shouldPreloadCuptiInstrumentation() {
#endif
}

bool setupCuptiInitCallback(bool logOnError) {
static bool setupCuptiInitCallback(bool logOnError) {
// libcupti will be lazily loaded on this call.
// If it is not available (e.g. CUDA is not installed),
// then this call will return an error and we just abort init.
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/output_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void EventCSVLogger::update(const Config& config) {
void EventCSVLogger::handleSample(
int device,
const Sample& sample,
bool from_new_version) {
bool /*from_new_version*/) {
using namespace std::chrono;
if (out_) {
auto now = system_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion libkineto/src/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ChromeTraceBaseTime& ChromeTraceBaseTime::singleton() {
// while a double can only represent 15-16 digits. By using relative time,
// other applications can accurately read the 'ts' field as a double.
// Use the program loading time as the baseline time.
inline int64_t transToRelativeTime(int64_t time) {
static inline int64_t transToRelativeTime(int64_t time) {
// Sometimes after converting to relative time, it can be a few nanoseconds
// negative. Since Chrome trace and json processing will throw a parser error,
// guard this.
Expand Down
10 changes: 5 additions & 5 deletions libkineto/test/CuptiCallbackApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ using namespace libkineto;

const size_t some_data = 42;

std::atomic<int> simple_cb_calls = 0;
static std::atomic<int> simple_cb_calls = 0;

void simple_cudaLaunchKernel_cb(
static void simple_cudaLaunchKernel_cb(
CUpti_CallbackDomain domain,
CUpti_CallbackId cbid,
const CUpti_CallbackData* cbInfo) {
Expand All @@ -35,7 +35,7 @@ void simple_cudaLaunchKernel_cb(
simple_cb_calls++;
}

void simple_cudaLaunchKernelExC_cb(
static void simple_cudaLaunchKernelExC_cb(
CUpti_CallbackDomain domain,
CUpti_CallbackId cbid,
const CUpti_CallbackData* cbInfo) {
Expand All @@ -49,7 +49,7 @@ void simple_cudaLaunchKernelExC_cb(
simple_cb_calls++;
}

void atomic_cb(
static void atomic_cb(
CUpti_CallbackDomain /*domain*/,
CUpti_CallbackId /*cbid*/,
const CUpti_CallbackData* /*cbInfo)*/) {
Expand All @@ -60,7 +60,7 @@ void atomic_cb(
}
}

void empty_cb(
static void empty_cb(
CUpti_CallbackDomain /*domain*/,
CUpti_CallbackId /*cbid*/,
const CUpti_CallbackData* /*cbInfo*/) {}
Expand Down
2 changes: 1 addition & 1 deletion libkineto/test/CuptiRangeProfilerConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST_F(CuptiRangeProfilerConfigTest, RangesDefaults) {

cfg_auto.setClientDefaults();

int user_ranges, auto_ranges;
int user_ranges = 0, auto_ranges = 0;

user_ranges = CuptiRangeProfilerConfig::get(cfg).cuptiProfilerMaxRanges();
auto_ranges =
Expand Down
16 changes: 8 additions & 8 deletions libkineto/test/EventProfilerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ class EventProfilerTest : public ::testing::Test {
loggers_,
onDemandLoggers_);

for (int i = 0; i < kEventGroupCount; i++) {
eventGroups_[i] = &eventGroups_[i];
for (auto& eventGroup : eventGroups_) {
eventGroup = &eventGroup;
}
for (int i = 0; i < kGroupSetCount; i++) {
// Default size to 1 but can be changed by test
Expand Down Expand Up @@ -532,10 +532,10 @@ TEST_F(EventProfilerTest, ReportSample) {

EXPECT_CALL(*cuptiEvents_, readEvent(_, _, _))
.Times(6)
.WillRepeatedly(Invoke(
[](CUpti_EventGroup g, CUpti_EventID id, std::vector<int64_t>& vals) {
vals = {1, 2, 3, 4};
}));
.WillRepeatedly(
Invoke([](CUpti_EventGroup /*g*/,
CUpti_EventID /*id*/,
std::vector<int64_t>& vals) { vals = {1, 2, 3, 4}; }));

// Need to collect four times - twice for each group set
profiler_->collectSample();
Expand All @@ -557,9 +557,9 @@ TEST_F(EventProfilerTest, ReportSample) {
auto& logger = dynamic_cast<MockLogger&>(*loggers_[0]);
EXPECT_CALL(logger, handleSample(0, _, _))
.Times(1)
.WillOnce(Invoke([](int device,
.WillOnce(Invoke([](int /*device*/,
const Sample& sample,
bool from_new_version) {
bool /*from_new_version*/) {
// Sample will include all stats - logger must pick the
// ones it wants.
EXPECT_EQ(sample.stats.size(), 4);
Expand Down
2 changes: 1 addition & 1 deletion libkineto/test/LoggerObserverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST(LoggerObserverTest, SingleCollectorObserver) {

// Writes NUM_OF_MESSAGES_FOR_EACH_TYPE messages for each INFO, WARNING, and
// ERROR.
void* writeSeveralMessages() {
static void* writeSeveralMessages() {
for (int i = 0; i < NUM_OF_MESSAGES_FOR_EACH_TYPE; i++) {
LOG(INFO) << InfoTestStr;
LOG(WARNING) << WarningTestStr;
Expand Down
Loading