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

[UR][HIP] Enable kernel finalization using comgr #940

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

Naghasan
Copy link
Contributor

@Naghasan Naghasan commented Oct 9, 2023

For kernel fusion support for hip, we need to finalize the kernels using comgr. The patch finalizes tagged binaries during buildProgram before handing it over to the hip runtime.

Initial / related PR intel/llvm#11003

For kernel fusion support for hip, we need to finalize the kernels using comgr.
The patch finalizes tagged binaries during buildProgram
before handing it over to the hip runtime.

Signed-off-by: Victor Lomuller <victor@codeplay.com>
@Naghasan Naghasan changed the title [HIP] Enable kernel finalization using comgr [UR][HIP] Enable kernel finalization using comgr Oct 10, 2023
@Naghasan
Copy link
Contributor Author

@JackAKirk could have a wee look please ? (I think you are one of the code owner) This is the UR part of the patch you approved in the main intel/llvm side

@JackAKirk
Copy link
Contributor

@JackAKirk could have a wee look please ? (I think you are one of the code owner) This is the UR part of the patch you approved in the main intel/llvm side

sure

@Naghasan
Copy link
Contributor Author

Thanks

@@ -18,7 +18,7 @@ set(UR_HIP_INCLUDE_DIR "${UR_HIP_ROCM_DIR}/include")
set(UR_HIP_HSA_INCLUDE_DIR "${UR_HIP_ROCM_DIR}/hsa/include")

# Set HIP lib dir
set(UR_HIP_LIB_DIR "${UR_HIP_ROCM_DIR}/hip/lib")
set(UR_HIP_LIB_DIR "${UR_HIP_ROCM_DIR}/lib")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @kbenzie for awareness. This change implies UR_HIP_ROCM_DIR semantic has changed. I guess this might affect the CMAKE gymnastics with regard to pointing unified-runtime/intel-llvm to the correct rocm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks more logical to me but I'm not well versed in finding rocm CMake game.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libs found in hip/lib are also found in lib via a symlink. But logically, the path is no longer HIP but ROCM (which include ROCM). Hence the simple change here.

@@ -259,6 +412,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(

// TODO: Set metadata here and use reqd_work_group_size information.
// See urProgramCreateWithBinary in CUDA adapter.
if (pProperties) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jchlanda I was just wondering whether this affects your work on reqd_work_group_size metadata?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, I've added essentially the same snippet to set the metadata.
I guess we should be OK though, whichever patch gets in first will cause a merge conflict for the other, but that should be easy to resolve.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, I reused the structure from the CUDA adapter. I suppose you did the same, so that's just a matter of filling in the if condition

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, git will likely resolve it for us. Not to worry.

ur_result_t ur_program_handle_t_::finalizeRelocatable() {
#ifndef SYCL_ENABLE_KERNEL_FUSION
assert(false && "Relocation only available with fusion");
return UR_RESULT_ERROR_UNKNOWN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will never be reached right? because of the above assert being set to false.

Also it would be better to use a backend specific error that then gets automatically passed to a sycl extension, using setErrorMessage, like here: https://github.com/intel/llvm/pull/10953/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will never be reached right?

In a normal setup, correct. Hence the false here.

In order to be reached, you would need to either enable fusion in intel/llvm and actively disable it in the adapter or use the finalize property in some other patch. Either way, you need to actively change something in the build (cmake changes) or add a patch (which if tested should fail CI) to trigger this.

I can add a setErrorMessage if you care about a non sycl focus use of the adapter, otherwise I don't think it is that useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's fine to leave it as it is.

@Naghasan
Copy link
Contributor Author

Unless there is more comments, can we have this merged please ?

thanks

@kbenzie
Copy link
Contributor

kbenzie commented Oct 19, 2023

Unless there is more comments, can we have this merged please ?

Updating UR in intel/llvm is currently blocked by intel/llvm#11312 - I'm hoping to get that resolved today but want to do that before merging any more adapter changed to UR, things are already kinda complicated. I'll add it to the list to merge once things are unblocked.

@kbenzie kbenzie added the ready to merge Added to PR's which are ready to merge label Oct 19, 2023
@kbenzie kbenzie merged commit cf26de2 into oneapi-src:adapters Oct 25, 2023
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Added to PR's which are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants