Skip to content

Commit 7e3ea4d

Browse files
authored
Add Mali G1 series support. (#95)
1 parent 6ec68b6 commit 7e3ea4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3207
-130
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text eol=lf
3+
4+
# Force these text files to normalized endings
5+
*.c text
6+
*.cpp text
7+
*.h text
8+
*.hpp text
9+
*.md text
10+
*.py text
11+
*.sh text
12+
*.txt text

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#
2-
# Copyright (c) 2021-2023 Arm Limited.
2+
# Copyright (c) 2021-2025 Arm Limited.
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
cmake_minimum_required(VERSION 3.13.5)
88

9-
project(hwcpipe VERSION 2.3)
9+
project(hwcpipe VERSION 2.4)
1010

1111
set(CMAKE_CXX_STANDARD 14)
1212
set(CMAKE_CXX_STANDARD_REQUIRED ON)

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Arm Limited
3+
Copyright (c) 2023-2025 Arm Limited
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
66
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the

backend/.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude: "device/src/uapi/.*"
77
repos:
88
# global hooks
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.4.0
10+
rev: v4.6.0
1111
hooks:
1212
- id: trailing-whitespace
1313
- id: end-of-file-fixer
@@ -28,13 +28,13 @@ repos:
2828
- id: jenkinslint
2929
files: Jenkinsfile
3030
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
31-
rev: v9.5.0
31+
rev: v9.16.0
3232
hooks:
3333
- id: commitlint
3434
stages: [commit-msg]
3535
additional_dependencies: ['@commitlint/config-conventional']
3636
- repo: https://github.com/pre-commit/mirrors-prettier
37-
rev: v2.7.1
37+
rev: v3.1.0
3838
hooks:
3939
- id: prettier
4040
types: [markdown]
@@ -44,7 +44,7 @@ repos:
4444
- id: cmake-format
4545
- id: cmake-lint
4646
- repo: https://github.com/PyCQA/pylint
47-
rev: v3.0.0a6
47+
rev: v3.1.0
4848
hooks:
4949
- id: pylint
5050
additional_dependencies: &pip-packages
@@ -53,16 +53,16 @@ repos:
5353
- types-PyYAML==6.0.7
5454
- parameterized==0.8.1
5555
- repo: https://github.com/PyCQA/flake8
56-
rev: 6.0.0
56+
rev: 7.0.0
5757
hooks:
5858
- id: flake8
5959
args: ['--max-line-length=120']
6060
- repo: https://github.com/psf/black
61-
rev: 23.3.0
61+
rev: 24.4.2
6262
hooks:
6363
- id: black
6464
- repo: https://github.com/pre-commit/mirrors-mypy
65-
rev: v1.3.0
65+
rev: v1.10.0
6666
hooks:
6767
- id: mypy
6868
additional_dependencies: *pip-packages
@@ -71,7 +71,7 @@ repos:
7171
hooks:
7272
- id: clang-format
7373
- repo: https://github.com/codespell-project/codespell
74-
rev: v2.2.4
74+
rev: v2.2.6
7575
hooks:
7676
- id: codespell
7777
exclude: "third_party/.*/vendor/.*"

backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2021-2022 ARM Limited.
2+
# Copyright (c) 2021-2024 ARM Limited.
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -22,6 +22,7 @@
2222
# SOFTWARE.
2323
#
2424

25+
# TODO GPUCORE-30489: Update the version to 3.16.
2526
cmake_minimum_required(VERSION 3.13.5)
2627

2728
project(hwcpipe2)

backend/device/include/device/hwcnt/block_extents.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023 Arm Limited.
2+
* Copyright (c) 2021-2024 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -64,6 +64,18 @@ class block_extents {
6464

6565
using num_blocks_of_type_type = std::array<uint8_t, num_block_types>;
6666

67+
using num_block_states_type = std::underlying_type_t<block_state_type>;
68+
69+
/** Number of block state types. */
70+
static const constexpr num_block_states_type num_block_states =
71+
static_cast<num_block_states_type>(block_state_type::last) + 1;
72+
73+
using num_block_state_strings_type = std::array<const char *, num_block_states>;
74+
75+
static const constexpr num_block_state_strings_type num_block_state_strings = {
76+
"on", "off", "available", "unavailable", "normal", "protected",
77+
};
78+
6779
/**
6880
* Construct block extents.
6981
*

backend/device/include/device/hwcnt/block_metadata.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023 Arm Limited.
2+
* Copyright (c) 2021-2025 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -57,9 +57,21 @@ enum class block_type : uint8_t {
5757
csg,
5858
/** First block type. */
5959
first = fe,
60+
/** Last block type. */
6061
last = csg,
6162
};
6263

64+
enum class block_state_type : uint8_t {
65+
on,
66+
off,
67+
available,
68+
unavailable,
69+
normal_mode,
70+
protected_mode,
71+
first = on,
72+
last = protected_mode,
73+
};
74+
6375
/**
6476
* Block state during the counters sample time.
6577
*
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2024 Arm Limited.
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to
8+
* deal in the Software without restriction, including without limitation the
9+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
* sell copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
/**
26+
* @file
27+
*
28+
* Hardware counters clock extents header.
29+
*/
30+
31+
#pragma once
32+
33+
#include <device/hwcnt/features.hpp>
34+
35+
#include <array>
36+
#include <cassert>
37+
#include <cstddef>
38+
#include <iterator>
39+
#include <map>
40+
#include <type_traits>
41+
#include <vector>
42+
43+
namespace hwcpipe {
44+
namespace device {
45+
namespace hwcnt {
46+
47+
/**
48+
* Clocks extents class.
49+
*
50+
* Stores information about clock numbers and clock names
51+
*/
52+
class clock_extents {
53+
public:
54+
/** Number of clock types. GPU Cycle Clock and SC Cycle Clock */
55+
static const constexpr size_t num_clock_types = 2;
56+
57+
using num_clock_types_strings_type = std::array<const char *, num_clock_types>;
58+
59+
/**
60+
* Construct clock extents.
61+
*
62+
* @param[in] has_gpu_cycle does GPU support GPU clock
63+
* @param[in] has_sc_cycle does GPU support SC clock
64+
*/
65+
clock_extents(bool has_gpu_cycle, bool has_sc_cycle) {
66+
was_set = true;
67+
has_gpu_cycle_ = false;
68+
has_sc_cycle_ = false;
69+
70+
if (has_gpu_cycle) {
71+
has_gpu_cycle_ = true;
72+
}
73+
if (has_sc_cycle) {
74+
has_sc_cycle_ = true;
75+
}
76+
}
77+
78+
/** Default ctor. */
79+
clock_extents()
80+
: has_gpu_cycle_(false)
81+
, has_sc_cycle_(false)
82+
, was_set(false){};
83+
/** Default copy ctor. */
84+
clock_extents(const clock_extents &) = default;
85+
/** Default assign. */
86+
clock_extents &operator=(const clock_extents &) = default;
87+
88+
/** @return number of clocks. */
89+
uint16_t num_of_enabled_clocks() const { return static_cast<uint16_t>(has_gpu_cycle_ + has_sc_cycle_); }
90+
91+
/** @return is GPU cycle clock enabled. */
92+
bool has_gpu_cycle() const { return has_gpu_cycle_; }
93+
94+
/** @return is Shader cycle clock enabled. */
95+
bool has_sc_cycle() const { return has_sc_cycle_; }
96+
97+
bool was_clock_extent_set() const { return was_set; }
98+
99+
/** @return clock names in domain order */
100+
const std::vector<const char *> get_active_clock_strings() const {
101+
std::vector<const char *> ret;
102+
if (has_gpu_cycle_)
103+
ret.push_back(clock_types_strings[gpu_cycle_idx]);
104+
if (has_sc_cycle_)
105+
ret.push_back(clock_types_strings[sc_cycle_idx]);
106+
return ret;
107+
};
108+
109+
private:
110+
bool has_gpu_cycle_;
111+
bool has_sc_cycle_;
112+
bool was_set;
113+
static constexpr size_t gpu_cycle_idx = 0;
114+
static constexpr size_t sc_cycle_idx = 1;
115+
116+
static const constexpr num_clock_types_strings_type clock_types_strings = {
117+
"Top cycle",
118+
"Shader cores",
119+
};
120+
};
121+
122+
} // namespace hwcnt
123+
} // namespace device
124+
} // namespace hwcpipe

backend/device/include/device/hwcnt/features.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023 Arm Limited.
2+
* Copyright (c) 2021-2024 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -56,13 +56,20 @@ namespace hwcnt {
5656
struct features {
5757
/**
5858
* True if HWC samples are annotated with the number of
59-
* GPU and shader cores cycles since the last sample.
59+
* GPU cycles since the last sample.
6060
*
61-
* When true, @ref sample_metadata::gpu_cycle and @ref sample_metadata::sc_cycle
62-
* values are set.
61+
* When true, @ref sample_metadata::gpu_cycle values are set.
6362
*/
6463
bool has_gpu_cycle;
6564

65+
/**
66+
* True if HWC samples are annotated with the number of
67+
* shader cores cycles since the last sample.
68+
*
69+
* When true, @ref sample_metadata::sc_cycle values are set.
70+
*/
71+
bool has_sc_cycle;
72+
6673
/** True if @ref block_metadata::state power values are set. */
6774
bool has_power_states;
6875

backend/device/include/device/instance.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023 Arm Limited.
2+
* Copyright (c) 2021-2024 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -33,6 +33,7 @@
3333
#include <device/api.hpp>
3434
#include <device/constants.hpp>
3535
#include <device/hwcnt/block_extents.hpp>
36+
#include <device/hwcnt/clock_extents.hpp>
3637

3738
#include <memory>
3839

@@ -78,6 +79,13 @@ class HWCPIPE_DEVICE_API instance {
7879
*/
7980
virtual hwcnt::block_extents get_hwcnt_block_extents() const = 0;
8081

82+
/**
83+
* Get hardware counters clock's extents.
84+
*
85+
* @return The clock_extents structure instance.
86+
*/
87+
virtual hwcnt::clock_extents get_hwcnt_clock_extents() const = 0;
88+
8189
/**
8290
* Create device instance.
8391
*

0 commit comments

Comments
 (0)