Skip to content

Commit

Permalink
Compile cdef public functions from torch_allocator with C ABI (#1350)
Browse files Browse the repository at this point in the history
Since Cython 3, we must explicitly request a C ABI with `-DCYTHON_EXTERN_C='extern "C"'` for `cdef public` functions.

- Closes #1349

Before:
```
$ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate
00000000000071c0 T _Z10deallocatePvlS_
0000000000007500 T _Z8allocateliPv
...
```

After:
```
$ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate
0000000000007500 T allocate
00000000000071c0 T deallocate
...
```

Authors:
  - Lawrence Mitchell (https://github.com/wence-)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)
  - Bradley Dice (https://github.com/bdice)

URL: #1350
  • Loading branch information
wence- authored Sep 26, 2023
1 parent cd76d41 commit c8acf76
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/rmm/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ set(linked_libraries rmm::rmm)
# Build all of the Cython targets
rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}"
CXX)
# The cdef public functions in this file need to have a C ABI
target_compile_definitions(torch_allocator PRIVATE CYTHON_EXTERN_C=extern\ "C")

0 comments on commit c8acf76

Please sign in to comment.