Skip to content
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

[CINN][New Hardware Update] HIP PR3 : add HIP backend #66109

Merged
merged 16 commits into from
Aug 9, 2024
Merged
Prev Previous commit
Next Next commit
fix approval
  • Loading branch information
DongBaiYue committed Jul 17, 2024
commit f10bccd0f384c50dfa5c5939fae0d9c01b9fbb43
5 changes: 3 additions & 2 deletions paddle/cinn/backends/hip/codegen_hip_dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,10 @@ void CodeGenHIP_Dev::PrintTempBufferCreation(const ir::Buffer &buffer) {
}
} else {
std::stringstream ss;
ss << "CUDA device codegen not support memory " << buffer->name << ", type "
ss << "HIP device codegen not support memory " << buffer->name << ", type "
<< buffer->memory_type;
PADDLE_THROW(phi::errors::InvalidArgument(ss.str()));
PADDLE_THROW(phi::errors::InvalidArgument("HIP codegen error in CINN: %s",
ss.str()));
}
}

Expand Down
12 changes: 7 additions & 5 deletions paddle/cinn/backends/hip/compiler_hip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ std::string Compiler::CompileWithHiprtc(const std::string& code,
log.resize(log_size);
HIPRTC_CHECK(hiprtcGetProgramLog(prog, &log[0]));
PADDLE_ENFORCE_EQ(
compile_res, HIPRTC_SUCCESS, ::common::errors::External(log));
compile_res,
HIPRTC_SUCCESS,
::common::errors::External("HIPRTC Error in Paddle CINN: %s", log));
}

size_t size;
Expand Down Expand Up @@ -136,10 +138,10 @@ std::string Compiler::CompileWithHipcc(const std::string& hip_c) {
std::string dir = "./source";
// create the folder to store sycl temporary files
if (access(dir.c_str(), F_OK) == -1) {
PADDLE_ENFORCE_NE(
mkdir(dir.c_str(), 7),
-1,
::common::errors::PreconditionNotMet("Fail to mkdir " + dir));
PADDLE_ENFORCE_NE(mkdir(dir.c_str(), 7),
-1,
::common::errors::PreconditionNotMet(
"Fail to mkdir %s in Hipcc compile.", dir));
}
prefix_name_ = dir + "/" + common::UniqName("hip_tmp");

Expand Down
5 changes: 4 additions & 1 deletion paddle/cinn/runtime/hip/hip_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ namespace runtime {
namespace hip {

HIPModule::HIPModule(const std::string& data) : data_(data) {
CHECK(!data.empty());
PADDLE_ENFORCE_EQ(
data.empty(),
false,
::common::errors::PreconditionNotMet("HIP Module Error: data is empty."));

hipGetDeviceCount(&num_devices_);
CHECK_GT(num_devices_, 0) << "No available devices";
Expand Down
3 changes: 3 additions & 0 deletions python/setup_cinn.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ if '${WITH_GPU}' == 'ON':
cinnlibs.append('${CMAKE_BINARY_DIR}/dist/cinn/include/paddle/cinn/runtime/cuda/float16.h')
cinnlibs.append('${CMAKE_BINARY_DIR}/dist/cinn/include/paddle/cinn/runtime/cuda/bfloat16.h')

if '${WITH_ROCM}' == 'ON':
cinnlibs.append('${CMAKE_BINARY_DIR}/dist/cinn/include/paddle/cinn/runtime/cuda/cinn_hip_runtime_source.h')

for lib in cinnlibs:
shutil.copy(lib, libs_path)
libname = os.path.basename(lib)
Expand Down