Parsing Select() expression dimension args to support range of values. (#1074)

* dim args for select token now supports range of values instead of single integer

* dim args for select token now supports range of values instead of single integer

* modified raw_ast fmt::format

* CHANGELOG.md

* varible rename for select dim from set to map in suffix

* use : for giving range of values

* Update source/lib/rocprofiler-sdk/counters/parser/scanner.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* format

* Update CHANGELOG.md

* using map instead of unordermap for select_dimension_map

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gopesh Bhardwaj <gopesh.bhardwaj@amd.com>
This commit is contained in:
venkat1361
2024-10-22 01:14:08 -05:00
committed by GitHub
vanhempi 210762c69d
commit 22881148bd
8 muutettua tiedostoa jossa 323 lisäystä ja 228 poistoa
+1
Näytä tiedosto
@@ -115,6 +115,7 @@ Full documentation for ROCprofiler-SDK is available at [Click Here](source/docs/
- Fixed MeanOccupancy* metrics
- Fix aborted-app validation test to properly check for hipExtHostAlloc command now that it is supported
- Fix for SQ and GRBM metrics implicitly reduced.
- Fix to handle a range of values for select() dimension in expressions parser.
### Removed
- Removed gfx8 metric definitions.
@@ -82,7 +82,7 @@ yyerror(rocprofiler::counters::RawAST**, const char* s)
ROCP_ERROR << s;
}
#line 85 "parser.cpp"
#line 83 "parser.cpp"
#ifndef YY_CAST
# ifdef __cplusplus
@@ -134,13 +134,14 @@ enum yysymbol_kind_t
YYSYMBOL_REDUCE = 21, /* REDUCE */
YYSYMBOL_SELECT = 22, /* SELECT */
YYSYMBOL_ACCUMULATE = 23, /* ACCUMULATE */
YYSYMBOL_LOWER_THAN_ELSE = 24, /* LOWER_THAN_ELSE */
YYSYMBOL_ELSE = 25, /* ELSE */
YYSYMBOL_YYACCEPT = 26, /* $accept */
YYSYMBOL_top = 27, /* top */
YYSYMBOL_exp = 28, /* exp */
YYSYMBOL_reduce_dim_args = 29, /* reduce_dim_args */
YYSYMBOL_select_dim_args = 30 /* select_dim_args */
YYSYMBOL_DIM_ARGS_RANGE = 24, /* DIM_ARGS_RANGE */
YYSYMBOL_LOWER_THAN_ELSE = 25, /* LOWER_THAN_ELSE */
YYSYMBOL_ELSE = 26, /* ELSE */
YYSYMBOL_YYACCEPT = 27, /* $accept */
YYSYMBOL_top = 28, /* top */
YYSYMBOL_exp = 29, /* exp */
YYSYMBOL_reduce_dim_args = 30, /* reduce_dim_args */
YYSYMBOL_select_dim_args = 31 /* select_dim_args */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
@@ -454,19 +455,19 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 13
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 60
#define YYLAST 68
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 26
#define YYNTOKENS 27
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 5
/* YYNRULES -- Number of rules. */
#define YYNRULES 17
#define YYNRULES 19
/* YYNSTATES -- Number of states. */
#define YYNSTATES 50
#define YYNSTATES 56
/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK 279
#define YYMAXUTOK 280
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
@@ -477,22 +478,22 @@ union yyalloc
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */
static const yytype_int8 yytranslate[] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 15, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 15, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int8 yyrline[] =
{0, 58, 58, 61, 62, 63, 64, 65, 66, 67, 70, 75, 79, 83, 90, 93, 100, 103};
static const yytype_int8 yyrline[] = {0, 57, 57, 60, 61, 62, 63, 64, 65, 66,
69, 74, 78, 82, 89, 92, 99, 103, 107, 112};
#endif
/** Accessing symbol of state STATE. */
@@ -530,6 +531,7 @@ static const char* const yytname[] = {"\"end of file\"",
"REDUCE",
"SELECT",
"ACCUMULATE",
"DIM_ARGS_RANGE",
"LOWER_THAN_ELSE",
"ELSE",
"$accept",
@@ -546,7 +548,7 @@ yysymbol_name(yysymbol_kind_t yysymbol)
}
#endif
#define YYPACT_NINF (-10)
#define YYPACT_NINF (-15)
#define yypact_value_is_default(Yyn) ((Yyn) == YYPACT_NINF)
@@ -556,20 +558,20 @@ yysymbol_name(yysymbol_kind_t yysymbol)
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int8 yypact[] = {2, 2, -10, -10, -7, -2, 3, 21, 38, 27, 2, 2, 14,
-10, 2, 2, 2, 2, -10, 0, 23, 18, 13, 13, -10, -10,
16, 28, 25, -9, 26, 37, -10, 39, 30, 36, -10, 29, 33,
42, 40, 41, 43, -10, 29, 44, 26, -10, -10, -10};
static const yytype_int8 yypact[] = {
2, 2, -15, -15, -7, -2, 10, 21, 38, 27, 2, 2, 16, -15, 2, 2, 2, 2, -15,
0, 23, 28, 29, 29, -15, -15, 26, 36, 30, -9, 31, 39, -15, 37, 44, 41, -15, 34,
45, 47, 42, 43, -6, -15, 34, 48, 49, 50, -15, -15, 46, 51, 31, 31, -15, -15};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_int8 yydefact[] = {0, 0, 3, 9, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0,
0, 8, 0, 0, 0, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 11, 0,
0, 0, 10, 0, 0, 0, 14, 0, 16, 13, 0, 0, 0, 15, 12, 17};
static const yytype_int8 yydefact[] = {
0, 0, 3, 9, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 8, 0, 0, 0, 4, 5, 6, 7, 0, 0,
0, 0, 0, 0, 11, 0, 0, 0, 10, 0, 0, 0, 14, 0, 0, 13, 0, 0, 0, 0, 15, 12, 16, 18, 0, 0, 17, 19};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = {-10, -10, -1, 11, 10};
static const yytype_int8 yypgoto[] = {-15, -15, -1, 20, -14};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] = {0, 7, 8, 41, 35};
@@ -578,28 +580,28 @@ static const yytype_int8 yydefgoto[] = {0, 7, 8, 41, 35};
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int8 yytable[] = {
9, 32, 10, 14, 15, 16, 17, 11, 33, 19, 20, 1, 12, 22, 23, 24, 25, 26, 16, 17, 2,
13, 3, 4, 5, 6, 14, 15, 16, 17, 14, 15, 16, 17, 21, 28, 29, 18, 38, 30, 27, 14,
15, 16, 17, 31, 34, 36, 39, 40, 37, 42, 43, 45, 48, 47, 49, 44, 0, 0, 46};
9, 32, 10, 14, 15, 16, 17, 11, 33, 19, 20, 1, 46, 22, 23, 24, 25, 26, 47, 12, 2, 13, 3,
4, 5, 6, 14, 15, 16, 17, 14, 15, 16, 17, 16, 17, 21, 18, 54, 55, 27, 14, 15, 16, 17, 28,
29, 30, 37, 36, 31, 34, 38, 39, 40, 45, 42, 43, 49, 44, 0, 50, 51, 52, 48, 0, 0, 0, 53};
static const yytype_int8 yycheck[] = {1, 10, 9, 3, 4, 5, 6, 9, 17, 10, 11, 9, 9, 14, 15, 16,
17, 17, 5, 6, 18, 0, 20, 21, 22, 23, 3, 4, 5, 6, 3, 4,
5, 6, 20, 17, 20, 10, 8, 11, 17, 3, 4, 5, 6, 20, 20, 10,
12, 20, 11, 18, 10, 12, 10, 44, 46, 17, -1, -1, 17};
static const yytype_int8 yycheck[] = {
1, 10, 9, 3, 4, 5, 6, 9, 17, 10, 11, 9, 18, 14, 15, 16, 17, 17, 24, 9, 18, 0, 20,
21, 22, 23, 3, 4, 5, 6, 3, 4, 5, 6, 5, 6, 20, 10, 52, 53, 17, 3, 4, 5, 6, 17,
20, 11, 11, 10, 20, 20, 8, 12, 20, 12, 11, 10, 10, 17, -1, 12, 12, 17, 44, -1, -1, -1, 17};
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
state STATE-NUM. */
static const yytype_int8 yystos[] = {0, 9, 18, 20, 21, 22, 23, 27, 28, 28, 9, 9, 9,
0, 3, 4, 5, 6, 10, 28, 28, 20, 28, 28, 28, 28,
17, 17, 17, 20, 11, 20, 10, 17, 20, 30, 10, 11, 8,
12, 20, 29, 18, 10, 17, 12, 17, 29, 10, 30};
static const yytype_int8 yystos[] = {0, 9, 18, 20, 21, 22, 23, 28, 29, 29, 9, 9, 9, 0,
3, 4, 5, 6, 10, 29, 29, 20, 29, 29, 29, 29, 17, 17,
17, 20, 11, 20, 10, 17, 20, 31, 10, 11, 8, 12, 20, 30,
11, 10, 17, 12, 18, 24, 30, 10, 12, 12, 17, 17, 31, 31};
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
static const yytype_int8 yyr1[] =
{0, 26, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 30, 30};
static const yytype_int8 yyr1[] = {0, 27, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 30, 30, 31, 31, 31, 31};
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
static const yytype_int8 yyr2[] = {0, 2, 1, 1, 3, 3, 3, 3, 3, 1, 6, 6, 10, 8, 1, 3, 3, 5};
static const yytype_int8 yyr2[] = {0, 2, 1, 1, 3, 3, 3, 3, 3, 1, 6, 6, 10, 8, 1, 3, 5, 7, 5, 7};
enum
{
@@ -1024,143 +1026,163 @@ yyreduce:
switch(yyn)
{
case 2: /* top: exp */
#line 58 "parser.y"
#line 57 "parser.y"
{
*result = (yyvsp[0].a);
}
#line 1122 "parser.cpp"
#line 1204 "parser.cpp"
break;
case 3: /* exp: NUMBER */
#line 61 "parser.y"
#line 60 "parser.y"
{
(yyval.a) = new RawAST(NUMBER_NODE, (yyvsp[0].d));
}
#line 1128 "parser.cpp"
#line 1210 "parser.cpp"
break;
case 4: /* exp: exp ADD exp */
#line 62 "parser.y"
#line 61 "parser.y"
{
(yyval.a) = new RawAST(ADDITION_NODE, {(yyvsp[-2].a), (yyvsp[0].a)});
}
#line 1134 "parser.cpp"
#line 1216 "parser.cpp"
break;
case 5: /* exp: exp SUB exp */
#line 63 "parser.y"
#line 62 "parser.y"
{
(yyval.a) = new RawAST(SUBTRACTION_NODE, {(yyvsp[-2].a), (yyvsp[0].a)});
}
#line 1140 "parser.cpp"
#line 1222 "parser.cpp"
break;
case 6: /* exp: exp MUL exp */
#line 64 "parser.y"
#line 63 "parser.y"
{
(yyval.a) = new RawAST(MULTIPLY_NODE, {(yyvsp[-2].a), (yyvsp[0].a)});
}
#line 1146 "parser.cpp"
#line 1228 "parser.cpp"
break;
case 7: /* exp: exp DIV exp */
#line 65 "parser.y"
#line 64 "parser.y"
{
(yyval.a) = new RawAST(DIVIDE_NODE, {(yyvsp[-2].a), (yyvsp[0].a)});
}
#line 1152 "parser.cpp"
#line 1234 "parser.cpp"
break;
case 8: /* exp: OP exp CP */
#line 66 "parser.y"
#line 65 "parser.y"
{
(yyval.a) = (yyvsp[-1].a);
}
#line 1158 "parser.cpp"
#line 1240 "parser.cpp"
break;
case 9: /* exp: NAME */
#line 67 "parser.y"
#line 66 "parser.y"
{
(yyval.a) = new RawAST(REFERENCE_NODE, (yyvsp[0].s));
free((yyvsp[0].s));
}
#line 1166 "parser.cpp"
#line 1248 "parser.cpp"
break;
case 10: /* exp: ACCUMULATE OP NAME CM NAME CP */
#line 70 "parser.y"
#line 69 "parser.y"
{
(yyval.a) = new RawAST(ACCUMULATE_NODE, (yyvsp[-3].s), (yyvsp[-1].s));
free((yyvsp[-3].s));
free((yyvsp[-1].s));
}
#line 1176 "parser.cpp"
#line 1258 "parser.cpp"
break;
case 11: /* exp: REDUCE OP exp CM NAME CP */
#line 75 "parser.y"
#line 74 "parser.y"
{
(yyval.a) = new RawAST(REDUCE_NODE, (yyvsp[-3].a), (yyvsp[-1].s), NULL);
free((yyvsp[-1].s));
}
#line 1185 "parser.cpp"
#line 1267 "parser.cpp"
break;
case 12: /* exp: REDUCE OP exp CM NAME CM O_SQ reduce_dim_args C_SQ CP */
#line 79 "parser.y"
#line 78 "parser.y"
{
(yyval.a) = new RawAST(REDUCE_NODE, (yyvsp[-7].a), (yyvsp[-5].s), (yyvsp[-2].ll));
free((yyvsp[-5].s));
}
#line 1194 "parser.cpp"
#line 1276 "parser.cpp"
break;
case 13: /* exp: SELECT OP exp CM O_SQ select_dim_args C_SQ CP */
#line 83 "parser.y"
#line 82 "parser.y"
{
(yyval.a) = new RawAST(SELECT_NODE, (yyvsp[-5].a), (yyvsp[-2].ll));
}
#line 1202 "parser.cpp"
#line 1284 "parser.cpp"
break;
case 14: /* reduce_dim_args: NAME */
#line 90 "parser.y"
#line 89 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[0].s), NULL);
free((yyvsp[0].s));
}
#line 1210 "parser.cpp"
#line 1292 "parser.cpp"
break;
case 15: /* reduce_dim_args: NAME CM reduce_dim_args */
#line 93 "parser.y"
#line 92 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-2].s), (yyvsp[0].ll));
free((yyvsp[-2].s));
}
#line 1218 "parser.cpp"
#line 1300 "parser.cpp"
break;
case 16: /* select_dim_args: NAME EQUALS NUMBER */
#line 100 "parser.y"
case 16: /* select_dim_args: NAME EQUALS O_SQ NUMBER C_SQ */
#line 99 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-2].s), (yyvsp[0].d), NULL);
free((yyvsp[-2].s));
}
#line 1226 "parser.cpp"
break;
case 17: /* select_dim_args: NAME EQUALS NUMBER CM select_dim_args */
#line 103 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-4].s), (yyvsp[-2].d), (yyvsp[0].ll));
(yyval.ll) = new LinkedList((yyvsp[-4].s), (yyvsp[-1].d), NULL);
free((yyvsp[-4].s));
}
#line 1234 "parser.cpp"
#line 1309 "parser.cpp"
break;
#line 1238 "parser.cpp"
case 17: /* select_dim_args: NAME EQUALS O_SQ NUMBER C_SQ CM select_dim_args */
#line 103 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-6].s), (yyvsp[-3].d), (yyvsp[0].ll));
free((yyvsp[-6].s));
}
#line 1318 "parser.cpp"
break;
case 18: /* select_dim_args: NAME EQUALS O_SQ DIM_ARGS_RANGE C_SQ */
#line 107 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-4].s), (yyvsp[-1].s), NULL);
free((yyvsp[-4].s));
free((yyvsp[-1].s));
}
#line 1328 "parser.cpp"
break;
case 19: /* select_dim_args: NAME EQUALS O_SQ DIM_ARGS_RANGE C_SQ CM select_dim_args */
#line 112 "parser.y"
{
(yyval.ll) = new LinkedList((yyvsp[-6].s), (yyvsp[-3].s), (yyvsp[0].ll));
free((yyvsp[-6].s));
free((yyvsp[-3].s));
}
#line 1338 "parser.cpp"
break;
#line 1342 "parser.cpp"
default: break;
}
@@ -1334,4 +1356,4 @@ yyreturnlab:
return yyresult;
}
#line 109 "parser.y"
#line 120 "parser.y"
@@ -82,8 +82,9 @@ enum yytokentype
REDUCE = 275, /* REDUCE */
SELECT = 276, /* SELECT */
ACCUMULATE = 277, /* ACCUMULATE */
LOWER_THAN_ELSE = 278, /* LOWER_THAN_ELSE */
ELSE = 279 /* ELSE */
DIM_ARGS_RANGE = 278, /* DIM_ARGS_RANGE */
LOWER_THAN_ELSE = 279, /* LOWER_THAN_ELSE */
ELSE = 280 /* ELSE */
};
typedef enum yytokentype yytoken_kind_t;
#endif
@@ -40,8 +40,9 @@ void yyerror(rocprofiler::counters::RawAST**, const char *s) { ROCP_ERROR << s;
%token NAME /* set data type for variables and user-defined functions */
%token REDUCE SELECT /* set data type for special functions */
%token ACCUMULATE
%token DIM_ARGS_RANGE
%type <a> exp /* set data type for expressions */
%type <s> NAME
%type <s> NAME DIM_ARGS_RANGE
%type <d> NUMBER
%type <ll> reduce_dim_args select_dim_args
@@ -95,12 +96,24 @@ reduce_dim_args: NAME { $$ = new LinkedList($1, NULL);
select_dim_args: NAME EQUALS NUMBER { $$ = new LinkedList($1, $3, NULL);
select_dim_args: NAME EQUALS O_SQ NUMBER C_SQ {
$$ = new LinkedList($1, $4, NULL);
free($1);
}
| NAME EQUALS NUMBER CM select_dim_args { $$ = new LinkedList($1, $3, $5);
| NAME EQUALS O_SQ NUMBER C_SQ CM select_dim_args {
$$ = new LinkedList($1, $4, $7);
free($1);
}
| NAME EQUALS O_SQ DIM_ARGS_RANGE C_SQ {
$$ = new LinkedList($1, $4, NULL);
free($1);
free($4);
}
| NAME EQUALS O_SQ DIM_ARGS_RANGE C_SQ CM select_dim_args {
$$ = new LinkedList($1, $4, $7);
free($1);
free($4);
}
;
@@ -22,6 +22,7 @@
#pragma once
#include "lib/common/logging.hpp"
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/counters/id_decode.hpp"
@@ -68,6 +69,7 @@ struct LinkedList
{
std::string name;
int data{-1};
std::string range_data;
LinkedList* next{nullptr};
LinkedList(const char* v, LinkedList* next_node)
: name(std::string{CHECK_NOTNULL(v)})
@@ -78,6 +80,11 @@ struct LinkedList
, data(d)
, next(next_node)
{}
LinkedList(const char* v, const char* r, LinkedList* next_node)
: name(std::string{CHECK_NOTNULL(v)})
, range_data(std::string{CHECK_NOTNULL(r)})
, next(next_node)
{}
};
struct RawAST
@@ -100,7 +107,7 @@ struct RawAST
std::unordered_set<rocprofiler_profile_counter_instance_types> reduce_dimension_set;
// Dimension set to select certain dimensions from the result
std::unordered_map<rocprofiler_profile_counter_instance_types, int> select_dimension_set;
std::map<rocprofiler_profile_counter_instance_types, std::string> select_dimension_map;
// Range restriction on this node
RawAST* range{nullptr};
@@ -197,8 +204,7 @@ struct RawAST
{
if(dimensions)
{
LinkedList* ptr = dimensions;
while(ptr)
while(dimensions)
{
const rocprofiler_profile_counter_instance_types* dim =
rocprofiler::common::get_val(get_dim_map(), dimensions->name);
@@ -208,9 +214,12 @@ struct RawAST
fmt::format("Unknown Dimension - {}", dimensions->name));
}
select_dimension_set.insert({*dim, ptr->data});
LinkedList* current = ptr;
ptr = ptr->next;
select_dimension_map.insert({*dim,
(dimensions->data != -1)
? std::to_string(dimensions->data)
: dimensions->range_data});
LinkedList* current = dimensions;
dimensions = dimensions->next;
delete current;
}
}
@@ -285,6 +294,38 @@ struct formatter<rocprofiler::counters::RawAST>
out = fmt::format_to(out, " \"Range\":{},", *ast.range);
}
static const std::map<rocprofiler::counters::rocprofiler_profile_counter_instance_types,
std::string>
SelectDimensionTypeToString = {
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_NONE,
"DIMENSION_NONE"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_XCC,
"DIMENSION_XCC"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_AID,
"DIMENSION_AID"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_SHADER_ENGINE,
"DIMENSION_SHADER_ENGINE"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_AGENT,
"DIMENSION_AGENT"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_SHADER_ARRAY,
"DIMENSION_SHADER_ARRAY"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_WGP,
"DIMENSION_WGP"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_INSTANCE,
"DIMENSION_INSTANCE"},
{rocprofiler::counters::rocprofiler_profile_counter_instance_types::
ROCPROFILER_DIMENSION_LAST,
"DIMENSION_LAST"},
};
out = fmt::format_to(out, " \"Counter_Set\":[");
for(const auto& ref : ast.counter_set)
{
@@ -302,15 +343,15 @@ struct formatter<rocprofiler::counters::RawAST>
++ReduceSetIndex == ast.reduce_dimension_set.size() ? "" : ",");
}
out = fmt::format_to(out, "], \"Select_Dimension_Set\":[");
out = fmt::format_to(out, "], \"Select_Dimension_Map\":[");
size_t SelectSetIndex = 0;
for(const auto& [type, val] : ast.select_dimension_set)
for(const auto& [type, val] : ast.select_dimension_map)
{
out = fmt::format_to(out,
"\"{},{}\"{}",
static_cast<int>(type),
"\"{}:\"{}\"\"{}",
SelectDimensionTypeToString.at(type),
val,
++SelectSetIndex == ast.select_dimension_set.size() ? "" : ",");
++SelectSetIndex == ast.select_dimension_map.size() ? "" : ",");
}
return fmt::format_to(out, "]}}");
@@ -1,6 +1,5 @@
#line 2 "scanner.cpp"
#line 4 "scanner.cpp"
#line 3 "scanner.cpp"
#define YY_INT_ALIGNED short int
@@ -388,8 +387,8 @@ yy_fatal_error(const char* msg);
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 23
#define YY_END_OF_BUFFER 24
#define YY_NUM_RULES 24
#define YY_END_OF_BUFFER 25
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -397,10 +396,10 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[58] = {
0, 0, 0, 24, 22, 21, 19, 6, 7, 3, 1, 9, 2, 22, 4, 14, 10, 8, 18, 11,
12, 18, 18, 18, 5, 14, 20, 13, 14, 0, 18, 18, 18, 18, 20, 13, 0, 0, 14, 18,
18, 18, 0, 13, 18, 18, 18, 18, 18, 18, 18, 15, 16, 18, 18, 18, 17, 0};
static const flex_int16_t yy_accept[64] = {
0, 0, 0, 25, 23, 22, 20, 6, 7, 3, 1, 9, 2, 23, 4, 14, 10, 8, 18, 11, 12, 18,
18, 18, 5, 14, 21, 0, 13, 14, 0, 0, 18, 18, 18, 18, 21, 19, 13, 0, 19, 0, 14, 18,
18, 18, 0, 0, 13, 18, 18, 18, 19, 18, 18, 18, 18, 15, 16, 18, 18, 18, 17, 0};
static const YY_CHAR yy_ec[256] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -422,37 +421,37 @@ static const YY_CHAR yy_ec[256] = {
static const YY_CHAR yy_meta[30] = {0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1};
static const flex_int16_t yy_base[60] = {
0, 0, 0, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 68, 68, 20, 82, 82, 0, 82,
82, 58, 55, 54, 82, 19, 0, 21, 28, 39, 0, 55, 53, 50, 0, 33, 45, 60, 59, 42,
41, 46, 55, 54, 41, 44, 43, 34, 39, 32, 33, 0, 0, 34, 20, 17, 0, 82, 31, 57};
static const flex_int16_t yy_base[66] = {
0, 0, 0, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 76, 76, 22, 90, 90, 0, 90, 90, 66,
63, 62, 90, 21, 0, 71, 24, 0, 70, 38, 0, 61, 59, 56, 0, 40, 39, 47, 50, 66, 65, 48,
47, 52, 61, 60, 59, 46, 49, 48, 52, 38, 41, 30, 26, 0, 0, 23, 14, 17, 0, 90, 28, 64};
static const flex_int16_t yy_def[60] = {0, 57, 1, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
57, 57, 57, 58, 57, 57, 58, 58, 58, 57, 57, 59, 57, 57, 57,
58, 58, 58, 58, 59, 57, 57, 57, 57, 58, 58, 58, 57, 57, 58,
58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 0, 57, 57};
static const flex_int16_t yy_def[66] = {
0, 63, 1, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 63, 63, 64,
64, 64, 63, 63, 65, 63, 63, 15, 63, 63, 64, 64, 64, 64, 65, 63, 63, 63, 63, 63, 63, 64,
64, 64, 63, 63, 63, 64, 64, 64, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 63, 63};
static const flex_int16_t yy_nxt[112] = {
static const flex_int16_t yy_nxt[120] = {
0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 18,
18, 18, 18, 18, 22, 23, 18, 18, 24, 27, 25, 28, 35, 30, 29, 29, 36, 27, 56, 28, 29,
29, 36, 29, 35, 37, 55, 37, 36, 29, 38, 42, 54, 42, 36, 53, 43, 34, 52, 34, 51, 50,
49, 48, 47, 43, 43, 46, 45, 44, 38, 38, 41, 40, 39, 33, 32, 31, 26, 25, 57, 3, 57,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
18, 18, 18, 18, 22, 23, 18, 18, 24, 27, 32, 28, 25, 29, 30, 38, 31, 31, 62, 39, 61,
60, 31, 31, 41, 39, 41, 27, 59, 42, 38, 37, 46, 47, 39, 47, 58, 27, 48, 27, 39, 40,
57, 52, 36, 56, 36, 55, 54, 53, 48, 48, 52, 51, 50, 49, 42, 42, 45, 44, 43, 40, 37,
35, 34, 33, 26, 25, 63, 3, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57};
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63};
static const flex_int16_t yy_chk[112] = {
static const flex_int16_t yy_chk[120] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 25, 15, 27, 58, 25, 15, 27, 28, 55, 28, 25,
15, 27, 28, 35, 29, 54, 29, 35, 28, 29, 36, 53, 36, 35, 50, 36, 59, 49, 59, 48, 47,
46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 33, 32, 31, 23, 22, 21, 14, 13, 3, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 64, 15, 25, 15, 15, 28, 25, 15, 61, 28, 60,
59, 25, 15, 31, 28, 31, 37, 56, 31, 38, 37, 37, 39, 38, 39, 55, 40, 39, 52, 38, 40,
54, 52, 65, 53, 65, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 35, 34, 33, 30, 27,
23, 22, 21, 14, 13, 3, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57};
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63};
/* Table of booleans, true if rule could match eol. */
static const flex_int32_t yy_rule_can_match_eol[24] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
static const flex_int32_t yy_rule_can_match_eol[25] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
};
static yy_state_type yy_last_accepting_state;
@@ -477,9 +476,9 @@ char* yytext;
#include "raw_ast.hpp"
using namespace std;
#define YYDEBUG 1
#line 518 "scanner.cpp"
/* float exponent */
#line 520 "scanner.cpp"
/* float exponent */
#line 522 "scanner.cpp"
#define INITIAL 0
@@ -714,7 +713,7 @@ YY_DECL
{
#line 15 "scanner.l"
#line 737 "scanner.cpp"
#line 739 "scanner.cpp"
while(/*CONSTCOND*/ 1) /* loops until end-of-file is reached */
{
@@ -741,11 +740,11 @@ YY_DECL
while(yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
{
yy_current_state = (int) yy_def[yy_current_state];
if(yy_current_state >= 58) yy_c = yy_meta[yy_c];
if(yy_current_state >= 64) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
} while(yy_base[yy_current_state] != 82);
} while(yy_base[yy_current_state] != 90);
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -883,34 +882,41 @@ YY_DECL
return NAME;
}
YY_BREAK
case 19:
/* rule 19 can match eol */
case 19: YY_RULE_SETUP
#line 42 "scanner.l"
{
yylval.s = strdup(yytext);
return DIM_ARGS_RANGE;
}
YY_BREAK
case 20:
/* rule 20 can match eol */
YY_RULE_SETUP
#line 43 "scanner.l"
#line 48 "scanner.l"
{
return EOL;
}
YY_BREAK
case 20: YY_RULE_SETUP
#line 44 "scanner.l"
case 21: YY_RULE_SETUP
#line 49 "scanner.l"
YY_BREAK
case 21: YY_RULE_SETUP
#line 45 "scanner.l"
case 22: YY_RULE_SETUP
#line 50 "scanner.l"
{ /* ignore white space */
}
YY_BREAK
case 22: YY_RULE_SETUP
#line 46 "scanner.l"
case 23: YY_RULE_SETUP
#line 51 "scanner.l"
{
throw std::runtime_error(fmt::format("Mystery character {}", *yytext));
}
YY_BREAK
case 23: YY_RULE_SETUP
#line 47 "scanner.l"
case 24: YY_RULE_SETUP
#line 52 "scanner.l"
YY_FATAL_ERROR("flex scanner jammed");
YY_BREAK
#line 921 "scanner.cpp"
#line 931 "scanner.cpp"
case YY_STATE_EOF(INITIAL): yyterminate();
case YY_END_OF_BUFFER:
@@ -1194,7 +1200,7 @@ yy_get_previous_state(void)
while(yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
{
yy_current_state = (int) yy_def[yy_current_state];
if(yy_current_state >= 58) yy_c = yy_meta[yy_c];
if(yy_current_state >= 64) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
@@ -1222,10 +1228,10 @@ yy_try_NUL_trans(yy_state_type yy_current_state)
while(yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
{
yy_current_state = (int) yy_def[yy_current_state];
if(yy_current_state >= 58) yy_c = yy_meta[yy_c];
if(yy_current_state >= 64) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 57);
yy_is_jam = (yy_current_state == 63);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1871,4 +1877,4 @@ yyfree(void* ptr)
#define YYTABLES_NAME "yytables"
#line 47 "scanner.l"
#line 52 "scanner.l"
@@ -39,10 +39,14 @@ EXP ([Ee][-+]?[0-9]+)
yylval.s = strdup(yytext);
return NAME; }
([0-9]+(:[0-9]+)?)(,[0-9]+(:[0-9]+)?)* {
yylval.s = strdup(yytext);
return DIM_ARGS_RANGE;
}
\n { return EOL; }
"//".*
[ \t] { /* ignore white space */ }
. { throw std::runtime_error(fmt::format("Mystery character {}", *yytext)); }
%%
@@ -37,45 +37,45 @@ TEST(parser, base_ops)
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"AB\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"BA\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}"},
{"AB + BA",
"{\"Type\":\"ADDITION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"AB\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"BA\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}"},
{"CD - ZX",
"{\"Type\":\"SUBTRACTION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"CD\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"ZX\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}"},
{"NM / DB",
"{\"Type\":\"DIVIDE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"NM\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"DB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"}};
"\"Select_Dimension_Map\":[]}"}};
for(auto [op, expected] : expressionToExpected)
{
@@ -99,16 +99,16 @@ TEST(parser, order_of_ops)
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"AB\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"BA\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[],"
" \"Select_Dimension_Set\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
" \"Select_Dimension_Map\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"CD\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}"},
{"(AB / BA) - BN",
"{\"Type\":\"SUBTRACTION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"DIVIDE_NODE\", \"REDUCE_OP\":\"\", "
@@ -116,49 +116,49 @@ TEST(parser, order_of_ops)
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"AB\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"BA\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"BN\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}"},
{"AD / (CD - ZX)",
"{\"Type\":\"DIVIDE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"AD\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"SUBTRACTION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"CD\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REFERENCE_NODE\", "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REFERENCE_NODE\", "
"\"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", \"Value\":\"ZX\", \"Counter_Set\":[], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}"},
{"MN * (NM / DB)",
"{\"Type\":\"MULTIPLY_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"MN\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"DIVIDE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"NM\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},"
"\"Select_Dimension_Map\":[]},"
"{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"DB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"}};
"\"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]}"}};
for(auto [op, expected] : expressionToExpected)
{
@@ -179,8 +179,8 @@ TEST(parser, reduction)
"{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"SUM\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[\"3\",\"1\"], \"Select_Dimension_Set\":[]}"},
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[\"3\",\"1\"], \"Select_Dimension_Map\":[]}"},
{"reduce(AB+CD, SUM, [DIMENSION_XCC,DIMENSION_SHADER_ENGINE])",
"{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"SUM\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"ADDITION_NODE\", \"REDUCE_OP\":\"\", "
@@ -188,12 +188,12 @@ TEST(parser, reduction)
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Value\":\"CD\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[\"3\",\"1\"], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[\"3\",\"1\"], "
"\"Select_Dimension_Map\":[]}"},
{"reduce(AB,DIV, [DIMENSION_XCC,DIMENSION_SHADER_ENGINE])+reduce(DC,SUM, "
"[DIMENSION_XCC,DIMENSION_SHADER_ENGINE])",
"{\"Type\":\"ADDITION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
@@ -201,15 +201,15 @@ TEST(parser, reduction)
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[\"3\",\"1\"], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"SUM\", "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"SUM\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"DC\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[\"3\",\"1\"], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}"}};
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[\"3\",\"1\"], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}"}};
for(auto [op, expected] : expressionToExpected)
{
@@ -223,36 +223,43 @@ TEST(parser, reduction)
}
}
TEST(parser, DISABLED_selection)
TEST(parser, selection)
{
std::map<std::string, std::string> expressionToExpected = {
{"select(AB, [SE=1,XCC=0])+select(DC,[SE=2])",
{"select(AB, "
"[DIMENSION_SHADER_ENGINE=[1:5,7:9],DIMENSION_XCC=[0,2:4,8]])+select(DC,[DIMENSION_SHADER_"
"ENGINE=[1:3,6,8]])",
"{\"Type\":\"ADDITION_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"SELECT_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[\"(\"XCC\", 0)\",\"(\"SE\", "
"1)\"]},{\"Type\":\"SELECT_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[\"DIMENSION_XCC:\"0,2:4,8\"\",\"DIMENSION_SHADER_ENGINE:\"1:5,"
"7:9\"\"]},"
"{\"Type\":\"SELECT_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"DC\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[\"(\"SE\", 2)\"]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}"},
{"select(AB, [SE=2,XCC=1,WGP=3])",
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[\"DIMENSION_SHADER_ENGINE:\"1:3,6,8\"\"]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}"},
{"select(AB, [DIMENSION_SHADER_ENGINE=[2],DIMENSION_XCC=[1,4],DIMENSION_WGP=[3:5]])",
"{\"Type\":\"SELECT_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[\"(\"WGP\", 3)\",\"(\"XCC\", "
"1)\",\"(\"SE\", 2)\"]}"},
{"select(AB, [XCC=0])",
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[\"DIMENSION_XCC:\"1,4\"\",\"DIMENSION_SHADER_ENGINE:\"2\"\","
"\"DIMENSION_WGP:\"3:5\"\"]}"},
{"select(AB, [DIMENSION_XCC=[0,3:6,9,11:13]])",
"{\"Type\":\"SELECT_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"AB\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[\"(\"XCC\", 0)\"]}"}};
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[\"DIMENSION_XCC:\"0,3:6,9,11:13\"\"]}"}};
for(auto [op, expected] : expressionToExpected)
{
@@ -292,17 +299,17 @@ TEST(parser, parse_accum_counter)
{"accumulate(SQ_WAVES,NONE)",
"{\"Type\":\"ACCUMULATE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", \"Value\""
":\"SQ_WAVES\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}"},
{"accumulate(SQ_WAVES,HIGH_RES)",
"{\"Type\":\"ACCUMULATE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"HIGH_RES\", "
"\"Value"
"\":\"SQ_WAVES\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"},
"\"Select_Dimension_Map\":[]}"},
{"accumulate(SQ_WAVES,LOW_RES)",
"{\"Type\":\"ACCUMULATE_NODE\", \"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"LOW_RES\", "
"\"Value\""
":\"SQ_WAVES\", \"Counter_Set\":[], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"}};
"\"Select_Dimension_Map\":[]}"}};
for(auto [op, expected] : expressionToExpected)
{
@@ -327,16 +334,16 @@ TEST(parser, parse_nested_accum_counter)
"\"REDUCE_OP\":\"sum\", \"ACCUMULATE_OP\":\"NONE\", "
"\"Counter_Set\":[{\"Type\":\"ACCUMULATE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"HIGH_RES\", \"Value\":\"SQ_LEVEL_WAVES\", \"Counter_Set\":[], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"max\", "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REDUCE_NODE\", \"REDUCE_OP\":\"max\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Counter_Set\":[{\"Type\":\"REFERENCE_NODE\", "
"\"REDUCE_OP\":\"\", \"ACCUMULATE_OP\":\"NONE\", \"Value\":\"GRBM_GUI_ACTIVE\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"Counter_Set\":[], \"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]},{\"Type\":\"REFERENCE_NODE\", \"REDUCE_OP\":\"\", "
"\"ACCUMULATE_OP\":\"NONE\", \"Value\":\"CU_NUM\", \"Counter_Set\":[], "
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Set\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Set\":[]}"}};
"\"Reduce_Dimension_Set\":[], \"Select_Dimension_Map\":[]}], \"Reduce_Dimension_Set\":[], "
"\"Select_Dimension_Map\":[]}"}};
for(auto [op, expected] : expressionToExpected)
{