mgpusim icon indicating copy to clipboard operation
mgpusim copied to clipboard

Seeking Guidance on HSACO File Compilation

Open jianqiao673 opened this issue 2 months ago • 5 comments

Hello author. We are a research team from the School of Computer Science and Technology at Shandong University, currently working on GPU memory optimization. Currently, we are attempting to write our own kernel operators. However, we have encountered an issue while compiling and generating HSACO files. We would greatly appreciate your guidance on the following questions: Question 1: How to compile HSACO files We are facing difficulties in compiling HSACO files. Currently, we are using Clang-12 (included with ROCm v4.2.0) for compilation. The complete command we are using to compile gemm.heaso file is as follows:

  clang-12 \

    -target amdgcn--amdhsa \
  
    -mcpu=gfx906 \
  
    -x cl \
  
    -cl-std=CL2.0 \
  
    -I/opt/rocm-4.2.0/opencl/include \
  
    -include opencl-c.h \
  
    -Xclang -mlink-builtin-bitcode \
  
    -Xclang /opt/rocm-4.2.0/amdgcn/bitcode/opencl.bc \
  
    gemm.cl \
  
    -o gemm.hsaco

This command or environment configuration seems to be causing discrepancies in the output. We hope you can advise us on the necessary compilation environment and tools, as well as any undocumented critical steps or parameters. Question 2: Regarding the choice of Clang compiler version We noticed that different HSACO files in your project (e.g., gemm.hsaco and kernels.hsaco) appear to have been compiled using different versions of Clang (e.g., Clang-12 and Clang-8). Is it necessary to select a specific Clang version when compiling different kernels? If so, what is the rationale behind this? If you have more detailed compilation documentation, specific environment configuration instructions, or any other relevant resources that you could share, it would be immensely helpful for our work. Thanks

jianqiao673 avatar Oct 13 '25 13:10 jianqiao673

The compiler that has been stable to use is the one in ROCm 3.8. We have been using the ROCm docker image to compile HSACO. Can you try to see if that works. Different clang version may be just because we compiled the binary at different times of development.

syifan avatar Oct 13 '25 21:10 syifan

The operating system we use is Windows, and it's difficult to configure ROCm3.8 with docker in Windows. Do you use Linux as your operating system or will different operating system affect the configuration of ROCm3.8?

jianqiao673 avatar Oct 16 '25 04:10 jianqiao673

Yes. We have always been using Linux to compile the HSACOs.

syifan avatar Oct 16 '25 13:10 syifan

We still have some difficulties on compiling the HSACOs .If you can offer us the command you compile the HSACOs, we will appreciate a lot

jianqiao673 avatar Oct 19 '25 12:10 jianqiao673

We have not been creating HSACOs for a long time. What error did you get?

syifan avatar Oct 21 '25 16:10 syifan