1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright 2020-2023 Intel Corporation.
//
// This software and the related documents are Intel copyrighted materials,
// and your use of them is governed by the express license under which they
// were provided to you ("License"). Unless the License provides otherwise,
// you may not use, modify, copy, publish, distribute, disclose or transmit
// this software or the related documents without Intel's prior written
// permission.
//
// This software and the related documents are provided as is, with no express
// or implied warranties, other than those that are expressly stated in the
// License.
#ifndef DEVICE_H
#define DEVICE_H
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "dla_runtime_log.h"
using namespace std;
using DebugNetworkData = std::map<std::string, uint64_t>;
// dla log macro
#define DLA_LOG(fmt, ...) printf(fmt, ##__VA_ARGS__);
#define DLA_ERROR(fmt, ...) printf(fmt, ##__VA_ARGS__);
class GraphJob;
class arch_params;
namespace dla {
class CompiledResult;
}
class Device {
public:
static unique_ptr<Device> MakeUnique(const arch_params* archParams, uint32_t waitForDlaTimeoutSeconds);
virtual GraphJob* CreateGraphJob(const dla::CompiledResult* compiledResult,
size_t numPipelines,
int instance,
std::string AES_key,
std::string IV_key,
bool encryption_enabled,
const std::string export_dir,
const std::string parameter_rom_export_dir) = 0;
// Return number of DLA jobs completed till now
// Used for debugging
virtual int GetNumInferencesCompleted(int instance) const = 0;
// Must be called when there are no active jobs on DLA
// Returns the total time taken by DLA jobs on hardware (in milliseconds)
virtual double GetActiveHWTimeMs(int instance) const = 0;
// Must be called when there are no active jobs on DLA
// Returns the average of time taken per job (in milliseconds)
// Avg Time per job < Active Time
virtual double GetAvgHWTimePerJobMs(uint64_t num_jobs, int instance) const = 0;
// Must be called when there are no active jobs on DLA
// Returns the number of memory read made by the input feature reader
virtual uint64_t GetNumInputFeatureMemoryReads(int instance) const = 0;
// Must be called when there are no active jobs on DLA
// Returns the number of memory read made by the filter reader
virtual uint64_t GetNumFilterMemoryReads(int instance) const = 0;
// Must be called when there are no active jobs on DLA
// Returns the number of memory writes made by the output feature writer
virtual uint64_t GetNumOutputFeatureMemoryWrites(int instance) const = 0;
// Waits for a job to finish on specified instance
virtual void WaitForDla(int instance, size_t threadId = 0, std::function<bool()> isCancelled = nullptr) = 0;
virtual int GetNumInstances() const = 0;
virtual double GetCoreDlaClockFreq() const = 0;
virtual int GetSizeCsrDescriptorQueue() const = 0;
virtual std::string SchedulerGetStatus() const = 0;
virtual bool InitializeScheduler(uint32_t sourceBufferSize,
uint32_t dropSourceBuffers,
uint32_t numInferenceRequests,
const std::string source_fifo_file="") = 0;
virtual DebugNetworkData ReadDebugNetwork(int instance) const = 0;
virtual ~Device(){}
};
#endif // DEVICE_H
|