Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ endfunction()
# Disable warnings that show up in external code (gtest;pybind11)
if(NOT MSVC)
set(TRITON_DISABLE_EH_RTTI_FLAGS "$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions;-fno-rtti>")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-covered-switch-default -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-covered-switch-default")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4624 /wd4715 /wd4530")
endif()
Expand Down Expand Up @@ -409,6 +409,12 @@ if(TRITON_BUILD_PYTHON_MODULE)

# Link triton with its dependencies
target_link_libraries(triton PRIVATE ${TRITON_LIBRARIES})

# Do not propagate libraries that libtriton depends on. This ensures that
# targets that link against libtriton do not accidentally link in their own
# copies of core Triton code and LLVM.
set_target_properties(triton PROPERTIES INTERFACE_LINK_LIBRARIES "")

if(WIN32)
target_link_libraries(triton PRIVATE ${CMAKE_DL_LIBS})
set_target_properties(triton PROPERTIES SUFFIX ".pyd")
Expand All @@ -431,10 +437,8 @@ if(TRITON_BUILD_PYTHON_MODULE)
"${TRITON_WHEEL_DIR}/FileCheck"
COPYONLY)

endif()

if (UNIX AND NOT APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,ALL")
# Only build plugins when building libtriton since they depend on libtriton.
add_subdirectory(examples/plugins)
endif()

Copy link
Copy Markdown
Contributor

@plotfi plotfi Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If --Bsymbolic is a workable solution, I think we could use it here:

if (UNIX AND NOT APPLE)
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--Bsymbolic")
endif()

if(TRITON_BUILD_PYTHON_MODULE AND NOT WIN32)
Expand All @@ -460,7 +464,6 @@ find_package(Threads REQUIRED)
add_subdirectory(third_party/f2reduce)
add_subdirectory(bin)
add_subdirectory(test)
add_subdirectory(examples)

if(TRITON_BUILD_UT)
add_subdirectory(unittest)
Expand Down
1 change: 0 additions & 1 deletion examples/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion examples/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ foreach( plugin ${TRITON_PLUGIN_PASSES} )
TritonCanonicalizeIncGen
TritonPluginsIncGen
)
target_link_libraries(${plugin} PRIVATE MLIRPass)
target_link_libraries(${plugin} PRIVATE triton)

# CMAKE_LIBRARY_OUTPUT_DIRECTORY is only set during the Python
# build. It is empty if building directly from the root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ add_mlir_dialect_library(MLIRDialectPlugin
MLIRDialectPluginPassesIncGen

LINK_LIBS PUBLIC
MLIRPass
LLVMSupport
MLIRSupport
TritonNVIDIAGPUToLLVM
triton
"$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>"
)

Expand Down
17 changes: 7 additions & 10 deletions python/test/unit/plugins/test_dialect_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import subprocess
import pathlib
import pytest
import re

from triton._internal_testing import is_cuda, is_hip, is_hip_cdna2

pytestmark = pytest.mark.skipif(is_hip_cdna2(), reason="old AMD GPUs are not supported")
from triton._internal_testing import is_cuda, is_hip


@pytest.mark.skipif(is_hip(), reason="plugin not supported/tested on AMD yet")
def test_override(tmp_path: pathlib.Path):
if os.environ.get('LLVM_BUILD_SHARED_LIBS', '0') == '0':
return
dir_path = os.path.dirname(os.path.realpath(__file__))

# Run once to get the file dumps
Expand Down Expand Up @@ -40,9 +38,6 @@ def test_override(tmp_path: pathlib.Path):
os.remove(ptx_files[0])
os.remove(cubin_files[0])

if is_hip():
pytest.skip("plugin not supported/tested on AMD yet")

filename = str(list(tmp_path.rglob("*.ttir"))[0])

with open(filename, "r") as infile:
Expand All @@ -51,8 +46,10 @@ def test_override(tmp_path: pathlib.Path):
# # Add ttgir instrumentation
with open(filename, "w") as outfile:
for line in file_str:
if "tt.get_program_id x" in line:
line = ' %pid_base = arith.constant 0 : i32\n %pid = plugin.magic %pid_base : i32\n'
match = re.search(r'(%\w+)\s*=\s*tt\.get_program_id\s+x', line)
if match:
ssa_name = match.group(1)
line = f' %pid_base = arith.constant 0 : i32\n {ssa_name} = plugin.magic %pid_base : i32\n'
outfile.write(line)

# # # Run again with kernel override
Expand Down
6 changes: 2 additions & 4 deletions python/test/unit/plugins/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import torch

import pytest
import os

import triton
import triton.language as tl
from triton import knobs
from triton._internal_testing import is_hip
import custom_stages


Expand All @@ -21,10 +21,8 @@ def kernel2(BLOCK_SIZE: tl.constexpr):
return


@pytest.mark.skipif(is_hip(), reason="plugin not supported/tested on AMD yet")
def test_op(capfd, device: str):
if os.environ.get('LLVM_BUILD_SHARED_LIBS', '0') == '0':
return

size = 98432
x = torch.rand(size, device=device)
output = torch.empty_like(x)
Expand Down