From e98fd89437b4fa004f2df6de4712b5845e03dd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=8F=E5=90=8D=E9=A6=99?= Date: Tue, 28 Mar 2023 09:45:35 +0800 Subject: [PATCH] =?UTF-8?q?mbuf=E5=86=85=E5=AD=98=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tf_adapter/kernels/aicpu/host_queue_dataset_op.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc b/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc index b46c6e0e8..070404811 100644 --- a/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc +++ b/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc @@ -597,14 +597,15 @@ class HostQueueDatasetOp : public DatasetOpKernel { ADP_LOG(INFO) << "Slave SendDataThread exit."; } - void RecordMbufQueueBytes(const bool is_hold_type, const uint64_t args_total_bytes) { - if (!is_hold_type) { return; } + void RecordMbufQueueBytes(const bool is_hold, const uint64_t args_total_bytes) { + if (!is_hold) { return; } mbuf_queue_rear_ = (mbuf_queue_rear_ + 1) % kStringTypeDepth; + mbuf_queue_total_bytes_ = mbuf_queue_total_bytes_ - mbuf_queue_bytes_[mbuf_queue_rear_] + args_total_bytes; mbuf_queue_bytes_[mbuf_queue_rear_] = args_total_bytes; } bool IsHoldDataTrans() { - if (!is_hold_type) { return false; } + if (mbuf_queue_total_bytes_ < static_cast(kMaxBytes)) { return false; } size_t mbuf_size; aclError status = acltdtQueryChannelSize(acl_handle_, &mbuf_size); if (status != ACL_SUCCESS) { @@ -629,7 +630,7 @@ class HostQueueDatasetOp : public DatasetOpKernel { Status status = Status::OK(); bool is_need_resend = false; - while(!finish_send_) { + while (!finish_send_) { if (IsHoldDataTrans()) { auto start = std::chrono::high_resolution_clock::now(); auto end = start + std::chrono::microseconds(kSleepDuration); @@ -1039,7 +1040,8 @@ class HostQueueDatasetOp : public DatasetOpKernel { double elapsed_time = 0; uint64_t total_bytes = 0; } data_thread_perf_stat_[static_cast(ThreadType::BUTT)]; - uint64_t mbuf_queue_bytes_[kStringTypeDepth]; + uint64_t mbuf_queue_bytes_[kStringTypeDepth] = { 0 }; + uint64_t mbuf_queue_total_bytes_ = 0; size_t mbuf_queue_rear_ = 0; }; const std::vector inputs_; -- Gitee