Debian Codegraph @

visa/iga/IGALibrary/Backend/GED/GEDUtil.cpp

raw
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2017-2021 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8
9 #include "GEDUtil.hpp"
10 #include "GEDToIGATranslation.hpp"
11 #include "IGAToGEDTranslation.hpp"
12
13 #include "../../bits.hpp"
14
15 using namespace iga;
16
17 static const GED_RETURN_VALUE
18 constructPartialGEDSendInstruction(ged_ins_t *ins, GED_MODEL gedP,
19 GED_OPCODE op, bool supportsExMsgDesc,
20 uint32_t exMsgDesc, uint32_t msgDesc) {
21 GED_RETURN_VALUE status = GED_InitEmptyIns(gedP, ins, op);
22
23 status = GED_SetExecSize(ins, 16);
24
25 if (supportsExMsgDesc && status == GED_RETURN_VALUE_SUCCESS) {
26 status = GED_SetExDescRegFile(ins, GED_REG_FILE_IMM);
27 }
28
29 if (status == GED_RETURN_VALUE_SUCCESS) {
30 status = GED_SetExMsgDescImm(ins, exMsgDesc);
31 }
32
33 if (status == GED_RETURN_VALUE_SUCCESS) {
34 status = GED_SetDescRegFile(ins, GED_REG_FILE_IMM);
35 }
36
37 if (status == GED_RETURN_VALUE_SUCCESS) {
38 status = GED_SetMsgDesc(ins, msgDesc);
39 }
40 return status;
41 }
42
43 iga::SFMessageType iga::getMessageType(Platform p, SFID sfid, uint32_t desc) {
44 GED_SFID gedSFID = lowerSFID(sfid);
45
46 GED_RETURN_VALUE getRetVal = GED_RETURN_VALUE_INVALID_FIELD;
47 GED_MESSAGE_TYPE msgType = GED_MESSAGE_TYPE_INVALID;
48 GED_MODEL gedP = lowerPlatform(p);
49
50 if (p >= Platform::XE2) {
51 // The message table looks wrong and is outdated as of XE2
52 return iga::SFMessageType::INVALID;
53 }
54
55 if (gedSFID != GED_SFID_INVALID && gedSFID != GED_SFID_NULL) {
56 switch (gedSFID) {
57 case GED_SFID_SAMPLER: ///< all
58 msgType = GED_GetMessageTypeDP_SAMPLER(desc, gedP, &getRetVal);
59 break;
60 case GED_SFID_GATEWAY: ///< all
61 break;
62 /// includes: GEN11
63 case GED_SFID_DP_DC2: ///< GEN10, GEN9
64 msgType = GED_GetMessageTypeDP_DC2(desc, gedP, &getRetVal);
65 break;
66 case GED_SFID_DP_RC: ///< all
67 msgType = GED_GetMessageTypeDP_RC(desc, gedP, &getRetVal);
68 break;
69 case GED_SFID_URB: ///< all
70 break;
71 case GED_SFID_SPAWNER: ///< all
72 break;
73 case GED_SFID_VME: ///< all
74 break;
75 /// includes: GEN11
76 case GED_SFID_DP_DCRO: ///< GEN10, GEN9
77 msgType = GED_GetMessageTypeDP_DCRO(desc, gedP, &getRetVal);
78 break;
79 case GED_SFID_DP_DC0: ///< all
80 if (p <= iga::Platform::GEN7P5) {
81 // IVB,HSW
82 msgType = GED_GetMessageTypeDP_DC0(desc, gedP, &getRetVal);
83 } else {
84 // Starting with BDW
85 if (GED_GetMessageTypeDP0Category(desc, gedP, &getRetVal) == 0) {
86 msgType = GED_GetMessageTypeDP_DC0Legacy(desc, gedP, &getRetVal);
87 } else {
88 msgType =
89 GED_GetMessageTypeDP_DC0ScratchBlock(desc, gedP, &getRetVal);
90 }
91 }
92 break;
93 case GED_SFID_PI: ///< all
94 break;
95 /// includes: GEN11
96 case GED_SFID_DP_DC1: ///< GEN10, GEN7.5, GEN8, GEN8.1, GEN9
97 msgType = GED_GetMessageTypeDP_DC1(desc, gedP, &getRetVal);
98 break;
99 /// includes: GEN11
100 case GED_SFID_CRE: ///< GEN10, GEN7.5, GEN8, GEN8.1, GEN9
101 break;
102 case GED_SFID_DP_SAMPLER: ///< GEN7, GEN7.5, GEN8, GEN8.1
103 msgType = GED_GetMessageTypeDP_SAMPLER(desc, gedP, &getRetVal);
104 break;
105 case GED_SFID_DP_CC: ///< GEN7, GEN7.5, GEN8, GEN8.1
106 msgType = GED_GetMessageTypeDP_CC(desc, gedP, &getRetVal);
107 break;
108 default:
109 break;
110 }
111 }
112
113 if (msgType == GED_MESSAGE_TYPE_INVALID ||
114 getRetVal != GED_RETURN_VALUE_SUCCESS) {
115 return SFMessageType::INVALID;
116 } else {
117 return translate(msgType);
118 }
119 }
120
121 static uint32_t getSplitSendMsgLength(uint32_t exDesc) {
122 return getBits<uint32_t>(exDesc, 6, 4);
123 }
124
125 uint32_t iga::getMessageLengths(Platform p, const OpSpec &os, uint32_t exDesc,
126 uint32_t desc, uint32_t *mLen, uint32_t *emLen,
127 uint32_t *rLen) {
128 GED_MODEL gedP = lowerPlatform(p);
129 GED_OPCODE gedOp = GED_OPCODE_INVALID;
130 if (os.isSendFormat()) {
131 gedOp = GED_OPCODE_send;
132 } else if (os.isSendsFormat()) {
133 gedOp = GED_OPCODE_sends;
134 }
135
136 if (gedOp == GED_OPCODE_INVALID)
137 return 0;
138
139 ged_ins_t gedInst;
140 auto getRetVal = constructPartialGEDSendInstruction(
141 &gedInst, gedP, gedOp, os.isSendsFormat(), exDesc, desc);
142
143 const uint32_t INVALID =
144 ((uint32_t)0xFFFFFFFFF); // TODO: include macro in iga.h?
145
146 uint32_t n = 0; // count successes
147
148 *mLen = GED_GetMessageLength(desc, gedP, &getRetVal);
149 if (getRetVal != GED_RETURN_VALUE_SUCCESS) { // TODO: what do I do if return
150 // is not success?
151 *mLen = INVALID;
152 } else
153 n++;
154
155 if (os.isSendsFormat()) {
156 *emLen = GED_GetExMsgLength(&gedInst, &getRetVal);
157 if (getRetVal != GED_RETURN_VALUE_SUCCESS) {
158 *emLen = getSplitSendMsgLength(exDesc);
159 }
160 n++;
161 }
162
163 *rLen = GED_GetResponseLength(desc, gedP, &getRetVal);
164 if (getRetVal != GED_RETURN_VALUE_SUCCESS) { // TODO: what do I do if return
165 // is not success?
166 *rLen = INVALID;
167 } else
168 n++;
169
170 return n;
171 }