aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/backends/ClContextControl.hpp
blob: 8098e30b75d92ce5060e96fe4a877953a9879958 (plain)
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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#pragma once

#include "armnn/IRuntime.hpp"

#ifdef ARMCOMPUTECL_ENABLED
#include <arm_compute/runtime/CL/CLTuner.h>
#endif

namespace armnn
{

class IClTunedParameters;
class ClTunedParameters;

// ARM Compute OpenCL context control
class ClContextControl
{
public:

    ClContextControl(IClTunedParameters* clTunedParameters = nullptr);

    virtual ~ClContextControl();

    void LoadOpenClRuntime();

    // Users should call this (after freeing all of the cl::Context objects they use)
    // to release the cached memory used by the compute library.
    void UnloadOpenClRuntime();

    // Clear the CL cache, without losing the tuned parameter settings
    void ClearClCache();

private:

    void DoLoadOpenClRuntime(bool useTunedParameters);

    ClTunedParameters* m_clTunedParameters;

};

class ClTunedParameters : public IClTunedParameters
{
public:
    ClTunedParameters(armnn::IClTunedParameters::Mode mode);

    virtual void Load(const char* filename);
    virtual void Save(const char* filename) const;

    Mode m_Mode;

#ifdef ARMCOMPUTECL_ENABLED
    arm_compute::CLTuner m_Tuner;
#endif
};

} // namespace armnn