Create a RdmaMessage according to the pre-defined format Args: rm: the message structure Returns: message in string format
| 1275 | // Returns: |
| 1276 | // message in string format |
| 1277 | string RdmaMessage::CreateMessage(const RdmaMessage& rm) { |
| 1278 | // Rdma Message format |
| 1279 | // type|name_size|name|step_id|request_index|remote_addr|rkey|is_dead|... |
| 1280 | // 1B| 2B | 512| 8B | 8B | 8B | 4B | 1B |... |
| 1281 | // ...|data_type|tensor_shape|tensor_bytes|error_status | |
| 1282 | // ...| XB | XB | 8B |size - 4B, proto - XB | |
| 1283 | // |
| 1284 | // ACK: Imm-type: ACK |
| 1285 | // TENSOR_REQUEST: Imm-type: MESSAGE |
| 1286 | // Fields: type, request_index, name, step_id, remote_addr, |
| 1287 | // rkey, is_dead, data_type, tensor_shape, tensor_bytes |
| 1288 | // META_DATA_UPDATE: Imm-type: MESSAGE |
| 1289 | // Fields: type, request_index, is_dead, data_type, |
| 1290 | // tensor_shape, tensor_bytes |
| 1291 | // TENSOR_RE_REQUST: Imm-type: MESSAGE |
| 1292 | // Fields: type, request_index, name, step_id, remote_addr, |
| 1293 | // rkey, is_dead, data_type, tensor_shape, tensor_bytes |
| 1294 | // ERROR_STATUS: Imm-type: MESSAGE |
| 1295 | // Fields: type, request_index, name, step_id, error_status |
| 1296 | // Tensor content: Imm-type: request_index |
| 1297 | size_t message_size = kMessageTotalBytes; |
| 1298 | char message[kMessageTotalBytes + kErrorStatusMaxSize]; |
| 1299 | // type |
| 1300 | message[kTypeStartIndex] = static_cast<char>(rm.type_) & 0xff; |
| 1301 | // request index |
| 1302 | memcpy(&message[kRequestIndexStartIndex], &rm.request_index_, |
| 1303 | sizeof(rm.request_index_)); |
| 1304 | // name, step_id, remote_addr, rkey |
| 1305 | if ((rm.type_ == RDMA_MESSAGE_TENSOR_REQUEST) || |
| 1306 | (rm.type_ == RDMA_MESSAGE_TENSOR_RE_REQUEST)) { |
| 1307 | memcpy(&message[kNameSizeStartIndex], &rm.name_size_, |
| 1308 | sizeof(rm.name_size_)); |
| 1309 | memcpy(&message[kNameStartIndex], rm.name_.data(), rm.name_.size()); |
| 1310 | memcpy(&message[kRemoteAddrStartIndex], &rm.remote_addr_, |
| 1311 | sizeof(rm.remote_addr_)); |
| 1312 | memcpy(&message[kRkeyStartIndex], &rm.rkey_, sizeof(rm.rkey_)); |
| 1313 | memcpy(&message[kStepIdStartIndex], &rm.step_id_, sizeof(rm.step_id_)); |
| 1314 | } |
| 1315 | // is_dead, data_type, tensor_shape, tensor_bytes |
| 1316 | if ((rm.type_ == RDMA_MESSAGE_TENSOR_REQUEST) || |
| 1317 | (rm.type_ == RDMA_MESSAGE_META_DATA_UPDATE) || |
| 1318 | (rm.type_ == RDMA_MESSAGE_TENSOR_RE_REQUEST)) { |
| 1319 | memcpy(&message[kIsDeadStartIndex], &rm.is_dead_, sizeof(rm.is_dead_)); |
| 1320 | |
| 1321 | memcpy(&message[kDataTypeStartIndex], &rm.data_type_, |
| 1322 | sizeof(rm.data_type_)); |
| 1323 | memcpy(&message[kTensorShapeStartIndex], &rm.tensor_shape_, |
| 1324 | sizeof(rm.tensor_shape_)); |
| 1325 | memcpy(&message[kTensorBytesStartIndex], &rm.tensor_bytes_, |
| 1326 | sizeof(rm.tensor_bytes_)); |
| 1327 | } |
| 1328 | // checksum |
| 1329 | #ifdef RDMA_DATA_VALIDATION |
| 1330 | memcpy(&message[kChecksumStartIndex], &rm.checksum_, sizeof(rm.checksum_)); |
| 1331 | #endif |
| 1332 | // error status |
| 1333 | if (rm.type_ == RDMA_MESSAGE_ERROR_STATUS) { |
| 1334 | ::grpc::Status gs = ToGrpcStatus(rm.status_); |
nothing calls this directly
no test coverage detected