Skip to content

Commit

Permalink
CR-1082655:Added support for device buffer to device buffer copy in x…
Browse files Browse the repository at this point in the history
…clCopyBO in sw and hw emu 2020.2 (#4432)
  • Loading branch information
vboggara-xilinx authored Nov 11, 2020
1 parent 8349372 commit f19a872
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1359,22 +1359,33 @@ int CpuemShim::xclCopyBO(unsigned int dst_boHandle, unsigned int src_boHandle, s
return -1;
}
}
else {
if (dBO->fd < 0)
{
std::cout << "bo is not exported for copying" << std::endl;
else if (!xclemulation::xocl_bo_host_only(sBO) && !xclemulation::xocl_bo_host_only(dBO) && (dBO->fd < 0) && (sBO->fd < 0)) {
unsigned char temp_buffer[size];
// copy data from source buffer to temp buffer
if (xclCopyBufferDevice2Host((void*)temp_buffer, sBO->base, size, src_offset) != size) {
std::cerr << "ERROR: copy buffer from device to host failed " << std::endl;
return -1;
}
// copy data from temp buffer to destination buffer
if (xclCopyBufferHost2Device(dBO->base, (void*)temp_buffer, size, dst_offset) != size) {
std::cerr << "ERROR: copy buffer from host to device failed " << std::endl;
return -1;
}
}
else if (dBO->fd >= 0) {
int ack = false;
auto fItr = mFdToFileNameMap.find(dBO->fd);
if (fItr != mFdToFileNameMap.end())
{
if (fItr != mFdToFileNameMap.end()) {
const std::string& sFileName = std::get<0>((*fItr).second);
xclCopyBO_RPC_CALL(xclCopyBO, sBO->base, sFileName, size, src_offset, dst_offset);
}
if (!ack)
return -1;
}
else {
std::cerr << "ERROR: Copy buffer from source to destination faliled" << std::endl;
return -1;
}

PRINTENDFUNC;
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2622,12 +2622,21 @@ int HwEmShim::xclCopyBO(unsigned int dst_boHandle, unsigned int src_boHandle, si
if (xclCopyBufferDevice2Host((void*)host_only_buffer, sBO->base, size, src_offset, sBO->topology) != size) {
return -1;
}
}
else {
if (dBO->fd < 0) {
std::cout << "bo is not exported for copying" << std::endl;
}// source and destination buffers are device_only
else if (!xclemulation::xocl_bo_host_only(sBO) && !xclemulation::xocl_bo_host_only(dBO) && (dBO->fd < 0) && (sBO->fd < 0)) {
unsigned char temp_buffer[size];
// copy data from source buffer to temp buffer
if (xclCopyBufferDevice2Host((void*)temp_buffer, sBO->base, size, src_offset, sBO->topology) != size) {
std::cerr << "ERROR: copy buffer from device to host failed " << std::endl;
return -1;
}
// copy data from temp buffer to destination buffer
if (xclCopyBufferHost2Device(dBO->base, (void*)temp_buffer, size, dst_offset, dBO->topology) != size) {
std::cerr << "ERROR: copy buffer from host to device failed " << std::endl;
return -1;
}
}
else if(dBO->fd >= 0){ //destination p2p buffer
int ack = false;
auto fItr = mFdToFileNameMap.find(dBO->fd);
if (fItr != mFdToFileNameMap.end()) {
Expand All @@ -2637,6 +2646,10 @@ int HwEmShim::xclCopyBO(unsigned int dst_boHandle, unsigned int src_boHandle, si
if (!ack)
return -1;
}
else{
std::cerr << "ERROR: Copy buffer from source to destination faliled" << std::endl;
return -1;
}

PRINTENDFUNC;
return 0;
Expand Down

0 comments on commit f19a872

Please sign in to comment.