Skip to content

Commit b9d4a52

Browse files
authored
Merge pull request #25 from GPUOpen-LibrariesAndSDKs/next-release-3
update to 2.5
2 parents 8071587 + f41cfa8 commit b9d4a52

File tree

7 files changed

+159
-36
lines changed

7 files changed

+159
-36
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2.5.cfa5e2a
2+
- More flexible vector types
3+
- Unifying math into a single header
4+
- Collapse crash fix
5+
- Other minor fixes
6+
17
2.4.c587aa7
28
- H-PLOC and improved wide BVH conversion
39
- CMake support

CMakeLists.txt

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ endfunction()
106106

107107

108108

109-
110-
function(get_hip_sdk_version result)
109+
# 'result' is the HIP version as string, for example: 6.2
110+
# 'result_path' is the output of the path to HIP, for example: C:\Program Files\AMD\ROCm\6.2
111+
function(get_hip_sdk_version result result_path)
111112
if(WIN32)
112113
set(root ".\\")
113114
endif()
@@ -118,7 +119,6 @@ function(get_hip_sdk_version result)
118119
set(useHipFromPATH OFF)
119120

120121

121-
122122
# Check if HIP_PATH is defined as a CMake parameter
123123
if(DEFINED HIP_PATH)
124124
message(STATUS "HIP_PATH is defined as a CMake parameter: ${HIP_PATH}")
@@ -131,8 +131,10 @@ function(get_hip_sdk_version result)
131131

132132
# if HIP_PATH is not in cmake, and not in environment variable
133133
else()
134-
message(STATUS "WARNING: HIP_PATH is not defined as a CMake parameter or an environment variable - not recommended")
134+
message(WARNING "WARNING: HIP_PATH is not defined as a CMake parameter or an environment variable - NOT RECOMMENDED")
135135

136+
# TODO: improve that, but it's not recommanded to use the cmake script without defining HIP_PATH anyway...
137+
set(${result_path} "UNKONWN_PATH" PARENT_SCOPE)
136138

137139
# Check if HIP is in the PATH environment variable
138140
string(REPLACE ";" "\n" PATH_LIST ${PATH})
@@ -152,6 +154,7 @@ function(get_hip_sdk_version result)
152154
if ( HIP_PATH )
153155
remove_trailing_slash(HIP_PATH)
154156
# message(STATUS "HIP_PATH formatted: ${HIP_PATH}")
157+
set(${result_path} ${HIP_PATH} PARENT_SCOPE)
155158
endif()
156159

157160

@@ -167,8 +170,21 @@ function(get_hip_sdk_version result)
167170
set(hipCommand "hipSdk\\bin\\hipcc")
168171
endif()
169172
else()
173+
170174
# HIP_PATH is expected to look like: C:\Program Files\AMD\ROCm\5.7
171-
set(hipCommand "${HIP_PATH}\\bin\\${hipCommand}")
175+
176+
if(EXISTS "${HIP_PATH}\\bin\\hipcc.exe")
177+
# in newer version of HIP SDK (>= 6.3), we are using 'hipcc.exe --version' to check the version
178+
# message(STATUS "using hipcc.exe to get the version")
179+
set(exec_perl "")
180+
set(hipCommand "${HIP_PATH}\\bin\\hipcc.exe")
181+
else()
182+
# in older version of HIP SDK, we are using 'perl hipcc --version' to check the version
183+
# message(STATUS "using perl hipcc to get the version")
184+
set(hipCommand "${HIP_PATH}\\bin\\${hipCommand}")
185+
endif()
186+
187+
172188
endif()
173189
endif()
174190

@@ -200,9 +216,10 @@ endfunction()
200216

201217

202218
# fill the HIP_VERSION_STR variable, it will look like: "6.2"
203-
get_hip_sdk_version(HIP_VERSION_STR)
219+
# also get the path to hip that'll be used along all this cmake.
220+
get_hip_sdk_version(HIP_VERSION_STR HIP_FINAL_PATH)
204221
message(STATUS "HIP_VERSION_STR = ${HIP_VERSION_STR}")
205-
222+
message(STATUS "HIP_FINAL_PATH = ${HIP_FINAL_PATH}")
206223

207224
function(write_version_info in_file header_file version_file version_str_out)
208225

@@ -346,14 +363,16 @@ endif()
346363

347364
# precompile kernels:
348365
if(PRECOMPILE)
366+
message(">> Execute: ${PYTHON_EXECUTABLE} compile.py --nvidia --hipSdkPath \"${HIP_FINAL_PATH}\"")
349367
execute_process(
350-
COMMAND ${PYTHON_EXECUTABLE} compile.py --nvidia --hipSdkPath ${HIP_PATH}
368+
COMMAND ${PYTHON_EXECUTABLE} compile.py --nvidia --hipSdkPath \"${HIP_FINAL_PATH}\"
351369
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/bitcodes
352370
)
353-
371+
354372
if(NOT NO_UNITTEST)
373+
message(">> Execute: ${PYTHON_EXECUTABLE} precompile_bitcode.py --nvidia --hipSdkPath \"${HIP_FINAL_PATH}\"")
355374
execute_process(
356-
COMMAND ${PYTHON_EXECUTABLE} precompile_bitcode.py --nvidia --hipSdkPath ${HIP_PATH}
375+
COMMAND ${PYTHON_EXECUTABLE} precompile_bitcode.py --nvidia --hipSdkPath \"${HIP_FINAL_PATH}\"
357376
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/bitcodes
358377
)
359378
endif()

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ This is the main repository for the source code for HIPRT.
2222
Then, you can use either premake or cmake.
2323

2424
   On Windows with premake:
25-
   5. `.\tools\premake5\win\premake5.exe vs2022`
26-
   6. `Open build\hiprt.sln with Visual Studio 2022.`
25+
   5. `set HIP_PATH=C:\Program Files\AMD\ROCm\6.2\` (optional: change default HIP SDK path)
26+
   6. `.\tools\premake5\win\premake5.exe vs2022`
27+
   7. `Open build\hiprt.sln with Visual Studio 2022.`
2728

2829
   On Linux with premake:
29-
   5. `./tools/premake5/linux64/premake5 gmake`
30-
   6. `make -C build -j config=release_x64`
30+
   5. `export HIP_PATH=/opt/rocm` (optional: change default HIP SDK path)
31+
   6. `./tools/premake5/linux64/premake5 gmake`
32+
   7. `make -C build -j config=release_x64`
3133

3234
   Example with Cmake on Windows:
3335
   5. `mkdir build`

premake5.lua

Lines changed: 101 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ function get_version(file)
9191
return major, minor, patch
9292
end
9393

94+
95+
-- find the path of 'Hipcc' from PATH
96+
-- return nil if not exist
97+
-- only works for linux ( for now )
98+
function findHipccPath()
99+
100+
if os.host() ~= "linux" then
101+
return nil
102+
end
103+
104+
local cmd = 'which hipcc 2>/dev/null'
105+
106+
local f = io.popen(cmd)
107+
local hipccPath = f:read("*a")
108+
f:close()
109+
110+
if hipccPath == nil or hipccPath == '' then
111+
print("hipccPath nil");
112+
return nil
113+
else
114+
print("-- hipccPath = " .. hipccPath );
115+
-- Remove any trailing whitespace
116+
hipccPath = hipccPath:gsub("%s+$", "")
117+
118+
-- Extract the directory from the full path
119+
local dir = hipccPath:match("(.+)/[^/]+$")
120+
return dir
121+
end
122+
end
123+
124+
125+
94126
function get_hip_sdk_verion()
95127

96128
if os.ishost("windows") then
@@ -100,33 +132,68 @@ function get_hip_sdk_verion()
100132
hipCommand = 'hipcc'
101133
HIP_PATH = os.getenv("HIP_PATH")
102134
PATH = os.getenv("PATH")
103-
hipInPath = false
104-
105-
-- check if HIP is in the PATH environement variable
106-
for token in string.gmatch(PATH, "[^;]+") do
107-
if string.find(token, 'hip') then
108-
if os.isfile(path.join(token, 'hipcc')) then
109-
hipInPath = true
110-
end
111-
end
135+
136+
137+
138+
hipccFromPATH = findHipccPath()
139+
if fromPATH ~= nil then
140+
print( "hipcc found from PATH: ".. hipccFromPATH )
112141
end
113142

143+
144+
114145
if os.ishost("windows") then
115-
if hipInPath then
116-
hipCommand = 'hipcc'
117-
elseif not HIP_PATH then
118-
hipCommand = root .. 'hipSdk\\bin\\hipcc'
119-
else
146+
147+
148+
if not HIP_PATH then
149+
-- if the HIP_PATH env var is not set, we assume there is a 'hipSdk' folder at the root of the project.
150+
HIP_PATH = path.getabsolute(root .. 'hipSdk') -- convert the path to absolute
151+
end
152+
120153
if string.sub(HIP_PATH, -1, -1) == '\\' or string.sub(HIP_PATH, -1, -1) == '/' then
121154
HIP_PATH = string.sub(HIP_PATH, 1, -2)
122155
end
156+
123157
-- HIP_PATH is expected to look like: C:\Program Files\AMD\ROCm\5.7
124-
hipCommand = '\"' .. HIP_PATH..'\\bin\\'..hipCommand .. '\"'
158+
print("using HIP_PATH = " .. HIP_PATH)
159+
160+
if os.isfile(HIP_PATH .. '\\bin\\hipcc.exe') then
161+
-- in newer version of HIP SDK (>= 6.3), we are using 'hipcc.exe --version' to check the version
162+
-- print("using hipcc.exe to get the version.")
163+
hipCommand = '\"' .. HIP_PATH..'\\bin\\hipcc.exe\"'
164+
elseif os.isfile(HIP_PATH .. '\\bin\\hipcc') then
165+
-- in older version of HIP SDK, we are using 'perl hipcc --version' to check the version
166+
-- print("using perl hipcc to get the version.")
167+
hipCommand = '\"' .. HIP_PATH..'\\bin\\hipcc\"'
168+
else
169+
print("ERROR: hipcc.exe or hipcc not found in the SDK path.")
170+
hipCommand = 'hipcc'
171+
end
172+
173+
-- for LINUX
174+
else
175+
176+
if not HIP_PATH then
177+
if hipccFromPATH ~= nil then
178+
hipCommand = 'hipcc'
179+
end
180+
181+
-- if HIP_PATH is set, we take the path from it.
182+
else
183+
if string.sub(HIP_PATH, -1, -1) == '\\' or string.sub(HIP_PATH, -1, -1) == '/' then
184+
HIP_PATH = string.sub(HIP_PATH, 1, -2)
185+
end
186+
187+
hipCommand = '\"' .. HIP_PATH..'/bin/hipcc\"'
125188
end
189+
126190
end
127191

192+
128193
tmpFile = os.tmpname ()
129-
os.execute (hipCommand .. " --version > " .. tmpFile)
194+
fullcommand = hipCommand .. " --version > " .. tmpFile
195+
print("Executing: " .. fullcommand);
196+
os.execute (fullcommand)
130197

131198
local version
132199
for line in io.lines (tmpFile) do
@@ -140,9 +207,19 @@ function get_hip_sdk_verion()
140207
version = "HIP_SDK_NOT_FOUND"
141208
end
142209

143-
return version
210+
return version, HIP_PATH
144211
end
145-
212+
213+
214+
215+
hipSdkVersion, hipFinalPath = get_hip_sdk_verion()
216+
print( "HIP_VERSION_STR: "..hipSdkVersion )
217+
if hipFinalPath ~= nil then
218+
print( "HIP SDK path: " .. hipFinalPath )
219+
else
220+
print( "no HIP SDK folder found." )
221+
end
222+
146223
function write_version_info(in_file, header_file, version_file)
147224
if not file_exists(version_file) then
148225
print("Version.txt file missing!\n")
@@ -164,8 +241,6 @@ function write_version_info(in_file, header_file, version_file)
164241
header = header:gsub("@HIPRT_PATCH_VERSION@", HIPRT_PATCH_VERSION)
165242
header = header:gsub("@HIPRT_API_VERSION@", HIPRT_API_VERSION)
166243
header = header:gsub("@HIPRT_VERSION_STR@", "\""..HIPRT_VERSION_STR.."\"")
167-
hipSdkVersion = get_hip_sdk_verion()
168-
print( "HIP_VERSION_STR: "..hipSdkVersion )
169244
header = header:gsub("@HIP_VERSION_STR@", "\""..hipSdkVersion.."\"")
170245
file = io.open(header_file, "w")
171246
file:write(header)
@@ -236,7 +311,12 @@ workspace "hiprt"
236311
end
237312

238313
if _OPTIONS["precompile"] then
239-
os.execute( "cd ./scripts/bitcodes/ && python compile.py")
314+
cmdExec = "cd ./scripts/bitcodes/ && python compile.py"
315+
if hipFinalPath ~= nil then
316+
cmdExec = cmdExec .. " --hipSdkPath \"" .. hipFinalPath .. "\""
317+
end
318+
print("Executing: " .. cmdExec);
319+
os.execute( cmdExec )
240320
end
241321

242322
if _OPTIONS["bakeKernel"] or _OPTIONS["bitcode"] then

scripts/bitcodes/compile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def compileAmd():
9696
'gfx900', 'gfx902', 'gfx904', 'gfx906', 'gfx908', 'gfx909', 'gfx90a', 'gfx90c', 'gfx940', 'gfx941', 'gfx942'] # Vega
9797

9898
if hip_sdk_version_num >= 62: # Navi4 supported from 6.2
99+
gpus.append('gfx1200')
99100
gpus.append('gfx1201')
100101

101102
if hip_sdk_version_num >= 61: # Strix supported from 6.1
@@ -123,6 +124,12 @@ def compileAmd():
123124

124125
print('export built programs ...')
125126
sys.stdout.flush()
127+
128+
if not os.path.exists(root + 'dist/bin/Debug/'):
129+
os.makedirs(root + 'dist/bin/Debug/')
130+
if not os.path.exists(root + 'dist/bin/Release/'):
131+
os.makedirs(root + 'dist/bin/Release/')
132+
126133
if isLinux():
127134
os.system('cp *.hipfb ' + root + 'dist/bin/Debug/')
128135
os.system('cp *.hipfb ' + root + 'dist/bin/Release/')

scripts/bitcodes/precompile_bitcode.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def compileAmd():
102102
hip_version = hip_sdk_version_major +"."+ hip_sdk_version_minor
103103

104104
if hip_sdk_version_num >= 62: # Navi4 supported from 6.2
105+
gpus.append('gfx1200')
105106
gpus.append('gfx1201')
106107

107108
if hip_sdk_version_num >= 61: # Strix supported from 6.1
@@ -134,6 +135,14 @@ def compileAmd():
134135

135136
print('export built programs ...')
136137
sys.stdout.flush()
138+
139+
if not os.path.exists(root + 'dist/bin/Debug/'):
140+
os.makedirs(root + 'dist/bin/Debug/')
141+
if not os.path.exists(root + 'dist/bin/Release/'):
142+
os.makedirs(root + 'dist/bin/Release/')
143+
if not os.path.exists(root + 'hiprt/bitcodes/'):
144+
os.makedirs(root + 'hiprt/bitcodes/')
145+
137146
if isLinux():
138147
os.system('cp *.hipfb ' + root + 'dist/bin/Debug/')
139148
os.system('cp *.hipfb ' + root + 'dist/bin/Release/')

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
2
22
5
3-
cfa5e2a
3+
337242e

0 commit comments

Comments
 (0)