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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Ben Widawsky <ben@bwidawsk.net>
*
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "intel_io.h"
#include "intel_chipset.h"
struct eu_rdata {
union {
struct {
uint8_t sendc_dep : 1;
uint8_t swh_dep : 1;
uint8_t pwc_dep : 1;
uint8_t n2_dep : 1;
uint8_t n1_dep : 1;
uint8_t n0_dep : 1;
uint8_t flag1_dep : 1;
uint8_t flag0_dep : 1;
uint8_t indx_dep : 1;
uint8_t mrf_dep : 1;
uint8_t dst_dep : 1;
uint8_t src2_dep : 1;
uint8_t src1_dep : 1;
uint8_t src0_dep : 1;
uint8_t mp_dep_pin : 1;
uint8_t sp_dep_pin : 1;
uint8_t fftid : 8;
uint8_t ffid : 4;
uint8_t instruction_valid : 1;
uint8_t thread_status : 3;
};
uint32_t dword;
} ud0;
union {
struct {
uint8_t mrf_addr : 4;
uint8_t dst_addr : 7;
uint8_t src2_addr : 7;
uint8_t src1_addr : 7;
uint8_t src0_addr : 7;
};
uint32_t dword;
} ud1;
union {
struct {
uint16_t exip : 12;
uint8_t opcode : 7;
uint8_t pwc : 8;
uint8_t instruction_valid : 1;
uint8_t mbz : 4;
};
uint32_t dword;
} ud2;
};
const char *thread_status[] =
{"INVALID", "invalid/no thread", "standby (dependency)", "INVALID", "Executing",
"INVALID" , "INVALID" , "INVALID"};
static struct eu_rdata
collect_rdata(int eu, int tid) {
struct eu_rdata rdata;
intel_register_write(0x7800, eu << 16 | (3 * tid) << 8);
rdata.ud0.dword = intel_register_read(0x7840);
intel_register_write(0x7800, eu << 16 | (3 * tid + 1) << 8);
rdata.ud1.dword = intel_register_read(0x7840);
intel_register_write(0x7800, eu << 16 | (3 * tid + 2) << 8);
rdata.ud2.dword = intel_register_read(0x7840);
return rdata;
}
static void
print_rdata(struct eu_rdata rdata) {
printf("\t%s\n", thread_status[rdata.ud0.thread_status]);
printf("\tn1_dep: %d\n", rdata.ud0.n1_dep);
printf("\tpwc_dep: %d\n", rdata.ud0.pwc_dep);
printf("\tswh_dep: %d\n", rdata.ud0.swh_dep);
printf("\tsource 0 %x\n", rdata.ud1.src0_addr);
printf("\tsource 1 %x\n", rdata.ud1.src1_addr);
printf("\tsource 2 %x\n", rdata.ud1.src2_addr);
printf("\tdest %x\n", rdata.ud1.dst_addr);
printf("\tmrf %x\n", rdata.ud1.mrf_addr);
printf("\tIP: %x\n", rdata.ud2.exip);
printf("\topcode: %x\n", rdata.ud2.opcode);
}
static void
find_stuck_threads(void)
{
int i, j;
for (i = 0; i < 15; i++)
for (j = 0; j < 5; j++) {
struct eu_rdata rdata;
rdata = collect_rdata(i, j);
if (rdata.ud0.thread_status == 2 ||
rdata.ud0.thread_status == 4) {
printf("%d %d:\n", i, j);
print_rdata(rdata);
}
}
}
int main(int argc, char *argv[]) {
struct pci_device *pci_dev;
pci_dev = intel_get_pci_device();
intel_register_access_init(pci_dev, 1);
find_stuck_threads();
// collect_rdata(atoi(argv[1]), atoi(argv[2]));
return 0;
}
|