Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoguochun1995 committed Mar 24, 2024
1 parent 102b1c4 commit d18234e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dipu/torch_dipu/csrc_dipu/vendor/ascend/deviceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ OpStatus mallocDevice(void** p, size_t nbytes, bool throwExcepion) {
*p = nullptr;
return OpStatus::SUCCESS;
}
DIPU_CALLACLRT(::aclrtMalloc(p, nbytes, ACL_MEM_MALLOC_HUGE_FIRST));
// 若用户需申请大块内存并自行划分、管理内存时,建议使用aclrtMallocAlign32接 DIPU_CALLACLRT(::aclrtMalloc(p, nbytes, ACL_MEM_MALLOC_HUGE_FIRST));
// 口,该接口相比aclrtMalloc接口,只会对用户申请的size向上对齐成32字节整数
// 倍,不会再多加32字节。 大块内存用作缓存时,无需多加32字节
DIPU_CALLACLRT(::aclrtMallocAlign32(p, nbytes, ACL_MEM_MALLOC_HUGE_FIRST));
return OpStatus::SUCCESS;
}

Expand All @@ -149,21 +152,18 @@ void freeDevice(void* p) {
// (synchronous) copy from device to a device
void memCopyD2D(size_t nbytes, deviceId_t dstDevId, void* dst,
deviceId_t srcDevId, const void* src) {
syncDevice();
DIPU_CALLACLRT(
::aclrtMemcpy(dst, nbytes, src, nbytes, ACL_MEMCPY_DEVICE_TO_DEVICE));
}

// (synchronous) copy from host to a device
void memCopyH2D(size_t nbytes, void* dst, const void* src) {
syncDevice();
DIPU_CALLACLRT(
::aclrtMemcpy(dst, nbytes, src, nbytes, ACL_MEMCPY_HOST_TO_DEVICE));
}

// (synchronous) copy from a device to host
void memCopyD2H(size_t nbytes, void* dst, const void* src) {
syncDevice();
DIPU_CALLACLRT(
::aclrtMemcpy(dst, nbytes, src, nbytes, ACL_MEMCPY_DEVICE_TO_HOST));
}
Expand Down Expand Up @@ -251,7 +251,7 @@ bool streamNotNull(deviceStream_t stream) {
}

void streamWaitEvent(deviceStream_t stream, deviceEvent_t event) {
DIPU_CALLACLRT(::aclrtSynchronizeEvent(event))
DIPU_CALLACLRT(::aclrtStreamWaitEvent(stream, event))
}

// =====================
Expand Down

0 comments on commit d18234e

Please sign in to comment.