Browse Source

fix

pull/1865/head
guopeian 4 years ago
parent
commit
6cd943b412
1 changed files with 47 additions and 30 deletions
  1. +47
    -30
      ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc

+ 47
- 30
ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc View File

@@ -728,38 +728,55 @@ Status AicpuNodeTask::SetMemCopyTask(const domi::TaskDef &task_def) {
} }


GELOGD("Start to set memcpy task for node[%s].", node_name_.c_str()); GELOGD("Start to set memcpy task for node[%s].", node_name_.c_str());
const domi::KernelExDef &kernel_def = task_def.kernel_ex();
if (kernel_def.args_size() > sizeof(STR_FWK_OP_KERNEL)) {
GELOGE(PARAM_INVALID, "[Check][Size]sizeof STR_FWK_OP_KERNEL is:%lu, but args_size:%d is bigger",
sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size());
REPORT_INNER_ERROR("E19999", "sizeof STR_FWK_OP_KERNEL is:%lu, but args_size:%d is bigger.",
sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size());
return PARAM_INVALID;
}
STR_FWK_OP_KERNEL aicpu_task = {0};
auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL),
kernel_def.args().data(), kernel_def.args_size());
if (sec_ret != EOK) {
GELOGE(FAILED, "[Update][aicpu_task] failed, ret: %d", sec_ret);
REPORT_CALL_ERROR("E19999", "update aicpu_task failed, ret: %d.", sec_ret);
return FAILED;
}

GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_def.task_info_size(), copy_workspace_buf_),
"[Alloc][TensorBuffer] for Node[%s] to copy task workspace buf, size=%u.",
node_name_.c_str(), kernel_def.task_info_size());

GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_->GetData(), kernel_def.task_info_size(),
kernel_def.task_info().data(), kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE));
const domi::KernelDef &kernel_def = task_def.kernel();
auto &memcpy_args = kernel_def.args();
uint32_t memcpy_args_size = kernel_def.args_size();
GE_IF_BOOL_EXEC(memcpy_args.size() != memcpy_args_size,
REPORT_INNER_ERROR("E19999", "MemCopy task def args.size=%zu, but args_size=%u not equal.",
memcpy_args.size(), memcpy_args_size);
GELOGE(FAILED, "[Check][Size]MemCopy task def args.size=%zu, but args_size=%u not equal.",
memcpy_args.size(), memcpy_args_size);
return FAILED;);
GE_IF_BOOL_EXEC(memcpy_args_size < sizeof(aicpu::AicpuParamHead),
REPORT_INNER_ERROR("E19999",
"Task def args_size=%u is less than aicpu param head len=%zu.",
memcpy_args_size, sizeof(aicpu::AicpuParamHead));
GELOGE(FAILED,
"[Check][Size] Task def args_size=%u is less than aicpu param head len=%zu.",
memcpy_args_size, sizeof(aicpu::AicpuParamHead));
return FAILED;);


aicpu_task.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast<uintptr_t>(copy_ioaddr_dev_->GetData());
aicpu_task.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast<uintptr_t>(copy_workspace_buf_->GetData());
aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0;
aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0;
std::unique_ptr<uint8_t[]> memcpy_task;
memcpy_task.reset(new(std::nothrow) uint8_t[memcpy_args_size]());
GE_IF_BOOL_EXEC(memcpy_task == nullptr,
REPORT_INNER_ERROR("E19999", "new memory failed for Node[MemCopy], task_size[%u].",
memcpy_args_size);
GELOGE(FAILED, "[Malloc][Memory] failed for Node[MemCopy], task_size[%u].",
memcpy_args_size);
return FAILED;);


GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL),
&aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE));
GELOGD("Set memcpy task for node[%s] successfully.", node_name_.c_str());
errno_t sec_ret = memcpy_s(memcpy_task.get(), memcpy_args_size, memcpy_args.c_str(), memcpy_args.size());
GE_IF_BOOL_EXEC(sec_ret != EOK,
REPORT_INNER_ERROR("E19999",
"memcpy_s argc_ failed for Node[MemCopy], ret: %d", sec_ret);
GELOGE(INTERNAL_ERROR,
"[Update][args] failed for Node[MemCopy], ret: %d", sec_ret);
return sec_ret;);
auto memcpy_param_head = reinterpret_cast<aicpu::AicpuParamHead *>(memcpy_task.get());
uint32_t memcpy_io_num = memcpy_param_head->ioAddrNum;
auto memcpy_io_addr = memcpy_task.get() + sizeof(aicpu::AicpuParamHead);
// if has input and output, need copy to ioaddr
int cpy_ret = memcpy_s(memcpy_io_addr, memcpy_args_size - sizeof(aicpu::AicpuParamHead),
&copy_ioaddr_dev_, sizeof(uint64_t) * memcpy_io_num);
GE_IF_BOOL_EXEC(cpy_ret != 0,
REPORT_INNER_ERROR("E19999", "Node[Memcpoy] memcpy io addr to AicpuParamHead failed,"
"ret=%d, args_size=%u, io nums=%zu.",
cpy_ret, memcpy_args_size, memcpy_io_num);
GELOGE(INTERNAL_ERROR, "[Update][io_addr]Node[MemCopy] memcpy io addr to AicpuParamHead failed,"
"ret=%d, args_size=%u, io nums=%zu.",
cpy_ret, memcpy_args_size, memcpy_io_num);
return INTERNAL_ERROR;);
GELOGD("Set memcpy task for node[MemCopy] successfully.");
return SUCCESS; return SUCCESS;
} }




Loading…
Cancel
Save