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

01_vector_add test compile error. Just want to confirm can this test be well supported. #211

Open
FatJhon opened this issue Jan 16, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@FatJhon
Copy link

FatJhon commented Jan 16, 2025

Describe the bug

user guide test vector_add test, just fail to make_so,get error information as follows:
ret = subprocess.check_call(cc_cmd)
File "/usr/local/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/rh/gcc-toolset-11/root/usr/bin/gcc', '/tmp/tmp59kzdlsc/kernel.s', '-O3', '-shared', '-fPIC', '-Wno-psabi', '-o', '/tmp/tmp59kzdlsc/kernel.cpython-310-x86_64-linux-gnu.so', '-lm', '-lTritonCPURuntime', '-lsleef', '-lgcc', '-L/home/workspace/torch-triton/triton-cpu/python/triton/_C', '-L/usr/local/lib', '-I/usr/local/include', '-I/tmp/tmp59kzdlsc', '-I/usr/local/include/python3.10', '-Wl,-rpath', PosixPath('/home/workspace/torch-triton/triton-cpu/python/triton/_C'), '-Wl,-rpath', '/usr/local/lib', '-g']' returned non-zero exit status 1.

Environment details

use the newest master && cpu backend test

@FatJhon FatJhon added the bug Something isn't working label Jan 16, 2025
@FatJhon FatJhon changed the title 01_vector_add test compile error. Just want to confirm can this test can be well supported. 01_vector_add test compile error. Just want to confirm can this test be well supported. Jan 16, 2025
@krishagarwal
Copy link

I found the same issue. Looking further up in the error log, I saw the following message from the assembler:

/tmp/tmpfne6g4g3/kernel.s: Assembler messages: /tmp/tmpfne6g4g3/kernel.s:4363: Error: junk at end of line, first unrecognized character is `"'

I manually printed the assembly source from python (TRITON_KERNEL_DUMP=1 TRITON_DUMP_DIR=<some directory> wasn't working) and saw that the line causing the error is:

.file	1 "<path>/triton-cpu/python/tutorials" "01-vector-add.py"

I guess the assembler needs this path to be one string rather than split into two, meaning it should be

.file	1 "<path>/triton-cpu/python/tutorials/01-vector-add.py"

For now, as a really dirty fix, I inserted the following at line 93 in python/triton/runtime/build.py:

with open(src, "r") as f:
    src_txt = f.read()
src_txt = src_txt.replace('" "', "/")
with open(src, "w") as f:
    f.write(src_txt)

Basically, this will manually combine the path into one string in the assembly source before compiling. It seems to be working fine for me so far, although I would obviously hope a more proper fix is implemented.

@ienkovich
Copy link
Collaborator

I've seen such a problem previously. It was caused by as not recognizing .file directive and we've fixed it by adding -g compilation option. Initially, we used -gdwarf-5, but later moved to -g (IIRC -gdwarf-5 caused failure on older toolchains). So I suspect the issue might be related to the binary toolchain version on your system. What is our toolchain version? Can you successfully compile the original asm file with your gcc/as providing -gdwarf-5 options (asm compilation options are added at python/triton/runtime/build.py:92)?

@krishagarwal
Copy link

gcc version 9.4.0, as version 2.34. The issue persists even after using -gdwarf-5.

@ienkovich
Copy link
Collaborator

In our flows we use GCC 11, Binutils 2.38 or newer, so upgrading should resolve the issue.

A possible workaround is to use TRITON_DISABLE_LINE_INFO=1. This should remove all .file directives you have a problem with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants