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
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,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 @@ -419,8 +419,19 @@ if(TRITON_BUILD_PYTHON_MODULE)
${PYTHON_SRC_PATH}/llvm.cc
${PYTHON_SRC_PATH}/specialize.cc)

# Fixes error: ‘GluonLayouts’ declared with greater visibility than the type of its field
if (NOT MSVC)
target_compile_options(triton PRIVATE -Wno-error=attributes)
endif()

# 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 Down Expand Up @@ -449,10 +460,8 @@ if(TRITON_BUILD_PYTHON_MODULE)
"${TRITON_WHEEL_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}"
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()

if(TRITON_BUILD_PYTHON_MODULE AND NOT WIN32)
Expand All @@ -478,7 +487,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.

5 changes: 4 additions & 1 deletion examples/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ foreach( plugin ${TRITON_PLUGIN_PASSES} )
TritonCanonicalizeIncGen
TritonPluginsIncGen
)
target_link_libraries(${plugin} PRIVATE MLIRPass)
target_link_libraries(${plugin} PRIVATE
$<$<PLATFORM_ID:Windows>:MLIRPass>
$<$<NOT:$<PLATFORM_ID:Windows>>: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,13 @@ add_mlir_dialect_library(MLIRDialectPlugin
MLIRDialectPluginPassesIncGen

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

Expand Down
9 changes: 5 additions & 4 deletions python/test/unit/plugins/test_dialect_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
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")


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 @@ -51,8 +50,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
Loading