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

[cmake][rocRAND] Updated toolchain-linux.cmake to have proper CMAKE_PREFIX_PATH definitions #587

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Documentation for rocRAND is available at
* `--test|-t` is no longer a required flag for `rtest.py`. Instead, the user can use either `--emulation|-e` or `--test|-t`, but not both.
* Removed TBB dependency for multi-core processing of host-side generation.

## Fixes
NguyenNhuDi marked this conversation as resolved.
Show resolved Hide resolved

* Fixed an issue where `CMAKE_PREFIX_PATH` was not defined properly in `CMAKELists.txt` and `toolchain-linux.cmake`.
* Fixed an issue where `cmake_platform_opts` in `rmake.py` was sometimes a string instead of a list.
NguyenNhuDi marked this conversation as resolved.
Show resolved Hide resolved

## rocRAND 3.2.0 for ROCm 6.3.0

### Added
Expand Down
57 changes: 33 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,48 @@ option(BUILD_FORTRAN_WRAPPER "Build Fortran wrapper" OFF)
option(BUILD_TEST "Build tests (requires googletest)" OFF)
option(BUILD_BENCHMARK "Build benchmarks" OFF)
cmake_dependent_option(BUILD_BENCHMARK_TUNING
"Build extra benchmarks for kernel configuration tuning" OFF "BUILD_BENCHMARK" OFF)
"Build extra benchmarks for kernel configuration tuning" OFF "BUILD_BENCHMARK" OFF)
option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF)
option(CODE_COVERAGE "Build with code coverage flags (clang only)" OFF)
option(DEPENDENCIES_FORCE_DOWNLOAD "Don't search the system for dependencies, always download them" OFF)
cmake_dependent_option(RUN_SLOW_TESTS "Run extra tests with CTest. These cover niche functionality and take long time" OFF "BUILD_TEST" OFF)


if (NOT DEFINED ENV{ROCM_PATH})
#Path to ROCm installation
set(ENV{ROCM_PATH} "/opt/rocm")
endif()

# Install prefix
set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "Install path prefix, prepended onto install directories")
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")

if(WIN32)
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_GENERATOR "ZIP")
set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path")
set(INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(CPACK_SET_DESTDIR OFF)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
else()
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")
#Adding CMAKE_PREFIX_PATH
if(NOT DEFINED CMAKE_PREFIX_PATH)
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH})
endif()
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
endif()

# CMake modules
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules
$ENV{ROCM_PATH}/lib/cmake/hip
${HIP_PATH}/cmake $ENV{ROCM_PATH}/hip/cmake # FindHIP.cmake
$ENV{ROCM_PATH}/llvm
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules
$ENV{ROCM_PATH}/lib/cmake/hip
${HIP_PATH}/cmake $ENV{ROCM_PATH}/hip/cmake # FindHIP.cmake
$ENV{ROCM_PATH}/llvm
)

#
Expand Down Expand Up @@ -192,23 +218,6 @@ endif()
# Package (make package)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
if(WIN32)
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_GENERATOR "ZIP")
set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path")
set(INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(CPACK_SET_DESTDIR OFF)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
else()
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")
#Adding CMAKE_PREFIX_PATH
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH} )
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
endif()

if( HIP_RUNTIME_LOWER STREQUAL "rocclr" )
if(BUILD_ADDRESS_SANITIZER)
Expand Down
12 changes: 7 additions & 5 deletions rmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ctypes
import pathlib
from fnmatch import fnmatchcase
import shutil

args = {}
param = {}
Expand Down Expand Up @@ -106,12 +107,13 @@ def config_cmd():
cmake_options.append( generator )
else:
rocm_path = os.getenv( 'ROCM_PATH', "/opt/rocm")
if (OS_info["ID"] in ['centos', 'rhel']):
cmake_executable = "cmake3"
else:
cmake_executable = "cmake"

cmake_executable = 'cmake'
if shutil.which('cmake3') is not None:
cmake_executable = 'cmake3'

toolchain = "toolchain-linux.cmake"
cmake_platform_opts = f"-DROCM_DIR:PATH={rocm_path} -DCPACK_PACKAGING_INSTALL_PREFIX={rocm_path}"
cmake_platform_opts = [f"-DROCM_DIR:PATH={rocm_path}", f"-DCPACK_PACKAGING_INSTALL_PREFIX={rocm_path}"]

tools = f"-DCMAKE_TOOLCHAIN_FILE={toolchain}"
cmake_options.append( tools )
Expand Down
18 changes: 13 additions & 5 deletions toolchain-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
#set(CMAKE_GENERATOR "Ninja")
# Ninja doesn't support platform
#set(CMAKE_GENERATOR_PLATFORM x64)
if (NOT python)
set(python "python3") # default for linux
endif()

if (DEFINED ENV{ROCM_PATH})
set(rocm_bin "$ENV{ROCM_PATH}/bin")
else()
set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to the ROCm installation.")
set(rocm_bin "/opt/rocm/bin")

if (NOT DEFINED ENV{ROCM_PATH})
set(ENV{ROCM_PATH} "/opt/rocm" CACHE PATH "Path to the ROCm installation.")
endif()

message("$ENV{ROCM_PATH}")

set(rocm_bin "$ENV{ROCM_PATH}/bin")
if (NOT DEFINED CMAKE_PREFIX_PATH)
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH})
endif()

if (NOT DEFINED ENV{CXX})
Expand Down
Loading