Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide non-necessary symbols from shared object #1136

Merged
merged 1 commit into from
Aug 27, 2024
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
4 changes: 4 additions & 0 deletions transformer_engine/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -G")
endif()

# Hide non-necessary symbols in shared object.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtransformer_engine.version")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtransformer_engine.version")

# Transformer Engine library
project(transformer_engine LANGUAGES CUDA CXX)

Expand Down
4 changes: 4 additions & 0 deletions transformer_engine/common/libtransformer_engine.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
global: *nvte*; *transformer_engine*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need * before nvte or transformer_engine? Shouldn't it be nvte_* instead (since that is the format of our C APIs)? I'm also not convinced we need to expose anything with transformer_engine, could you give examples of the APIs we would want to expose that way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The * before nvte and transformer_engine is needed because some symbols are mangled, for e.g. _Z14nvte_unpermuteP....
  2. transformer_engine is necessary because we use some functionality such as transformer_engine::getenv in the frameworks, so we need to define the symbol for it to load the framework shared objects.

Given how both *transformer_engine* and (to a lesser extent) *nvte* patterns are specific to TE, I think it's safe to continue exposing these globally.

Copy link
Member

@ptrendx ptrendx Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Anything that is mangled is a bug since we advertise C API. In the case of permute it is because there is no extern "C" decorator around those functions. Also we are using nullptr instead of NULL or 0 - apparently C23 introduced it but I don't think we want to expect people to have such new C standards. @phu0ngng could we have it fixed?
  2. I thought we do not do this anymore and instead compile that function in each framework extension separately. @timmoon10 could you comment?

local: *;
};
Loading