Skip to content

Commit

Permalink
compress code objects (#2707)
Browse files Browse the repository at this point in the history
* compress code objects by default
* adds CMake option to control and tests compiler support
  • Loading branch information
TorreZuk authored Sep 23, 2024
1 parent 3f73cc1 commit bb81a83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmake/build-options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# presented in the superbuild GUI, but then passed into the ExternalProject as -D
# parameters, which would already define them.

include(CheckCXXCompilerFlag)

option( BUILD_VERBOSE "Output additional build information" OFF )

# BUILD_SHARED_LIBS is a cmake built-in; we make it an explicit option such that it shows in cmake-gui
Expand All @@ -46,6 +48,15 @@ endif()
# this file is intended to be loaded by toolchain or early as sets global compiler flags
# rocm-cmake checks will throw warnings if set later as cmake watchers installed


option(BUILD_OFFLOAD_COMPRESS "Build rocBLAS with offload compression" ON)
if (BUILD_OFFLOAD_COMPRESS)
check_cxx_compiler_flag("--offload-compress" CXX_COMPILER_SUPPORTS_OFFLOAD_COMPRESS)
if (NOT CXX_COMPILER_SUPPORTS_OFFLOAD_COMPRESS)
message( STATUS "WARNING: BUILD_OFFLOAD_COMPRESS=ON but flag not supported by compiler. Ignoring option." )
endif()
endif()

# FOR OPTIONAL CODE COVERAGE
option(BUILD_CODE_COVERAGE "Build rocBLAS with code coverage enabled" OFF)

Expand Down
4 changes: 4 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ function( rocblas_library_settings lib_target_ )
set_target_properties( ${lib_target_} PROPERTIES CXX_EXTENSIONS NO )
set_target_properties( ${lib_target_} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" )

if(BUILD_OFFLOAD_COMPRESS AND CXX_COMPILER_SUPPORTS_OFFLOAD_COMPRESS)
set_target_properties( ${lib_target_} PROPERTIES COMPILE_FLAGS "--offload-compress" )
endif()

target_link_libraries( ${lib_target_} INTERFACE hip::host )
if (WIN32)
target_link_libraries( ${lib_target_} PRIVATE hip::device )
Expand Down
6 changes: 6 additions & 0 deletions rmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def parse_args():
experimental_opts.add_argument( '--no-msgpack', dest='tensile_msgpack_backend', required=False, default=True, action='store_false',
help='Build Tensile backend not to use MessagePack and so use YAML (optional)')

general_opts.add_argument( '--no-offload-compress', dest='no_offload_compress', required=False, default=False, action='store_true',
help='Do not apply offload compression.')

general_opts.add_argument( '-r', '--relocatable', required=False, default=False, action='store_true',
help='Linux only: Add RUNPATH (based on ROCM_RPATH) and remove ldconf entry.')

Expand Down Expand Up @@ -399,6 +402,9 @@ def config_cmd():
if args.address_sanitizer:
cmake_options.append(f"-DBUILD_ADDRESS_SANITIZER=ON")

if args.no_offload_compress:
cmake_options.append(f"-DBUILD_OFFLOAD_COMPRESS=OFF")

# clean
delete_dir(build_path)

Expand Down

1 comment on commit bb81a83

@LunNova
Copy link

@LunNova LunNova commented on bb81a83 Oct 9, 2024

Choose a reason for hiding this comment

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

I was excited to see this feature, in practice it doesn't help much because the TensileCreateLibrary code is not compressed.
Raised ROCm/Tensile#2031

Please sign in to comment.