"git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "61f50c45849ee7315da5f7e2df193d4c9fe9713c"
Commit fa91e1e6 authored by Qianfeng Zhang's avatar Qianfeng Zhang
Browse files

Allocate persistent host memory for hipMemcpyAsync when hipGraph capturing is detected

parent cf133833
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstring>
#include "ck/utility/common_header.hpp" #include "ck/utility/common_header.hpp"
#include "ck/utility/philox_rand.hpp" #include "ck/utility/philox_rand.hpp"
...@@ -912,11 +913,37 @@ struct DeviceGroupedMultiheadAttentionForward_Xdl_CShuffle_V2 ...@@ -912,11 +913,37 @@ struct DeviceGroupedMultiheadAttentionForward_Xdl_CShuffle_V2
some_has_main_k_block_loop |= y; some_has_main_k_block_loop |= y;
} }
HIP_CHECK_ERROR(hipMemcpyAsync(arg.p_workspace_, hipStreamCaptureStatus status = hipStreamCaptureStatusNone;
arg.group_kernel_args_.data(),
arg.group_kernel_args_.size() * sizeof(GroupKernelArg), HIP_CHECK_ERROR(hipStreamIsCapturing(stream_config.stream_id_, &status));
hipMemcpyHostToDevice,
stream_config.stream_id_)); if(status == hipStreamCaptureStatusActive)
{
std::cout << " Inside hipStreamCapturing ..." << std::endl;
size_t copy_size = arg.group_kernel_args_.size() * sizeof(GroupKernelArg);
// ToDO: when to release this memory buffer?
char* persistent_ptr = new char[copy_size];
(void)std::memcpy(persistent_ptr, arg.group_kernel_args_.data(), copy_size);
HIP_CHECK_ERROR(hipMemcpyAsync(arg.p_workspace_,
persistent_ptr,
copy_size,
hipMemcpyHostToDevice,
stream_config.stream_id_));
}
else
{
std::cout << " Outside hipStreamCapturing ..." << std::endl;
HIP_CHECK_ERROR(
hipMemcpyAsync(arg.p_workspace_,
arg.group_kernel_args_.data(),
arg.group_kernel_args_.size() * sizeof(GroupKernelArg),
hipMemcpyHostToDevice,
stream_config.stream_id_));
}
float ave_time = 0; float ave_time = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment