diff options
author | estewart08 <ethan.stewart@amd.com> | 2024-09-05 12:27:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 12:27:50 -0500 |
commit | 33621a986017873884d330023935d4b27bb6b198 (patch) | |
tree | 24643df2bd8b7e61cc8125254df388569e7f975b /var | |
parent | 055eb3cd94b9b3721d4e8914dfb9d031523a4b42 (diff) | |
download | spack-33621a986017873884d330023935d4b27bb6b198.tar.gz spack-33621a986017873884d330023935d4b27bb6b198.tar.bz2 spack-33621a986017873884d330023935d4b27bb6b198.tar.xz spack-33621a986017873884d330023935d4b27bb6b198.zip |
[rocm-openmp-extras] - Add support for flang-legacy in 6.1.2 (#46130)
* [rocm-openmp-extras] - Add support for flang-legacy in 6.1.2
* [rocm-openmp-extras] - Remove unused variable flang_legacy_dir
* [rocm-openmp-extras] - Limit flang-legacy build to 6.1 and newer ROCm versions
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/llvm-amdgpu/package.py | 2 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/rocm-openmp-extras/package.py | 80 |
2 files changed, 70 insertions, 12 deletions
diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py index 405ea30a1b..ee98ca82c8 100644 --- a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py +++ b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py @@ -260,7 +260,7 @@ class LlvmAmdgpu(CMakePackage, CompilerPackage): args.append(self.define("LLVM_ENABLE_PROJECTS", llvm_projects)) args.append(self.define("LLVM_ENABLE_RUNTIMES", llvm_runtimes)) args.append(self.define("LLVM_ENABLE_LIBCXX", "OFF")) - args.append(self.define("CLANG_LINK_FLANG_LEGACY", False)) + args.append(self.define("CLANG_LINK_FLANG_LEGACY", True)) args.append(self.define("CMAKE_CXX_STANDARD", 17)) args.append(self.define("FLANG_INCLUDE_DOCS", False)) args.append(self.define("LLVM_BUILD_DOCS", "ON")) diff --git a/var/spack/repos/builtin/packages/rocm-openmp-extras/package.py b/var/spack/repos/builtin/packages/rocm-openmp-extras/package.py index 506a43ec5f..54402bdfc0 100644 --- a/var/spack/repos/builtin/packages/rocm-openmp-extras/package.py +++ b/var/spack/repos/builtin/packages/rocm-openmp-extras/package.py @@ -481,6 +481,9 @@ class RocmOpenmpExtras(Package): os.unlink(os.path.join(bin_dir, "flang1")) if os.path.islink((os.path.join(bin_dir, "flang2"))): os.unlink(os.path.join(bin_dir, "flang2")) + if self.spec.version >= Version("6.1.0"): + if os.path.islink((os.path.join(bin_dir, "flang-legacy"))): + os.unlink(os.path.join(bin_dir, "flang-legacy")) if os.path.islink((os.path.join(lib_dir, "libdevice"))): os.unlink(os.path.join(lib_dir, "libdevice")) if os.path.islink((os.path.join(llvm_prefix, "lib-debug"))): @@ -488,6 +491,11 @@ class RocmOpenmpExtras(Package): os.symlink(os.path.join(omp_bin_dir, "flang1"), os.path.join(bin_dir, "flang1")) os.symlink(os.path.join(omp_bin_dir, "flang2"), os.path.join(bin_dir, "flang2")) + + if self.spec.version >= Version("6.1.0"): + os.symlink( + os.path.join(omp_bin_dir, "flang-legacy"), os.path.join(bin_dir, "flang-legacy") + ) os.symlink(os.path.join(omp_lib_dir, "libdevice"), os.path.join(lib_dir, "libdevice")) os.symlink( os.path.join(openmp_extras_prefix, "lib-debug"), os.path.join(llvm_prefix, "lib-debug") @@ -579,6 +587,40 @@ class RocmOpenmpExtras(Package): components["pgmath"] += flang_common_args + flang_legacy_version = "17.0-4" + + components["flang-legacy-llvm"] = [ + "-DLLVM_ENABLE_PROJECTS=clang", + "-DCMAKE_BUILD_TYPE=Release", + "-DLLVM_ENABLE_ASSERTIONS=ON", + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86", + "-DCLANG_DEFAULT_LINKER=lld", + "-DLLVM_INCLUDE_BENCHMARKS=0", + "-DLLVM_INCLUDE_RUNTIMES=0", + "-DLLVM_INCLUDE_EXAMPLES=0", + "-DLLVM_INCLUDE_TESTS=0", + "-DLLVM_INCLUDE_DOCS=0", + "-DLLVM_INCLUDE_UTILS=0", + "-DCLANG_DEFAULT_PIE_ON_LINUX=0", + "../../rocm-openmp-extras/flang/flang-legacy/{0}/llvm-legacy/llvm".format( + flang_legacy_version + ), + ] + + components["flang-legacy"] = [ + "-DCMAKE_C_COMPILER={0}/clang".format(bin_dir), + "-DCMAKE_CXX_COMPILER={0}/clang++".format(bin_dir), + "../rocm-openmp-extras/flang/flang-legacy/{0}".format(flang_legacy_version), + ] + + if ( + self.compiler.name == "gcc" + and self.compiler.version >= Version("7.0.0") + and self.compiler.version < Version("9.0.0") + ): + components["flang-legacy-llvm"] += ["-DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'"] + components["flang-legacy"] += ["-DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'"] + components["flang"] = [ "../rocm-openmp-extras/flang", "-DFLANG_OPENMP_GPU_AMD=ON", @@ -595,22 +637,38 @@ class RocmOpenmpExtras(Package): ] components["flang-runtime"] += flang_common_args - build_order = ["aomp-extras", "openmp", "openmp-debug", "pgmath", "flang", "flang-runtime"] + build_order = ["aomp-extras", "openmp"] + if self.spec.version >= Version("6.1.0"): + build_order += ["flang-legacy-llvm", "flang-legacy"] + build_order += ["pgmath", "flang", "flang-runtime"] # Override standard CMAKE_BUILD_TYPE for arg in std_cmake_args: found = re.search("CMAKE_BUILD_TYPE", arg) if found: std_cmake_args.remove(arg) for component in build_order: - with working_dir("spack-build-{0}".format(component), create=True): - cmake_args = components[component] - cmake_args.extend(std_cmake_args) - # OpenMP build needs to be run twice(Release, Debug) - if component == "openmp-debug": - cmake_args.append("-DCMAKE_BUILD_TYPE=Debug") - else: + cmake_args = components[component] + cmake_args.extend(std_cmake_args) + if component == "flang-legacy-llvm": + with working_dir("spack-build-{0}/llvm-legacy".format(component), create=True): + cmake_args.append("-DCMAKE_BUILD_TYPE=Release") + cmake(*cmake_args) + make() + elif component == "flang-legacy": + with working_dir("spack-build-flang-legacy-llvm"): cmake_args.append("-DCMAKE_BUILD_TYPE=Release") - cmake(*cmake_args) - make() - make("install") + cmake(*cmake_args) + make() + make("install") + os.symlink(os.path.join(bin_dir, "clang"), os.path.join(omp_bin_dir, "clang")) + else: + with working_dir("spack-build-{0}".format(component), create=True): + # OpenMP build needs to be run twice(Release, Debug) + if component == "openmp-debug": + cmake_args.append("-DCMAKE_BUILD_TYPE=Debug") + else: + cmake_args.append("-DCMAKE_BUILD_TYPE=Release") + cmake(*cmake_args) + make() + make("install") |