Adding rocBLAS support for BLAS domain through Intel DPCPP compiler with HIP backend support
Description
This PR is intended to extend the HIP backend of BLAS domain, which is currently supported for hipSYCL compiler to Intel’s DPC++/SYCL compiler.
Checklist
All Submissions
- [x] Do all unit tests pass locally? Test Cases.log
- [x] Have you formatted the code using clang-format?
New features
- [x] Have you provided motivation for adding a new feature?
- [x] Have you added relevant tests?
@TejaX-Alaghari Thank you for this PR! I have built and successfully tested it on an application containing SYCL code. Just had to adjust the following line in FindrocBLAS.cmake to IMPORTED_LOCATION "${HIP_PATH}/../rocblas/lib/librocblas.so" in order to handle non-standard ROCM paths. Could you please incorporate this small fix before the PR gets merged? Also filed a related issue on the intel llvm page.
Thanks for the suggestion @ajaypanyala. I've added a commit for that change. Do let me know if there are any other suggestions.
@TejaX-Alaghari @mmeterel I get a link error in the final step.
[100%] Linking CXX shared library ../../../../lib/libonemkl_blas_rocblas.so
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lclang_rt.builtins-x86_64
Not sure if something needs to be fixed in this file.
For now, I got it to work by manually adding -L$ROCM_PATH/llvm/lib/clang/13.0.0/lib/linux to the link line where libclang_rt.builtins-x86_64.a exists. The link step tries to find clang_rt.builtins-x86_64 in the folder $INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/lib/linux which doesn't exist. Only the include folder $INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/include exists. I am building the intel-llvm compiler as described here
[EDIT] This issue probably belongs in the intel-llvm repo. There is a related issue that was just opened.
@TejaX-Alaghari @mmeterel I get a link error in the final step.
[100%] Linking CXX shared library ../../../../lib/libonemkl_blas_rocblas.so /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lclang_rt.builtins-x86_64Not sure if something needs to be fixed in this file.
For now, I got it to work by manually adding
-L$ROCM_PATH/llvm/lib/clang/13.0.0/lib/linuxto the link line wherelibclang_rt.builtins-x86_64.aexists. The link step tries to findclang_rt.builtins-x86_64in the folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/lib/linuxwhich doesn't exist. Only the include folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/includeexists. I am building theintel-llvmcompiler as described here[EDIT] This issue probably belongs in the intel-llvm repo. There is a related issue that was just opened.
@ajaypanyala @TejaX-Alaghari Thanks for the detailed explanation. I have seen the same issue earlier. I am leaning towards waiting for LLVM issue to be fixed, so we don't have to recommend users to use temporary hack. What do you think?
@TejaX-Alaghari @mmeterel I get a link error in the final step.
[100%] Linking CXX shared library ../../../../lib/libonemkl_blas_rocblas.so /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lclang_rt.builtins-x86_64Not sure if something needs to be fixed in this file. For now, I got it to work by manually adding
-L$ROCM_PATH/llvm/lib/clang/13.0.0/lib/linuxto the link line wherelibclang_rt.builtins-x86_64.aexists. The link step tries to findclang_rt.builtins-x86_64in the folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/lib/linuxwhich doesn't exist. Only the include folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/includeexists. I am building theintel-llvmcompiler as described here [EDIT] This issue probably belongs in the intel-llvm repo. There is a related issue that was just opened.@ajaypanyala @TejaX-Alaghari Thanks for the detailed explanation. I have seen the same issue earlier. I am leaning towards waiting for LLVM issue to be fixed, so we don't have to recommend users to use temporary hack. What do you think?
@mmeterel Sounds good. That would be perfect! Thanks!
@TejaX-Alaghari @mmeterel I get a link error in the final step.
[100%] Linking CXX shared library ../../../../lib/libonemkl_blas_rocblas.so /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lclang_rt.builtins-x86_64Not sure if something needs to be fixed in this file. For now, I got it to work by manually adding
-L$ROCM_PATH/llvm/lib/clang/13.0.0/lib/linuxto the link line wherelibclang_rt.builtins-x86_64.aexists. The link step tries to findclang_rt.builtins-x86_64in the folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/lib/linuxwhich doesn't exist. Only the include folder$INTEL_LLVM_INSTALL_PATH/lib/clang/15.0.0/includeexists. I am building theintel-llvmcompiler as described here [EDIT] This issue probably belongs in the intel-llvm repo. There is a related issue that was just opened.@ajaypanyala @TejaX-Alaghari Thanks for the detailed explanation. I have seen the same issue earlier. I am leaning towards waiting for LLVM issue to be fixed, so we don't have to recommend users to use temporary hack. What do you think?
@mmeterel : According to the compiler team, SYCL compiler doesn't use clang-builtins library. It uses libgcc_s.so instead. In this case, the dependency for libclang_rt is from ROCM blas library. The clang version of libclang_rt should match the ROCM library built version. It suggests that adding -L$ROCM_PATH/llvm/lib/clang/13.0.0/lib/linux is the right permanent solution.
@TejaX-Alaghari Sorry for the delay in getting back to this. I have a few follow-up requests and questions about this PR.
- Could you please update each conversation with your feedback?
- I left 7 comments on May 11. Could you please respond to each of these comments with the status? Let's do our best to have every question/comment answered.
@TejaX-Alaghari I tested this PR on an AMD system with ROCM version 5.0.0 and card version gfx90a. LLVM with HIP backend is built from this commit: 66361038b63caaae566fc9648f5da50b74222b83
I am getting the warning/errors/crashes as shown in the attached files. I have tested only Level1 APIs for simplicity.
Could you please advise how to resolve them? Feel free to schedule a meeting to discuss in detail.
Thanks for the PR. Looking forward to add this feature.
I added some initial feedback. General comments:
- Please check if the comments added for cuBLAS backend still makes sense here as well. And if yes, update them accordingly.
- Please use sycl:: namespace throughout the project.
- Please make sure header guards match header names.
- Please test rocBLAS backend with hipSYCL so make sure nothing is broken. Update logs.
- I have some concerns about Copyrights - will add my feedback later ==> feedback added
- Please update README and docs folder as needed.
- In the test logs, please test MKLCPU backend as well. Also, I see segfault errors. Can you fix them?
Thanks for the detailed feedback on the PR. Please find below, the response for above comments:
- The existing comments are relevant for the changes introduced in this PR
- All the earlier "cl::sycl::"namespaces have been updated to "sycl::"
- All header guards match their respective file names
- TBD
- Updated the copyrights per the suggestion for newly introduced files
- Updated README and docs with the build configuration for rocBLAS backend through clang++
- We haven't observed any issues while testing MKLCPU backend for BLAS with "ctest"
Tested the PR again after latest commits. Still seeing major failures. Please reach out for a debug session.
Tested the PR again after latest commits. Still seeing major failures. Please reach out for a debug session.
After discussing with @TejaX-Alaghari offline, this issue is most likely due to missing synchronization. Similar issue was fixed in #228 for cuBLAS backend. @TejaX-Alaghari will work on updating this PR. Please note that, similar updates will likely needs to be done for rocRAND (#218 ) and rocSOLVER (#208 ) PRs.
Attached are the results for my local tests using LLVM compiler: rocblas_llvm_log.txt
I see three problems with these results:
- SCAL seg fault: Tracked in issue #233
- Warnings due to hipCtxGetCurrent: Tracked in issue #234
- Warnings due to linking module: Tracked in https://github.com/intel/llvm/issues/6922
I also ran this PR using hipSYCL. Attached are the results: rocblas_hipsycl_log.txt The errors I see are intermittent and do not appear then we run gtest directly. I don't think, these are related to this PR.
Based on the above discussion, I don't have concerns with merging this PR. The mentioned issues can be tracked separately.
Thanks for all your efforts on enabling rocBLAS backend with LLVM-HIP compiler.
@vmalia @mkrainiuk I just added my test results along with related issues. The PR is ok to merge IMHO. Could you please take a look from your side?