CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CINN][New Hardware Update] SYCL first PR #69554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
bce8bd8
to
4334c66
Compare
fix_bugs fix_bugs
ac7d13f
to
2dc4989
Compare
@@ -536,6 +542,14 @@ std::vector<ir::LoweredFunc> OpLowererImpl::DoOpLower( | |||
} else { | |||
op_func_arg_tensors->push_back(expr.as_tensor_ref()); | |||
} | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码实现没有差异性,std::variant<common::HygonDCUArchHIP, common::HygonDCUArchSYCL>处理 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
@@ -222,6 +222,9 @@ std::shared_ptr<framework::OpStrategy> StrategyForGatherNd( | |||
}, | |||
[&](common::HygonDCUArchHIP) { | |||
pe::IRGpuScheduleInjective(ir_sch, output_shapes.front(), target); | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
@@ -224,6 +224,9 @@ std::shared_ptr<framework::OpStrategy> StrategyForRepeat( | |||
}, | |||
[&](common::HygonDCUArchHIP) { | |||
pe::IRGpuScheduleInjective(ir_sch, output_shapes.front(), target); | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
::sycl::info::device_type::gpu)[0] | ||
.get_backend()); | ||
}, | ||
[&](common::X86Arch) { LOG(FATAL) << "SYCL Not supported this arch \n"; }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上, arch 为sycl /hip 的backend为都是:sycl::backend::ext_oneapi_hip,不会歧义吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
this->queues.resize(this->devices.size()); | ||
// sycl::backend -> Target::Arch | ||
switch (backend) { | ||
case ::sycl::backend::ext_oneapi_hip: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在更早的时候是不是就拦截掉了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前函数返回SYCLBackendAPI类内的私有变量arch,因此之前此处需要根据backend初始化this->arch,已参照修改意见修改。
.get_info<::sycl::info::device::sub_group_sizes>(); | ||
size_t max_sub_group_size = | ||
*max_element(std::begin(sub_group_sizes), std::end(sub_group_sizes)); | ||
rv = static_cast<int>(max_sub_group_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
SYCLModule::~SYCLModule() { | ||
VLOG(3) << "destructor for SYCLModule"; | ||
if (so_handler_ != nullptr) { | ||
// dlclose(so_handler_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冗余代码?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
2b9205d
to
bbd123a
Compare
modify according to comment modify according to comment modify according to comment
bbd123a
to
980cfbe
Compare
@@ -60,6 +60,13 @@ class CodeGenGpuHost : public CodeGenHost { | |||
} else { | |||
return CodeGenHost::Visit(op); | |||
} | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也是?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HygonDCUArchHIP需要判定是否为call_hip_kernel,HygonDCUArchSYCL需要判定是否为call_sycl_kernel,所需要判定的op不同,所以这里不能合并。
@@ -218,6 +218,11 @@ void detail::CollectBucketStrategyHostFunctionVisitor::ProcessLoweredFunc( | |||
[&](common::HygonDCUArchHIP) { | |||
#ifdef CINN_WITH_HIP | |||
shared_mem_bytes = CalculateSharedMemory(func); | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也是吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改了一下HygonDCUArchSYCL的对应逻辑。
paddle/cinn/backends/compiler.cc
Outdated
@@ -286,6 +287,10 @@ std::string Compiler::GetSourceCode(const ir::Module& module) { | |||
#else | |||
CINN_NOT_IMPLEMENTED | |||
#endif | |||
}, | |||
[&](common::HygonDCUArchSYCL) -> std::string { | |||
PADDLE_THROW(phi::errors::Unimplemented( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CINN_NOT_IMPLEMENTED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
paddle/cinn/common/target.cc
Outdated
@@ -79,6 +86,11 @@ int GetRuntimeArchImpl(HygonDCUArchHIP) { | |||
"HygonDCUArchHIP not supported GetRuntimeArch!")); | |||
} | |||
|
|||
int GetRuntimeArchImpl(HygonDCUArchSYCL) { | |||
PADDLE_THROW(::common::errors::InvalidArgument( | |||
"HygonDCUArchSYCL not supported GetRuntimeArch!")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CINN_NOT_IMPLEMENTED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
@@ -372,6 +372,12 @@ std::vector<ir::LoweredFunc> OpLowererImpl::PostProcess( | |||
#ifdef CINN_WITH_HIP | |||
optim::EliminateCommonGlobalMemoryRead(&(func_body)); | |||
optim::OptimizeExprGPU(&(func_body)); | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
::sycl::range<3> Grid(grid_z, grid_y, grid_x); | ||
::sycl::range<3> Block(block_z, block_y, block_x); | ||
// need malloc_shared | ||
// LOG(INFO) << "kernel args :" << (float* )(*(void **)(kernel_args[0]))[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
冗余代码
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
fix_bugs fix_bugs
90cb5a8
to
f11c934
Compare
.Visit(&new_forloop->body); | ||
}, | ||
[&](std::variant<common::HygonDCUArchHIP, common::HygonDCUArchSYCL>) { | ||
setNvHygon(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setNvHygon会不会有歧义那?海光的设备为啥和NV的有关系那?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是在NV设备与海光设备上均调用相同的函数,无需修改
[&](common::ARMArch) { LOG(FATAL) << "SYCL Not supported this arch \n"; }, | ||
[&](common::NVGPUArch) { backend = ::sycl::backend::ext_oneapi_cuda; }, | ||
[&](std::variant<common::HygonDCUArchHIP, common::HygonDCUArchSYCL>) { | ||
backend = ::sycl::backend::ext_oneapi_hip; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common::HygonDCUArchHIP对应:hip::backend::ext_oneapi_hip?
common::HygonDCUArchSYCL对应::sycl::backend::ext_oneapi_sycl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已参照修改意见修改。
5310255
to
46fdb22
Compare
e7b6aab
to
16b5843
Compare
cinn_buffer_t *CreateBufferFromNumpyImpl(common::HygonDCUArchSYCL, | ||
py::array data) { | ||
PADDLE_THROW(::common::errors::Unimplemented("CINN old obsolete code!")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分代码是不是可以清理了
|
||
#undef CINN_CUDA_INDEX_ADD | ||
|
||
int cinn_sycl_resize_bilinear(const int *buf, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些函数是不是没有地方在调用的,是不是可以清理下
int b3, | ||
int b4); | ||
|
||
void cinn_call_cnnl_conv2d_forward(void* v_args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
类似这种接口,是不是也不在需要了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Category
CINN
PR Types
New features
Description
SYCL后端第一个PR