Skip to content

Commit da086eb

Browse files
authored
Clean up TritonSan for release (#322)
**This PR refactors TritonSan-related files to prepare the tool for broader use. Key changes include:** 1. **CMake Option for TritonSan** Introduced a new CMake option `TRITON_SAN_ENABLED` (default: `ON`) to allow users to disable TritonSan build and tests if not needed. 2. **Directory Renaming** Renamed the `script` folder to `triton-san` for clarity and consistency. 3. **Unified Build Script** Added a single build script `triton-san/build.sh` to streamline the installation process for users. 4. **Driver Script Template** Included a template `triton-san.in` used by `build.sh` to generate the final `triton-san` driver script, enabling users to launch Triton programs with TritonSan. 5. **Documentation and Examples** Provided a new README and example programs to help users get started with TritonSan. 6. **Test Suite Updates** Updated relevant `lit` tests and added `; REQUIRES: triton-san` to ensure tests are only run when TritonSan is enabled. 7. **Fix some broken path settings in test/lit.site.cfg.py.in** 8. **Move common utility bash functions into `utility.inc` and include it into other bash scripts through the `source` command** 9. **Use ANSI escape codes to set the color for status/warning/error messages** https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
1 parent 15b3f87 commit da086eb

24 files changed

+625
-320
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
option(TRITON_SHARED_BUILD_CPU_BACKEND "Build triton-shared CPU backend" ON)
2+
option(TRITON_SHARED_BUILD_TRITON_SAN "Build the triton-san sanitizer suite" ON)
23

34
set(TRITON_SHARED_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
45
set(TRITON_SHARED_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ll.ir ll.mlir tt.mlir ttshared.mlir
207207
```
208208

209209
## Debugging Triton Programs
210-
Triton-shared includes a build option that enables LLVM-sanitizers - AddressSanitizer (ASan) and ThreadSanitizer (TSan) - to help detect memory safety and concurrency issues in Triton programs. These sanitizers dynamically analyze the program during execution, identifying bugs such as buffer overflows and data races respectively. For more details and setup instructions, refer [here](https://github.com/microsoft/triton-shared/blob/main/scripts/SANITIZER.md).
210+
Triton-shared includes a build option that enables LLVM-sanitizers - AddressSanitizer (ASan) and ThreadSanitizer (TSan) - to help detect memory safety and concurrency issues in Triton programs. These sanitizers dynamically analyze the program during execution, identifying bugs such as buffer overflows and data races respectively. For more details and setup instructions, refer [here](triton-san/README.md).
211211

212212
## Contributing
213213

lib/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ add_subdirectory(Analysis)
22
add_subdirectory(AnalysisStructured)
33
add_subdirectory(Conversion)
44
add_subdirectory(Dialect)
5-
add_subdirectory(Sanitizer)
5+
6+
if(TRITON_SHARED_BUILD_TRITON_SAN)
7+
add_subdirectory(Sanitizer)
8+
endif(TRITON_SHARED_BUILD_TRITON_SAN)
9+
610
add_subdirectory(Transform)
711
add_subdirectory(Utils)

scripts/SANITIZER.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

scripts/build_triton_shared_for_sanitizers.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

scripts/run_triton_with_sanitizers.sh

Lines changed: 0 additions & 100 deletions
This file was deleted.

scripts/setup_runtime_for_sanitizers.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

scripts/setup_triton_shared_with_venv.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/Sanitizer/SanitizerAttributes/asan.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: %toolsdir/opt -load-pass-plugin %shlibdir/libSanitizerAttributes.so -passes=sanitizer-attributes -sanitizer-type=asan -S %s | FileCheck %s
1+
; REQUIRES: triton-san
2+
; RUN: opt -load-pass-plugin %sanitizer_dir/libSanitizerAttributes.so -passes=sanitizer-attributes -sanitizer-type=asan -S %s | FileCheck %s
23

34
; ModuleID = 'LLVMDialectModule'
45
source_filename = "LLVMDialectModule"

test/Sanitizer/SanitizerAttributes/tsan.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: %toolsdir/opt -load-pass-plugin %shlibdir/libSanitizerAttributes.so -passes=sanitizer-attributes -sanitizer-type=tsan -S %s | FileCheck %s
1+
; REQUIRES: triton-san
2+
; RUN: opt -load-pass-plugin %sanitizer_dir/libSanitizerAttributes.so -passes=sanitizer-attributes -sanitizer-type=tsan -S %s | FileCheck %s
23

34
; ModuleID = 'LLVMDialectModule'
45
source_filename = "LLVMDialectModule"

0 commit comments

Comments
 (0)