Skip to content

Commit

Permalink
Add an option to build with asan. (#933)
Browse files Browse the repository at this point in the history
Tested:

```
$ pip install -e .
$ nm -an bin/nvfuser_tests | grep asan
<empty>
$ python setup.py develop --build-with-asan
$ nm -an bin/nvfuser_tests | grep asan
...
00000000024f3840 B __odr_asan._ZN7nvfuser38NVFuserTest_FusionDefinition_CUDA_Test10test_info_E
00000000024f38e0 B __odr_asan._ZN7nvfuser35NVFuserTest_PyFusionCache_CUDA_Test10test_info_E
00000000024f3980 B __odr_asan._ZN7nvfuser43NVFuserTest_RecordFunctorEquality_CUDA_Test10test_info_E
0000000002528fa0 B __odr_asan._ZN5torch8autograd47_GLOBAL__N__551c3bf8_14_rng_kernels_cu_8fdfe6fb13graph_task_idE
```
  • Loading branch information
wujingyue authored Sep 23, 2023
1 parent 088e6cf commit 5169d12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc")
set(NVFUSER_THIRD_PARTY_DIR "${NVFUSER_ROOT}/third_party")

option(NVFUSER_STANDALONE_BUILD_WITH_UCC "" OFF)
option(NVFUSER_BUILD_WITH_ASAN "Build nvFuser with asan" OFF)

if(PROJECT_IS_TOP_LEVEL)
find_package(Torch REQUIRED)
Expand Down Expand Up @@ -246,6 +247,11 @@ target_include_directories(${NVFUSER_CODEGEN} PUBLIC
)
set_property(TARGET ${NVFUSER_CODEGEN} PROPERTY CXX_STANDARD 17)

if(NVFUSER_BUILD_WITH_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

if(PROJECT_IS_TOP_LEVEL)
target_link_libraries(${NVFUSER_CODEGEN} PRIVATE torch ${TORCH_LIBRARIES})

Expand Down Expand Up @@ -632,6 +638,7 @@ message(STATUS "")
message(STATUS "******** Nvfuser configuration summary ********")
message(STATUS " UCC_FOUND: ${UCC_FOUND}")
message(STATUS " NVFUSER_STANDALONE_BUILD_WITH_UCC : ${NVFUSER_STANDALONE_BUILD_WITH_UCC}")
message(STATUS " NVFUSER_BUILD_WITH_ASAN : ${NVFUSER_BUILD_WITH_ASAN}")

if(NVFUSER_STANDALONE_BUILD_WITH_UCC)
message(STATUS " UCC_HOME: $ENV{UCC_HOME}")
Expand Down
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
NO_BENCHMARK = False
NO_NINJA = False
BUILD_WITH_UCC = False
BUILD_WITH_ASAN = False
PATCH_NVFUSER = True
OVERWRITE_VERSION = False
VERSION_TAG = None
Expand All @@ -87,6 +88,9 @@
if arg == "--build-with-ucc":
BUILD_WITH_UCC = True
continue
if arg == "--build-with-asan":
BUILD_WITH_ASAN = True
continue
if arg == "--debug":
BUILD_TYPE = "Debug"
continue
Expand Down Expand Up @@ -296,6 +300,8 @@ def cmake(build_dir: str = "", install_prefix: str = "./nvfuser"):
cmd_str.append(f"-DPython_EXECUTABLE={sys.executable}")
if not NO_BENCHMARK:
cmd_str.append("-DBUILD_NVFUSER_BENCHMARK=ON")
if BUILD_WITH_ASAN:
cmd_str.append("-DNVFUSER_BUILD_WITH_ASAN=ON")
cmd_str.append(".")

print(f"Configuring CMake with {' '.join(cmd_str)}")
Expand Down

0 comments on commit 5169d12

Please sign in to comment.