aboutsummaryrefslogtreecommitdiff
path: root/driver_library/include/ethosu.hpp
diff options
context:
space:
mode:
authorPer Åstrand <per.astrand@arm.com>2020-10-24 20:17:10 +0200
committerPer Åstrand <per.astrand@arm.com>2020-11-16 13:57:40 +0100
commit2354d3e8a681b282e1fc1b098ecacca3c58e38c0 (patch)
tree84359938e9f9d71d2d11db35f8ab5ee00b16e343 /driver_library/include/ethosu.hpp
parentf7e407a0fe58d76d54e3d1f9d2cb117036cd095b (diff)
downloadethos-u-linux-driver-stack-2354d3e8a681b282e1fc1b098ecacca3c58e38c0.tar.gz
Add APIs for PMU configuration in library
Change-Id: I7694ab9dd5ff20c29feb0506bcf36a1cf4983243
Diffstat (limited to 'driver_library/include/ethosu.hpp')
-rw-r--r--driver_library/include/ethosu.hpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/driver_library/include/ethosu.hpp b/driver_library/include/ethosu.hpp
index 12192bf..70d0701 100644
--- a/driver_library/include/ethosu.hpp
+++ b/driver_library/include/ethosu.hpp
@@ -96,19 +96,46 @@ public:
network(network) {
std::copy(ifmBegin, ifmEnd, std::back_inserter(ifmBuffers));
std::copy(ofmBegin, ofmEnd, std::back_inserter(ofmBuffers));
- create();
+ std::vector<uint32_t> counterConfigs = initializeCounterConfig();
+
+ create(counterConfigs, false);
}
+ template <typename T, typename U>
+ Inference(std::shared_ptr<Network> &network,
+ const T &ifmBegin,
+ const T &ifmEnd,
+ const T &ofmBegin,
+ const T &ofmEnd,
+ const U &counters,
+ bool enableCycleCounter) :
+ network(network) {
+ std::copy(ifmBegin, ifmEnd, std::back_inserter(ifmBuffers));
+ std::copy(ofmBegin, ofmEnd, std::back_inserter(ofmBuffers));
+ std::vector<uint32_t> counterConfigs = initializeCounterConfig();
+
+ if (counters.size() > counterConfigs.size())
+ throw EthosU::Exception("PMU Counters argument to large.");
+
+ std::copy(counters.begin(), counters.end(), counterConfigs.begin());
+ create(counterConfigs, enableCycleCounter);
+ }
+
virtual ~Inference();
- void wait(int timeoutSec = -1);
+ int wait(int timeoutSec = -1);
+ const std::vector<uint32_t> getPmuCounters();
+ uint64_t getCycleCounter();
bool failed();
int getFd();
std::shared_ptr<Network> getNetwork();
std::vector<std::shared_ptr<Buffer>> &getIfmBuffers();
std::vector<std::shared_ptr<Buffer>> &getOfmBuffers();
+ static uint32_t getMaxPmuEventCounters();
+
private:
- void create();
+ void create(std::vector<uint32_t> &counterConfigs, bool enableCycleCounter);
+ std::vector<uint32_t> initializeCounterConfig();
int fd;
std::shared_ptr<Network> network;