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

Minor CMake Changes #303

Merged
merged 10 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Full documentation for hipTensor is available at [rocm.docs.amd.com/projects/hiptensor](https://rocm.docs.amd.com/projects/hipTensor/en/latest/index.html).

## (Unreleased) hipTensor 1.5.0 for ROCm 6.4.0

### Changes
dlangbe marked this conversation as resolved.
Show resolved Hide resolved

* Renamed the CMake option `AMDGPU_TARGETS` to `GPU_TARGETS`

## (Unreleased) hipTensor 1.4.0 for ROCm 6.3.0

### Additions
Expand Down
45 changes: 26 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ if( CMAKE_PROJECT_NAME STREQUAL "hiptensor" )
option(BUILD_OFFLOAD_COMPRESS "Build hiptensor with offload compression" ON)
endif()

# Check if offload compression is supported
include(CheckCXXCompilerFlag)
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()

# Setup output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -106,25 +97,41 @@ else()
endif()

if (ADDRESS_SANITIZER_ENABLED)
set(CMAKE_NO_BUILTIN_CHRPATH ON)
rocm_check_target_ids(DEFAULT_AMDGPU_TARGETS
rocm_check_target_ids(DEFAULT_GPU_TARGETS
TARGETS "gfx90a:xnack+;gfx942:xnack+" )
else()
rocm_check_target_ids(DEFAULT_AMDGPU_TARGETS
rocm_check_target_ids(DEFAULT_GPU_TARGETS
TARGETS "gfx908;gfx90a;gfx942" )
endif()

# Variable AMDGPU_TARGET must be a cached variable and must be specified before calling find_package(hip)
# This is because hip-config.cmake sets --offload-arch via AMDGPU_TARGET cached variable __after__ setting
# default cached variable AMDGPU_TARGET to "gfx900;gfx906;gfx908;gfx1100;gfx1101;gfx1102", where not all archs are compatible with MFMA instructions
# Check if offload compression is supported
include(CheckCXXCompilerFlag)
if (BUILD_OFFLOAD_COMPRESS)
dlangbe marked this conversation as resolved.
Show resolved Hide resolved
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." )
if(ADDRESS_SANITIZER_ENABLED)
set(CMAKE_NO_BUILTIN_CHRPATH ON)
endif()
elseif(CXX_COMPILER_SUPPORTS_OFFLOAD_COMPRESS)
dlangbe marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_NO_BUILTIN_CHRPATH OFF)
endif()
endif()

# Variable GPU_TARGET must be a cached variable and must be specified before calling find_package(hip)
# This is because hip-config.cmake sets --offload-arch via GPU_TARGET cached variable __after__ setting
# default cached variable GPU_TARGET to "gfx900;gfx906;gfx908;gfx1100;gfx1101;gfx1102", where not all archs are compatible with MFMA instructions
#
# By rule, once cached variable is set, it cannot be overridden unless we use the FORCE option
if(AMDGPU_TARGETS)
set(AMDGPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
if(GPU_TARGETS)
set(GPU_TARGETS "${GPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
elseif(AMDGPU_TARGETS)
set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
message(STATUS "WARNING: AMDGPU_TARGETS use is deprecated. Use GPU_TARGETS.")
else()
set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
set(GPU_TARGETS "${DEFAULT_GPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
endif()
message( VERBOSE "AMDGPU_TARGETS=${AMDGPU_TARGETS}")
message( VERBOSE "GPU_TARGETS=${GPU_TARGETS}")

if(HIPTENSOR_DEFAULT_STRIDES_COL_MAJOR)
add_compile_definitions(HIPTENSOR_DEFAULT_STRIDES_COL_MAJOR=1)
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ For more detailed information, please refer to the [hipTensor installation guide

### Project options

| Option | Description | Default Value |
|---------------------------------|---------------------------------------------------|----------------------------------------------------------------|
| AMDGPU_TARGETS | Build code for specific GPU target(s) | gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942 |
| HIPTENSOR_BUILD_TESTS | Build Tests | ON |
| HIPTENSOR_BUILD_SAMPLES | Build Samples | ON |
| HIPTENSOR_BUILD_COMPRESSED_DBG | Enable compressed debug symbols | ON |
| Option | Description | Default Value |
|---------------------------------|----------------------------------------------------|----------------------------------------------------------------|
| GPU_TARGETS | Build code for specific GPU target(s) | gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942 |
| AMDGPU_TARGETS | (Deprecated) Build code for specific GPU target(s) | gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942 |
| HIPTENSOR_BUILD_TESTS | Build Tests | ON |
| HIPTENSOR_BUILD_SAMPLES | Build Samples | ON |
| HIPTENSOR_BUILD_COMPRESSED_DBG | Enable compressed debug symbols | ON |
| HIPTENSOR_DEFAULT_STRIDES_COL_MAJOR | Set hiptensor default data layout to column major | ON |

### Example configurations
Expand All @@ -49,7 +50,7 @@ By default, the project is configured as Release mode. Here are some of the exam
| Configuration | Command |
|----------------------------------|---------------------------------------------------------------------------|
| Basic | `CC=hipcc CXX=hipcc cmake -B<build_dir> .` |
| Targeting gfx908 | `CC=hipcc CXX=hipcc cmake -B<build_dir> . -DAMDGPU_TARGETS=gfx908:xnack-` |
| Targeting gfx908 | `CC=hipcc CXX=hipcc cmake -B<build_dir> . -DGPU_TARGETS=gfx908:xnack-` |
| Debug build | `CC=hipcc CXX=hipcc cmake -B<build_dir> . -DCMAKE_BUILD_TYPE=Debug` |
| Build without tests (default on) | `CC=hipcc CXX=hipcc cmake -B<build_dir> . -DHIPTENSOR_BUILD_TESTS=OFF` |

Expand Down
6 changes: 3 additions & 3 deletions docs/install/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Below are the project options available to build hipTensor library with or witho
* - **Option**
- **Description**
- **Default Value**
* - AMDGPU_TARGETS
* - GPU_TARGETS
- Build code for specific GPU target(s)
- ``gfx908:xnack-``; ``gfx90a:xnack-``; ``gfx90a:xnack+``; ``gfx940``; ``gfx941``; ``gfx942``
* - HIPTENSOR_BUILD_TESTS
Expand All @@ -184,7 +184,7 @@ Here are some example project configurations:
+===================================+====================================================================================================================+
| Basic | :code:`CC=/opt/rocm/bin/amdclang CXX=/opt/rocm/bin/amdclang++ cmake -B<build_dir> .` |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| Targeting gfx908 | :code:`CC=/opt/rocm/bin/amdclang CXX=/opt/rocm/bin/amdclang++ cmake -B<build_dir> . -DAMDGPU_TARGETS=gfx908:xnack-`|
| Targeting gfx908 | :code:`CC=/opt/rocm/bin/amdclang CXX=/opt/rocm/bin/amdclang++ cmake -B<build_dir> . -DGPU_TARGETS=gfx908:xnack-`|
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| Debug build | :code:`CC=/opt/rocm/bin/amdclang CXX=/opt/rocm/bin/amdclang++ cmake -B<build_dir> . -DCMAKE_BUILD_TYPE=Debug` |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -437,7 +437,7 @@ Build performance

Depending on the resources available to the build machine and the build configuration selected, hipTensor build times can be on the order of an hour or more. Here are some things you can do to reduce build times:

* Target a specific GPU (e.g., ``-D AMDGPU_TARGETS=gfx908:xnack-``)
* Target a specific GPU (e.g., ``-D GPU_TARGETS=gfx908:xnack-``)
* Use lots of threads (e.g., ``-j32``)
* If they aren't needed, specify either ``HIPTENSOR_BUILD_TESTS`` or ``HIPTENSOR_BUILD_SAMPLES`` as OFF to disable client builds.
* During the ``make`` command, build a specific target, e.g: ``logger_test``.
Expand Down
2 changes: 1 addition & 1 deletion library/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function(add_hiptensor_component COMPONENT_NAME COMPONENT_SOURCES)

# Build components as object files.
# Make sure they have -fPIC and that they inherit the hip::device environment
# so that they build for all archs in AMDGPU_TARGETS
# so that they build for all archs in GPU_TARGETS
add_library(${COMPONENT_NAME} OBJECT ${COMPONENT_SOURCES})
target_compile_options(${COMPONENT_NAME} PRIVATE ${CLANG_DRIVER_MODE})
target_link_options(${COMPONENT_NAME} PRIVATE ${CLANG_DRIVER_MODE})
Expand Down
Loading