Skip to content

Commit

Permalink
Gator 8.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Oct 30, 2023
1 parent c44388e commit e2a71c3
Show file tree
Hide file tree
Showing 118 changed files with 3,302 additions and 547 deletions.
3 changes: 2 additions & 1 deletion daemon/Buffer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2013-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2013-2023 by Arm Limited. All rights reserved. */

#ifndef BUFFER_H
#define BUFFER_H
Expand All @@ -9,6 +9,7 @@

#include "IBufferControl.h"
#include "IRawFrameBuilder.h"
#include "lib/Span.h"

#include <atomic>
#include <cstdint>
Expand Down
30 changes: 27 additions & 3 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_worker_base.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_worker.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_workers_process.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_workers_process_fwd.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_workers_process_holder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/agents/agent_workers_process_holder.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/common/coalescing_cpu_monitor.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/common/nl_cpu_monitor.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/common/polling_cpu_monitor.h
Expand Down Expand Up @@ -327,6 +330,7 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/apc/perf_apc_frame_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/apc/perf_counter.h
${CMAKE_CURRENT_SOURCE_DIR}/apc/summary_apc_frame_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/AcceptedSocketQueue.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ArmNNDriver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ArmNNDriver.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ArmNNSource.cpp
Expand All @@ -341,6 +345,8 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/DecoderUtility.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/DriverSourceIpc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/DriverSourceIpc.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/DriverSourceWithAgent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/DriverSourceWithAgent.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/FrameBuilderFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/FrameBuilderFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/GlobalState.cpp
Expand All @@ -360,6 +366,8 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/IPerJobCounterSelectionConsumer.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ISender.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ISession.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ISocketIO.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/IAcceptingSocket.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/ISessionPacketSender.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/IStartStopHandler.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/PacketDecoder.cpp
Expand All @@ -381,7 +389,6 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SessionPacketSender.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SessionStateTracker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SessionStateTracker.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SocketAcceptor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SocketAcceptor.h
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SocketIO.cpp
${CMAKE_CURRENT_SOURCE_DIR}/armnn/SocketIO.h
Expand Down Expand Up @@ -445,6 +452,7 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/capture/Environment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/capture/Environment.h
${CMAKE_CURRENT_SOURCE_DIR}/capture/internal/UdpListener.h
${CMAKE_CURRENT_SOURCE_DIR}/handleException.h
${CMAKE_CURRENT_SOURCE_DIR}/ipc/async_streamline_sender.h
${CMAKE_CURRENT_SOURCE_DIR}/ipc/codec.h
${CMAKE_CURRENT_SOURCE_DIR}/ipc/message_key.h
Expand All @@ -471,6 +479,8 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/FsEntry.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/FsUtils.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/GenericTimer.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/LineReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/LineReader.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/Memory.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/perfetto_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/lib/PmuCommonEvents.h
Expand Down Expand Up @@ -538,13 +548,18 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux/Tracepoints.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/agent_log.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logging/agent_log.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/file_log_sink.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/configuration.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/file_log_sink.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logging/file_log_sink.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/global_log.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logging/global_log.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/logger_t.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/logging.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logging/suppliers.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/log_sink_t.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/parameters.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/std_log_sink.h
${CMAKE_CURRENT_SOURCE_DIR}/logging/suppliers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logging/suppliers.h
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliDevice.h
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliGPUClockPolledDriverCounter.h
Expand Down Expand Up @@ -600,6 +615,15 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xml/PmuXMLParser.h
)

IF(ANDROID)
SET(GATORD_SRC_FILES ${GATORD_SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/agents/armnn/armnn_agent.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/armnn/armnn_agent_main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/agents/armnn/armnn_agent_main.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/armnn/armnn_agent_worker.h
)
ENDIF()

IF(CONFIG_USE_PERFETTO)
SET(GATORD_SRC_FILES ${GATORD_SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/agents/perfetto/perfetto_agent.h
Expand Down
48 changes: 38 additions & 10 deletions daemon/Child.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Child.h"

#include "CapturedXML.h"
#include "Config.h"
#include "ConfigurationXML.h"
#include "CounterXML.h"
#include "Driver.h"
Expand All @@ -22,17 +23,14 @@
#include "SessionData.h"
#include "StreamlineSetup.h"
#include "UserSpaceSource.h"
#include "agents/agent_workers_process.h"
#include "agents/perfetto/perfetto_driver.h"
#include "agents/spawn_agent.h"
#include "armnn/ArmNNSource.h"
#include "capture/CaptureProcess.h"
#include "capture/Environment.h"
#include "lib/Assert.h"
#include "lib/FsUtils.h"
#include "lib/WaitForProcessPoller.h"
#include "lib/Waiter.h"
#include "lib/perfetto_utils.h"
#include "logging/global_log.h"
#include "mali_userspace/MaliHwCntrSource.h"
#include "xml/EventsXML.h"

Expand All @@ -46,6 +44,7 @@
#include <boost/asio/detached.hpp>
#include <boost/filesystem.hpp>

#include <semaphore.h>
#include <sys/eventfd.h>
#include <sys/prctl.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -152,7 +151,7 @@ void Child::run()
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(&"gatord-child"), 0, 0, 0);

// TODO: better place for this
agent_workers_process.start();
agent_workers_process->start();

// Disable line wrapping when generating xml files; carriage returns and indentation to be added manually
mxmlSetWrapMargin(0);
Expand Down Expand Up @@ -272,6 +271,7 @@ void Child::run()
lib::Waiter waitTillStart;
lib::Waiter waitForExternalSourceAgent;
lib::Waiter waitForPerfettoAgent;
lib::Waiter waitForArmnnAgent;

auto startedCallback = [&]() {
LOG_DEBUG("Received start capture callback");
Expand All @@ -285,7 +285,7 @@ void Child::run()
// Must be initialized before senderThread is started as senderThread checks externalSource
if (!addSource(createExternalSource(senderSem, drivers),
[this, &waitForExternalSourceAgent, &waitForPerfettoAgent, enablePerfettoAgent](auto & source) {
this->agent_workers_process.async_add_external_source(
this->agent_workers_process->async_add_external_source(
source,
[&waitForExternalSourceAgent](bool success) {
waitForExternalSourceAgent.disable();
Expand All @@ -298,7 +298,7 @@ void Child::run()
});
#ifdef CONFIG_USE_PERFETTO
if (enablePerfettoAgent) {
this->agent_workers_process.async_add_perfetto_source(
this->agent_workers_process->async_add_perfetto_source(
source,
[&waitForPerfettoAgent](bool success) {
waitForPerfettoAgent.disable();
Expand Down Expand Up @@ -344,7 +344,7 @@ void Child::run()
gSessionData.mPids,
drivers.getFtraceDriver(),
!gSessionData.mCaptureCommand.empty(),
agent_workers_process);
*agent_workers_process);
if (newPrimarySource == nullptr) {
LOG_ERROR("%s", primarySourceProvider.getPrepareFailedMessage());
handleException();
Expand Down Expand Up @@ -376,11 +376,39 @@ void Child::run()
}
}

if (!addSource(armnn::createSource(drivers.getArmnnDriver().getCaptureController(), senderSem))) {
if (!addSource(armnn::createSource(drivers.getArmnnDriver().getCaptureController(), senderSem),
#if CONFIG_ARMNN_AGENT
[this, &waitForArmnnAgent](auto & /*source*/) {
this->agent_workers_process->async_add_armnn_source(
drivers.getArmnnDriver().getAcceptedSocketConsumer(),
[&waitForArmnnAgent](bool success) {
waitForArmnnAgent.disable();
if (!success) {
LOG_ERROR("Failed to start armnn agent");
handleException();
}
else {
LOG_DEBUG("Started armnn agent");
}
});
}
#else
[&waitForArmnnAgent](auto & /*source*/) { waitForArmnnAgent.disable(); }
#endif
)) {
LOG_ERROR("Unable to prepare ArmNN source for capture");
handleException();
}

#if CONFIG_ARMNN_AGENT
if (!sessionEnded) {
LOG_DEBUG("Waiting for armnn agent to start");
waitForArmnnAgent.wait();
LOG_DEBUG("Waiting for armnn agent complete");
drivers.getArmnnDriver().startAcceptingThread();
}
#endif

// do this last so that monotonic start is close to start of profiling
auto monotonicStart = primarySource.sendSummary();
if (!monotonicStart) {
Expand Down Expand Up @@ -433,7 +461,7 @@ void Child::run()
LOG_FINE("Profiling ended.");

// must happen before sources is cleared
agent_workers_process.join();
agent_workers_process->join();

sources.clear();

Expand Down
17 changes: 6 additions & 11 deletions daemon/Child.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#define __CHILD_H__

#include "Configuration.h"
#include "Logging.h"
#include "Source.h"
#include "agents/agent_workers_process.h"
#include "agents/agent_workers_process_holder.h"
#include "capture/CaptureProcess.h"
#include "handleException.h"
#include "lib/AutoClosingFd.h"
#include "logging/suppliers.h"

Expand All @@ -17,8 +17,6 @@
#include <set>
#include <vector>

#include <semaphore.h>

class Drivers;
class Sender;
class OlySocket;
Expand All @@ -28,9 +26,7 @@ namespace lib {
class Waiter;
}

void handleException() __attribute__((noreturn));

class Child {
class Child : private agents::i_agent_worker_manager_callbacks_t {
public:
struct Config {
std::set<CounterConfiguration> events;
Expand Down Expand Up @@ -67,7 +63,6 @@ class Child {

private:
friend void ::handleException();
friend class agents::agent_workers_process_manager_t<Child>;

static std::atomic<Child *> gSingleton;

Expand All @@ -88,7 +83,7 @@ class Child {
Config config;
const logging::log_access_ops_t & log_ops;
std::shared_ptr<Command> command {};
agents::agent_workers_process_t<Child> agent_workers_process;
agents::agent_worker_manager_holder_t agent_workers_process;

Child(agents::i_agent_spawner_t & hi_priv_spawner,
agents::i_agent_spawner_t & lo_priv_spawner,
Expand Down Expand Up @@ -128,8 +123,8 @@ class Child {
void doEndSession();

// for agent_workers_process_t
void on_terminal_signal(int signo);
void on_agent_thread_terminated();
void on_agent_thread_terminated() override;
void on_terminal_signal(int signo) override;
};

#endif //__CHILD_H__
12 changes: 9 additions & 3 deletions daemon/Config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#ifndef CONFIG_H
#define CONFIG_H
Expand All @@ -8,8 +8,6 @@

#define ARRAY_LENGTH(A) static_cast<int>(sizeof(A) / sizeof((A)[0]))

#define MAX_PERFORMANCE_COUNTERS 100

// feature control options
#ifndef CONFIG_PREFER_SYSTEM_WIDE_MODE
#define CONFIG_PREFER_SYSTEM_WIDE_MODE 1
Expand Down Expand Up @@ -68,4 +66,12 @@
#endif
#endif

#ifndef CONFIG_ARMNN_AGENT
#if defined(ANDROID) || defined(__ANDROID__)
#define CONFIG_ARMNN_AGENT 1
#else
#define CONFIG_ARMNN_AGENT 0
#endif
#endif

#endif // CONFIG_H
Loading

0 comments on commit e2a71c3

Please sign in to comment.