Skip to content

Commit ad8cdd8

Browse files
NguyenNhuDiamd-jnovotnyNguyen
authored
[cmake][rocRAND] Updated toolchain-linux.cmake to have proper CMAKE_PREFIX_PATH definitions (#587)
* make rmake compatible with linux * updated tool chain and cmakeList such that CMAKE_PREFIX_PATH is defined * implemented default paramaters * removed CXX default * updated changelog * updated changelog to include rmake fix * Update CHANGELOG.md Co-authored-by: Jeffrey Novotny <[email protected]> * Update CHANGELOG.md Co-authored-by: Jeffrey Novotny <[email protected]> * got rid of extra message call * removed part of code where the CXX_COMPILER was forced changed to g++ or cl if it was not gnu * updated changelog to include new Dependencies.cmake changes * Update CHANGELOG.md Co-authored-by: Jeffrey Novotny <[email protected]> * updated to use google benchmark version 1.8 and cmake version 3.16-3.25 * got rid of run.error_occurred as its no longer supported with google benchmark 1.8 --------- Co-authored-by: Jeffrey Novotny <[email protected]> Co-authored-by: Nguyen <[email protected]>
1 parent cd243ae commit ad8cdd8

File tree

6 files changed

+62
-59
lines changed

6 files changed

+62
-59
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ Documentation for rocRAND is available at
1414

1515
### Changed
1616

17+
* Removed a section in `cmake/Dependencies.cmake` that was forcing `DCMAKE_CXX_COMPILER` to be set to either `cl` or `g++` if the compiler was not `GNU`.
1718
* `--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.
1819
* Removed TBB dependency for multi-core processing of host-side generation.
1920

21+
## Resolved issues
22+
23+
* Fixed an issue where `CMAKE_PREFIX_PATH` was not defined properly in `CMAKELists.txt` and `toolchain-linux.cmake`.
24+
* Fixed an issue in `rmake.py` where `cmake_platform_opts` was sometimes a string instead of a list.
25+
2026
## rocRAND 3.2.0 for ROCm 6.3.0
2127

2228
### Added

CMakeLists.txt

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
24+
cmake_policy(VERSION 3.16...3.25)
2425

2526
# Build options
2627
include(CMakeDependentOption)
@@ -29,22 +30,48 @@ option(BUILD_FORTRAN_WRAPPER "Build Fortran wrapper" OFF)
2930
option(BUILD_TEST "Build tests (requires googletest)" OFF)
3031
option(BUILD_BENCHMARK "Build benchmarks" OFF)
3132
cmake_dependent_option(BUILD_BENCHMARK_TUNING
32-
"Build extra benchmarks for kernel configuration tuning" OFF "BUILD_BENCHMARK" OFF)
33+
"Build extra benchmarks for kernel configuration tuning" OFF "BUILD_BENCHMARK" OFF)
3334
option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF)
3435
option(CODE_COVERAGE "Build with code coverage flags (clang only)" OFF)
3536
option(DEPENDENCIES_FORCE_DOWNLOAD "Don't search the system for dependencies, always download them" OFF)
3637
cmake_dependent_option(RUN_SLOW_TESTS "Run extra tests with CTest. These cover niche functionality and take long time" OFF "BUILD_TEST" OFF)
3738

39+
40+
if (NOT DEFINED ENV{ROCM_PATH})
41+
#Path to ROCm installation
42+
set(ENV{ROCM_PATH} "/opt/rocm")
43+
endif()
44+
3845
# Install prefix
39-
set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "Install path prefix, prepended onto install directories")
46+
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")
47+
48+
if(WIN32)
49+
set(CPACK_SOURCE_GENERATOR "ZIP")
50+
set(CPACK_GENERATOR "ZIP")
51+
set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path")
52+
set(INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
53+
set(CPACK_SET_DESTDIR OFF)
54+
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
55+
set(CPACK_PACKAGING_INSTALL_PREFIX "")
56+
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
57+
else()
58+
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")
59+
#Adding CMAKE_PREFIX_PATH
60+
if(NOT DEFINED CMAKE_PREFIX_PATH)
61+
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH})
62+
endif()
63+
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
64+
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
65+
endif()
66+
endif()
4067

4168
# CMake modules
4269
list(APPEND CMAKE_MODULE_PATH
43-
${CMAKE_CURRENT_SOURCE_DIR}/cmake
44-
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules
45-
$ENV{ROCM_PATH}/lib/cmake/hip
46-
${HIP_PATH}/cmake $ENV{ROCM_PATH}/hip/cmake # FindHIP.cmake
47-
$ENV{ROCM_PATH}/llvm
70+
${CMAKE_CURRENT_SOURCE_DIR}/cmake
71+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules
72+
$ENV{ROCM_PATH}/lib/cmake/hip
73+
${HIP_PATH}/cmake $ENV{ROCM_PATH}/hip/cmake # FindHIP.cmake
74+
$ENV{ROCM_PATH}/llvm
4875
)
4976

5077
#
@@ -192,23 +219,6 @@ endif()
192219
# Package (make package)
193220
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
194221
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
195-
if(WIN32)
196-
set(CPACK_SOURCE_GENERATOR "ZIP")
197-
set(CPACK_GENERATOR "ZIP")
198-
set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path")
199-
set(INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
200-
set(CPACK_SET_DESTDIR OFF)
201-
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
202-
set(CPACK_PACKAGING_INSTALL_PREFIX "")
203-
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
204-
else()
205-
set(CMAKE_INSTALL_PREFIX "$ENV{ROCM_PATH}" CACHE PATH "Install path prefix, prepended onto install directories")
206-
#Adding CMAKE_PREFIX_PATH
207-
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH} )
208-
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
209-
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
210-
endif()
211-
endif()
212222

213223
if( HIP_RUNTIME_LOWER STREQUAL "rocclr" )
214224
if(BUILD_ADDRESS_SANITIZER)

benchmark/custom_csv_formater.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,13 @@ inline void customCSVReporter::ReportRuns(const std::vector<Run>& reports)
152152
inline void customCSVReporter::PrintRunData(const Run& run)
153153
{
154154
std::ostream& Out = GetOutputStream();
155-
std::ostream& Err = GetErrorStream();
156155

157156
//get the name of the engine and distribution:
158-
159157
std::string temp = run.benchmark_name();
160-
161158
std::string deviceName = std::string(temp.begin(), temp.begin() + temp.find("<"));
162-
163159
temp.erase(0, temp.find("<") + 1);
164-
165160
std::string engineName = std::string(temp.begin(), temp.begin() + temp.find(","));
166-
167161
temp.erase(0, engineName.size() + 1);
168-
169162
std::string mode = "default";
170163

171164
if(deviceName != "device_kernel")
@@ -174,7 +167,6 @@ inline void customCSVReporter::PrintRunData(const Run& run)
174167
temp.erase(0, temp.find(",") + 1);
175168
}
176169
std::string disName = std::string(temp.begin(), temp.begin() + temp.find(">"));
177-
178170
std::string lambda = "";
179171

180172
size_t ePos = disName.find("=");
@@ -186,13 +178,6 @@ inline void customCSVReporter::PrintRunData(const Run& run)
186178

187179
Out << engineName << "," << disName << "," << mode << ",";
188180
Out << CsvEscape(run.benchmark_name()) << ",";
189-
if(run.error_occurred)
190-
{
191-
Err << std::string(elements.size() - 3, ',');
192-
Err << "true,";
193-
Err << CsvEscape(run.error_message) << "\n";
194-
return;
195-
}
196181

197182
// Do not print iteration on bigO and RMS report
198183
if(!run.report_big_o && !run.report_rms)

cmake/Dependencies.cmake

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ if(BUILD_TEST)
8080
endif()
8181
endif()
8282

83-
8483
# Benchmark dependencies
8584
if(BUILD_BENCHMARK)
8685
if(NOT DEPENDENCIES_FORCE_DOWNLOAD)
@@ -94,19 +93,12 @@ if(BUILD_BENCHMARK)
9493
message(FATAL_ERROR "DownloadProject.cmake doesn't support multi-configuration generators.")
9594
endif()
9695
set(GOOGLEBENCHMARK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/deps/googlebenchmark CACHE PATH "")
97-
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
98-
# hip-clang cannot compile googlebenchmark for some reason
99-
if(WIN32)
100-
set(COMPILER_OVERRIDE "-DCMAKE_CXX_COMPILER=cl")
101-
else()
102-
set(COMPILER_OVERRIDE "-DCMAKE_CXX_COMPILER=g++")
103-
endif()
104-
endif()
105-
96+
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
97+
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark." OFF)
10698
download_project(
10799
PROJ googlebenchmark
108100
GIT_REPOSITORY https://github.com/google/benchmark.git
109-
GIT_TAG v1.6.1
101+
GIT_TAG v1.8.0
110102
INSTALL_DIR ${GOOGLEBENCHMARK_ROOT}
111103
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_CXX_STANDARD=14 ${COMPILER_OVERRIDE}
112104
LOG_DOWNLOAD TRUE
@@ -116,6 +108,8 @@ if(BUILD_BENCHMARK)
116108
BUILD_PROJECT TRUE
117109
UPDATE_DISCONNECTED TRUE
118110
)
111+
set(HAVE_STD_REGEX ON)
112+
set(RUN_HAVE_STD_REGEX 1)
119113
endif()
120114
find_package(benchmark REQUIRED CONFIG PATHS ${GOOGLEBENCHMARK_ROOT} NO_DEFAULT_PATH)
121115
endif()

rmake.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import ctypes
1111
import pathlib
1212
from fnmatch import fnmatchcase
13+
import shutil
1314

1415
args = {}
1516
param = {}
@@ -109,10 +110,11 @@ def config_cmd():
109110
cmake_options.append( generator )
110111
else:
111112
rocm_path = os.getenv( 'ROCM_PATH', "/opt/rocm")
112-
if (OS_info["ID"] in ['centos', 'rhel']):
113-
cmake_executable = "cmake3"
114-
else:
115-
cmake_executable = "cmake"
113+
114+
cmake_executable = 'cmake'
115+
if shutil.which('cmake3') is not None:
116+
cmake_executable = 'cmake3'
117+
116118
toolchain = "toolchain-linux.cmake"
117119
cmake_platform_opts = [f"-DROCM_DIR:PATH={rocm_path}", f"-DCPACK_PACKAGING_INSTALL_PREFIX={rocm_path}"]
118120

toolchain-linux.cmake

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
#set(CMAKE_GENERATOR "Ninja")
33
# Ninja doesn't support platform
44
#set(CMAKE_GENERATOR_PLATFORM x64)
5+
if (NOT python)
6+
set(python "python3") # default for linux
7+
endif()
58

6-
if (DEFINED ENV{ROCM_PATH})
7-
set(rocm_bin "$ENV{ROCM_PATH}/bin")
8-
else()
9-
set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to the ROCm installation.")
10-
set(rocm_bin "/opt/rocm/bin")
9+
10+
if (NOT DEFINED ENV{ROCM_PATH})
11+
set(ENV{ROCM_PATH} "/opt/rocm" CACHE PATH "Path to the ROCm installation.")
12+
endif()
13+
14+
set(rocm_bin "$ENV{ROCM_PATH}/bin")
15+
if (NOT DEFINED CMAKE_PREFIX_PATH)
16+
list( APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH}/llvm $ENV{ROCM_PATH})
1117
endif()
1218

1319
if (NOT DEFINED ENV{CXX})

0 commit comments

Comments
 (0)