2 * validate_power.c - validate PowerPC event tables + encodings
4 * Copyright (c) 2012 Google, Inc
5 * Contributed by Stephane Eranian <eranian@gmail.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #include <sys/types.h>
34 #include <perfmon/pfmlib.h>
36 #define MAX_ENCODING 1
38 #define SRC_LINE .line = __LINE__
43 uint64_t codes[MAX_ENCODING];
47 static const test_event_t ppc_test_events[]={
49 .name = "ppc970::PM_CYC",
53 .fstr = "ppc970::PM_CYC",
56 .name = "ppc970::PM_INST_DISP",
60 .fstr = "ppc970::PM_INST_DISP",
63 .name = "ppc970mp::PM_CYC",
67 .fstr = "ppc970mp::PM_CYC",
70 .name = "ppc970mp::PM_INST_DISP",
74 .fstr = "ppc970mp::PM_INST_DISP",
77 .name = "power4::PM_CYC",
81 .fstr = "power4::PM_CYC",
84 .name = "power4::PM_INST_DISP",
88 .fstr = "power4::PM_INST_DISP",
91 .name = "power5::PM_CYC",
95 .fstr = "power5::PM_CYC",
98 .name = "power5::PM_INST_DISP",
101 .codes[0] = 0x300009,
102 .fstr = "power5::PM_INST_DISP",
105 .name = "power5p::PM_CYC",
109 .fstr = "power5p::PM_CYC",
112 .name = "power5p::PM_INST_DISP",
115 .codes[0] = 0x300009,
116 .fstr = "power5p::PM_INST_DISP",
119 .name = "power6::PM_INST_CMPL",
123 .fstr = "power6::PM_INST_CMPL",
126 .name = "power6::PM_THRD_CONC_RUN_INST",
129 .codes[0] = 0x300026,
130 .fstr = "power6::PM_THRD_CONC_RUN_INST",
133 .name = "power7::PM_CYC",
137 .fstr = "power7::PM_CYC",
140 .name = "power7::PM_INST_DISP",
144 .fstr = "power7::PM_INST_DISP",
147 .name = "power8::PM_L1MISS_LAT_EXC_1024",
150 .codes[0] = 0x67200301eaull,
151 .fstr = "power8::PM_L1MISS_LAT_EXC_1024",
154 .name = "power8::PM_RC_LIFETIME_EXC_32",
157 .codes[0] = 0xde200201e6ull,
158 .fstr = "power8::PM_RC_LIFETIME_EXC_32",
161 #define NUM_TEST_EVENTS (int)(sizeof(ppc_test_events)/sizeof(test_event_t))
163 static int check_test_events(FILE *fp)
165 const test_event_t *e;
171 for (i = 0, e = ppc_test_events; i < NUM_TEST_EVENTS; i++, e++) {
175 ret = pfm_get_event_encoding(e->name, PFM_PLM0 | PFM_PLM3, &fstr, NULL, &codes, &count);
177 fprintf(fp,"Event%d %s, ret=%s(%d) expected %s(%d)\n", i, e->name, pfm_strerror(ret), ret, pfm_strerror(e->ret), e->ret);
180 if (ret != PFM_SUCCESS) {
182 fprintf(fp,"Event%d %s, expected fstr NULL but it is not\n", i, e->name);
186 fprintf(fp,"Event%d %s, expected count=0 instead of %d\n", i, e->name, count);
190 fprintf(fp,"Event%d %s, expected codes[] NULL but it is not\n", i, e->name);
194 if (count != e->count) {
195 fprintf(fp,"Event%d %s, count=%d expected %d\n", i, e->name, count, e->count);
198 for (j=0; j < count; j++) {
199 if (codes[j] != e->codes[j]) {
200 fprintf(fp,"Event%d %s, codes[%d]=%#"PRIx64" expected %#"PRIx64"\n", i, e->name, j, codes[j], e->codes[j]);
204 if (e->fstr && strcmp(fstr, e->fstr)) {
205 fprintf(fp,"Event%d %s, fstr=%s expected %s\n", i, e->name, fstr, e->fstr);
215 printf("\t %d PowerPC events: %d errors\n", i, errors);
220 validate_arch(FILE *fp)
222 return check_test_events(fp);