Replies: 5 comments 8 replies
|
Thank you for sharing, we/I have yet to digest your proposal. Regarding generic package, we have an OpenCL based flavor which works just fine on all major GPU architectures like single binary (same goes for CP2K). The reason for non-generic build with CUDA/HIP are specialized kernels and in the past no fallback to generic/untuned parameters. This is now solved for CUDA/HIP but may need some extra work to expose a generic GPU package. Worst case for the latter is to always fall-back even worse to have done data transfers before entering the fallback. For OpenCL, this was never a problem since tuned parameters are entirely optional plus it can include all tuned parameters available with one binary plus having a GPU based fallback for parameters. Questioning your desire in general, DBCSR's GPU support relies on reasonable support for FP64 aka double-precision which may be badly supported by client GPUs (very unfavorable FLOPS ratio vs single-precision let alone low precision). With unfavorable I mean the GPU may yield less FLOPS then the aggregated CPU package (all cores). Even with FP64, GPU acceleration can fall short just to mention it. |
|
I see the point why you are asking this change: compilation time. And you are definitely right, we can reuse most (definitely all Fortran files, for instance) of the built files for different GPU arch. However, as you pointed out, it requires some refactoring of the build system. I think the only file that requires a specific recompilation per each arch is https://github.com/cp2k/dbcsr/blob/develop/src/acc/cuda_hip/calculate_norms.cpp. (side node: the current policy is to pass all macros to all files, so So, ideally, we can pass WITH_GPU="list of GPUs", then generate the kernels (i.e. the python script) per each arch in separate directories, build the Fortran files only once, compile calculate_norms per each arch (or we can make a fat binary), and then link per each arch and produce a libdbcsr_.a, as you are suggesting. This is valid only for the library. I don't want to make the same machinery for the executables (tests and examples), where only a single arch must be specified (then we will pick up the right library). Is this what you are suggesting? Given my current commitments, I can work on that in about ~1 month... |
|
Hello folks! Any consensus on this issue? |
|
I have made the required changes and pushed them to my fork 1. However, for some reason, when I run Errors: Upon manually fixing this one, I get many more. PS: The Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Hello team,
I am Spaarsh1 and I am trying to enable HIP/ROCm in the debian package for
dbcsrunder my GSoC'25 work as a contributor at Debian3. Cordell Bloor (@cgmb4) is my GSoC mentor.The package can be easily built for a GPU but the current build process requires us to run the entire build multiple times for all GPU architectures (which, in case of AMD, are currently
gfx906,gfx908andgfx90a). To prevent this,cmakeallows to use a flag calledCMAKE_HIP_ARCHITECTURES5 that allows us to create a fat binary (a generic build, loosely speaking) that is compatible for multiple architectures simultaneously. But it has been manually disabled in the build process as seen here6. Due to this reason we need to build a separate binary for each supported architecture (libdbcsr-rocm-dev-gfxXXXX) which bloats our source package (and not to mention the increased build time).Upon further investigation, I came to realize that the reason for the aforementioned disable was due to the custom kernel building7 that
dbcsrdoes. This cannot be manipulated via cmake since those sections are built via python scripts. A non-trivial amount of changes shall be required to achieve a full generic build, if it is possible at all.However, after analyzing the binaries built for different packages, I understand that only
libdbcsr.ais dependent on the architecture (please correct me if I am wrong).With this understanding, I propose the following change, which would result in a single binary file that shall be able to support multiple GPU architectures with lesser bloating of our debian package:
Currently the build process uses the
WITH_GPUflag to build the package. Assuming I am not mistaken about onlylibdbcsr.abeing architecture-dependent, a way to compile alibdbcsr.arch.afor each architecture would enable support for all architectures via a single binary. This can be achieved by introducing a new optional flag, sayHIP_MULTI_ARCHITECTURE, in the main CMakeLists.txt8 file that can accept multiple architectures/target GPUs as input. In the CMakeLists.txt we parse over the inputs in the flag and loop over thelibdbcsr.acompilation, changing theWITH_GPUfor each iteration. This shall result in alibdbcsr.arch.afile after each iteration. Finally, all these files can be a part of thelibdbcsr-rocm-devpackage (you can find the MR here9. This would also need us to make theWITH_GPUflag optional. A new check that ensures that at leastWITH_GPUorHIP_MULTI_ARCHITECTUREis defined shall be added.The proposed change will allow us to build a generic HIP/ROCm dbcsr package for the dbcsr debian package.
Regards,
Spaarsh
All reactions