Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/tsingmicro-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ jobs:
run: |
source ~/env.sh
python3.11 -c 'import triton; print(triton.__path__)'
/usr/local/lib/python3.11/dist-packages/triton/backends/tsingmicro/bin/tsingmicro-opt --version
/usr/local/lib/python3.11/dist-packages/triton/backends/tsingmicro/bin/tsingmicro-llvm-opt --version
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def run(self):
cmake_major, cmake_minor = int(match.group("major")), int(match.group("minor"))
if (cmake_major, cmake_minor) < (3, 18):
raise RuntimeError("CMake >= 3.18.0 is required")

for ext in self.extensions:
self.build_extension(ext)

Expand Down
1 change: 1 addition & 0 deletions third_party/tsingmicro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if(NOT DEFINED TX8_HOME)
endif()
endif()

set(TSM_BACKEND_DIR ${CMAKE_CURRENT_SOURCE_DIR}/backend)
set(XUANTIE_NAME Xuantie-900-gcc-elf-newlib-x86_64-V2.10.2)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down
19 changes: 19 additions & 0 deletions third_party/tsingmicro/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ get_property(triton_libs GLOBAL PROPERTY TRITON_LIBS)

add_llvm_executable(tsingmicro-opt tsingmicro-opt.cpp PARTIAL_SOURCES_INTENDED)

if (DEFINED TSM_BACKEND_DIR)
set(TSM_BIN_OUT ${TSM_BACKEND_DIR}/bin)
else ()
set(TSM_BIN_OUT ${CMAKE_BINARY_DIR}/bin)
endif ()

# TODO: what's this?
llvm_update_compile_flags(tsingmicro-opt)
target_link_libraries(tsingmicro-opt PRIVATE
Expand All @@ -22,6 +28,9 @@ target_link_libraries(tsingmicro-opt PRIVATE
MLIRPass
MLIRTransforms
)
set_target_properties(tsingmicro-opt PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TSM_BIN_OUT}
)

mlir_check_all_link_libraries(tsingmicro-opt)

Expand All @@ -43,6 +52,9 @@ target_link_libraries(tsingmicro-reduce PRIVATE
MLIRPass
MLIRTransforms
)
set_target_properties(tsingmicro-reduce PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TSM_BIN_OUT}
)

mlir_check_all_link_libraries(tsingmicro-reduce)

Expand All @@ -64,6 +76,9 @@ target_link_libraries(tsingmicro-lsp PRIVATE
MLIRPass
MLIRTransforms
)
set_target_properties(tsingmicro-lsp PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TSM_BIN_OUT}
)

mlir_check_all_link_libraries(tsingmicro-lsp)

Expand All @@ -86,3 +101,7 @@ target_link_libraries(tsingmicro-llvm-opt PRIVATE
LLVMCodeGen
)
export_executable_symbols_for_plugins(tsingmicro-llvm-opt)

set_target_properties(tsingmicro-llvm-opt PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TSM_BIN_OUT}
)
24 changes: 24 additions & 0 deletions third_party/tsingmicro/crt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ add_library(${VENDOR_RUNTIME_LIB} STATIC ${VENDOR_SOURCES})
target_compile_options(${VENDOR_RUNTIME_LIB} PRIVATE ${RISCV_COMPILE_OPTIONS})
target_link_options(${VENDOR_RUNTIME_LIB} PRIVATE --target=${RISCV_TRIPLE})

if (DEFINED TSM_BACKEND_DIR)
set_target_properties(${VENDOR_RUNTIME_LIB} PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY ${TSM_BACKEND_DIR}/lib
)
else ()
# Set properties for the library
set_target_properties(${VENDOR_RUNTIME_LIB} PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
endif ()

# Setup compiler and environment for RISC-V compilation
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Use the existing Clang installation with target triple
Expand All @@ -103,3 +116,14 @@ else()
COMMAND ${CMAKE_COMMAND} -E echo "Building ${VENDOR_RUNTIME_LIB} for RISC-V target"
)
endif()

# Install targets
install(TARGETS ${VENDOR_RUNTIME_LIB}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

# Install headers (optional)
file(GLOB_RECURSE VENDOR_HEADERS Target/lib/${TARGET}/*.h)
install(FILES ${VENDOR_HEADERS} DESTINATION include/${TARGET})