Skip to content

Commit dc52634

Browse files
committed
Typed scalars rework
- Change the behavior of constant-folded strictly typed integer arithmetic from silent wraparound to raising compile-time error on overflow. - Add wrapping_add(), wrapping_sub(), wrapping_mul() for explicit wraparound arithmetic. - Make Tile/Scalar/Pointer/Vector concrete classes implemented in C++. They can represent both strictly typed constants and symbolic values. - Add cl.OpaqueValue to avoid representing mbarrier etc. as Scalar. - Remove SymbolicTile etc. in favor of the new classes. - Add a build step to generate docstrings for C++ implementations from the comments in cext.pyi. - Add support for typed scalars inside static_eval(). - Move the implementation of arithmetic ops to C++. Signed-off-by: Greg Bonik <gbonik@nvidia.com>
1 parent 3397cce commit dc52634

79 files changed

Lines changed: 9326 additions & 1856 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cext/CMakeLists.txt‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,35 @@ add_library(_cext_static STATIC
6161
cuda_loader.cpp
6262
cuda_helper.cpp
6363
dtype.cpp
64+
enums.cpp
65+
error.cpp
6466
ipc_util.cpp
6567
memory.cpp
6668
py.cpp
6769
pynvvm.cpp
6870
stream_buffer.cpp
6971
tensor_map.cpp
7072
tile_kernel.cpp
73+
value.cpp
7174
xla_ffi.cpp
7275
xla_ffi_py.cpp
7376
)
7477

78+
# Docstrings of the types defined in value.cpp, generated from their stubs in _cext.pyi
79+
set(cext_pyi ${CMAKE_SOURCE_DIR}/src/cuda/tile/_cext.pyi)
80+
set(cext_generated_dir ${CMAKE_CURRENT_BINARY_DIR}/generated)
81+
add_custom_command(
82+
OUTPUT ${cext_generated_dir}/cext_docstrings.h
83+
COMMAND ${CMAKE_COMMAND} -E make_directory ${cext_generated_dir}
84+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_docstrings.py
85+
${cext_pyi} ${cext_generated_dir}/cext_docstrings.h
86+
DEPENDS ${cext_pyi} ${CMAKE_CURRENT_SOURCE_DIR}/gen_docstrings.py
87+
COMMENT "Generating cext_docstrings.h from _cext.pyi"
88+
)
89+
target_sources(_cext_static PRIVATE ${cext_generated_dir}/cext_docstrings.h)
90+
7591
target_compile_options(_cext_static PUBLIC ${cext_compile_flags} ${nostdlib_flags})
76-
target_include_directories(_cext_static PRIVATE ${cext_include_dirs})
92+
target_include_directories(_cext_static PRIVATE ${cext_include_dirs} ${cext_generated_dir})
7793
target_link_options(_cext_static PUBLIC ${cext_link_flags} ${nostdlib_flags})
7894

7995

@@ -139,4 +155,4 @@ add_test_executable(test_hash_map test/test_hash_map.cpp memory.cpp)
139155

140156
add_test_executable(test_vec test/test_vec.cpp memory.cpp)
141157

142-
add_test_executable(test_string_builder test/test_string_builder.cpp py.cpp)
158+
add_test_executable(test_string_builder test/test_string_builder.cpp memory.cpp py.cpp)

0 commit comments

Comments
 (0)