-
Notifications
You must be signed in to change notification settings - Fork 242
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
3x faster MIOpen build by using host compiler instead of ROCm/clang++ #2091
base: develop
Are you sure you want to change the base?
3x faster MIOpen build by using host compiler instead of ROCm/clang++ #2091
Conversation
…l subset of source files with HIP-enabled Clang compiler. The rest of .cpp files are compiled with the host C++ compiler (e.g. gcc or regular clang), which is faster
…he following calls to hip_add_interface_compile_flags are disabled in /opt/rocm/lib/cmake/hip/hip-config.cmake: hip_add_interface_compile_flags(hip::device -x hip) hip_add_interface_compile_flags(hip::device --offload-arch=${GPU_TARGET}) * Adding an option to specify the HIP architectures explicitly, since HIP language uses native target (your GPU) by default: cmake -DMIOPEN_BACKEND=HIP -DCMAKE_HIP_ARCHITECTURES="gfx900;gfx906;gfx908;gfx90a;gfx1030" ..
Not all MIOpen source files could be treated as plain C++ files. Apparently, this happens due to some CK headers spilling GPU device code definitions via include files. In order to workaround this issue, we temporary migrate to CMake 3.24 and rename these files from .cpp to .hip. Moreover, two lines of
|
@dmikushin this is very interesting indeed! Let's merge the latest
|
@JehandadKhan One reason I'm compiling some files as .hip sources is the following:
CK wants to use half types, that are not fully standardized. Another reason: included CK headers contains device function code:
I have no idea why CK needs to include all of this into the host source files. Perhaps, these functions could be macro-guarded? |
MIOpen doesnt compile device kernels during cmake build time. Everything compiled at runtime. So it doesnt make sense to use the The only reason why we use Also, I dont think it is good to require a version of cmake that is not available in standard packages in ubuntu 20.04. |
@pfultz2 , please see above:
If we can ask CK to guard this code, then there will be no need of HIP mode indeed. And likely no need for CMake 3.24 as well, so your concern will be resolved. |
@@ -191,7 +190,6 @@ endif() | |||
# HIP is always required | |||
find_package(hip REQUIRED PATHS /opt/rocm) | |||
message(STATUS "Build with HIP ${hip_VERSION}") | |||
target_flags(HIP_COMPILER_FLAGS hip::device) |
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 will break when we compile(at runtime) with clang directly instead of using hiprtc. We still probably need that as a fallback for when we run into issues with hiprtc.
Yes this is a bug that should be fixed in CK. They should not be exposing device code in the header files for a host API. |
My ultimate goal is to drop rocm/clang++ from compilation, because it's slow. We should let the clang++ developers to figure out why it is slow and use the host gcc in the meantime, which is much faster. As you said, this is possible, given that CK stops spoiling host compilation with half types and unused declaration of device functions. Perhaps this could be resolved by a small code cleanup... |
set(HIP_LIBRARIES ${hip_LIBRARIES}) | ||
set(HIP_LIBRARY ${hip_LIBRARY}) | ||
set(HIP_HIPCC_EXECUTABLE ${hip_HIPCC_EXECUTABLE}) | ||
set(HIP_HIPCONFIG_EXECUTABLE ${hip_HIPCONFIG_EXECUTABLE}) |
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.
Not really related to this PR, but this file should be removed. This was added just to provide workarounds for hip-clang for rocm 3.5. There has been fixes since this, so we should no longer need this(if we still need it then we need to report it to the hip team).
This PR experimentally switches MIOpen C++ compiler from
/opt/rocm/llvm/bin/clang++
to just system's default C++ compiler (e.g. GCC) and greatly improves the MIOpen compilation speed (about 3.5x on my machine):Original:
New: