Use independent version of hipFFT for ROCm 4.1 and later
@@ -115,6 +115,7 @@ if use_hip:
'libraries': [
'amdhip64', # was hiprtc and hip_hcc before ROCm 3.8.0
'hipblas',
+ ('hipfft', lambda hip_version: hip_version >= 401),
'hiprand',
'rocfft',
'roctx64',
@@ -452,6 +453,20 @@ def check_library(compiler, includes=(), libraries=(),
return True
+def canonicalize_hip_libraries(hip_version, libraries):
+ def ensure_tuple(x):
+ return x if isinstance(x, tuple) else (x, None)
+ new_libraries = []
+ for library in libraries:
+ lib_name, pred = ensure_tuple(library)
+ if pred is None:
+ new_libraries.append(lib_name)
+ elif pred(hip_version):
+ new_libraries.append(lib_name)
+ libraries.clear()
+ libraries.extend(new_libraries)
+
+
def preconfigure_modules(compiler, settings):
"""Returns a list of modules buildable in given environment and settings.
@@ -520,6 +535,19 @@ def preconfigure_modules(compiler, settings):
if os.path.exists(lib_path):
settings['library_dirs'].append(lib_path)
+ # In ROCm 4.1 and later, we need to use the independent version of
+ # hipfft as well as rocfft. We configure the lists of include
+ # directories and libraries to link here depending on ROCm version
+ # before the configuration process following.
+ if use_hip and module['name'] == 'cuda':
+ if module['check_method'](compiler, settings):
+ hip_version = module['version_method']()
+ if hip_version >= 401:
+ rocm_path = build.get_rocm_path()
+ inc_path = os.path.join(rocm_path, 'hipfft', 'include')
+ settings['include_dirs'].insert(0, inc_path)
+ canonicalize_hip_libraries(hip_version, module['libraries'])
+
print('')
print('-------- Configuring Module: {} --------'.format(
module['name']))
