-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHostMemory.cpp
40 lines (39 loc) · 1.31 KB
/
HostMemory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file HostMemory.cpp
* @brief Implementation of host memory type
*/
#include "HostMemoryRegion.hpp"
#include "CopyChannel.hpp"
#include <cstring>
namespace interdevcopy {
/**
* @brief a function to copy between host memory
* @param dst destination host memory region
* @param src source host memory region
* @param dstoff offset of destination from the start of destination region
* @param srcoff offset of source from the start of source region
* @param size the size of area to transfer
* @param option for future use
*/
ssize_t copyFromHostToHost(HostMemoryRegion *dst, HostMemoryRegion *src,
size_t dstoff, size_t srcoff, size_t size,
__attribute__((unused)) void *option) {
memmove(dst->getPtr(dstoff), src->getPtr(srcoff), size);
return size;
}
/**
* @brief Copy function factory for transfer between host memory
*
* CopyHostToThst defines a copy channel between host memory.
*/
struct CopyHostToHost {
using srctype = HostMemoryRegion;
using desttype = HostMemoryRegion;
CopyFuncType operator()(DeviceMemoryRegion *dst, DeviceMemoryRegion *src,
__attribute__((unused)) void *option) {
return wrapCopyFuncWithDownCastAndBind(©FromHostToHost, dst, src);
}
};
}
REGISTER_DEVICE_MEMORY_REGION_TYPE(interdevcopy::HostMemoryRegion);
REGISTER_COPY_HANDLER(interdevcopy::CopyHostToHost);