aomp icon indicating copy to clipboard operation
aomp copied to clipboard

upstream spack package

Open trws opened this issue 5 years ago • 4 comments

I notice in the docs and in the repo there are references to spack, and in fact a partial spack package. Could this be upstreamed so we can start actually using it for downstream packages?

I'm working on fixing up the llvm package in spack to build a working offload compiler with libomptarget. It's working for cuda, but the lack of a working aomp package with appropriate dependencies means no AMD support for now.

trws avatar Dec 09 '19 21:12 trws

Hey Tom, I am a novice at spack. I assume you are talking about this package.py file

# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# ----------------------------------------------------------------------------
from spack import *
class Aomp(MakefilePackage):
    """  llvm openmp compiler from AMD"""
    homepage = "https://github.com/ROCm-Developer-Tools/aomp"
    url      = "https://github.com/ROCm-Developer-Tools/aomp/releases/download/rel_0.7-5/aomp-0.7-5.tar.gz"
    version('0.7-5', sha256='8f3b20e57bf2032d388879429f29b729ce9a46bee5e7ba76976fc77ea48707a7')
    family = 'compiler'
    def edit(self, spec, prefix):
        makefile = FileFilter('Makefile')
    def install(self, spec, prefix):
        make()
        make("install")

**This simple Makefile in the root directory of this repo is used to build aomp using aomp's scripted build that starts with build_aomp.sh **

#-----------------------------------------------------------------------
#
#  Makefile: Makefile to build aomp from release source code/tarball
#
# Set location of symbolic link AOMP. Link will be to versioned AOMP install in parent of ${AOMP)
AOMP ?= /usr/local/aomp
AOMP_REPOS = $(shell pwd)
all:
        AOMP=$(AOMP) AOMP_REPOS=$(AOMP_REPOS) AOMP_CHECK_GIT_BRANCH=0 AOMP_APPLY_ROCM_PATCHES=0 $(AOMP_REPOS)/aomp/bin/build_aomp.sh
install:
        @echo "Installation complete to $(AOMP)"

The build script build_aomp.sh calls a build script for each component in a correct order. This is a standalone build subsystem. There are no rocm dependencies. Each needed rocm component is built from source code that is in that big tarball. For example, one of the directories in the tarball is llvm-project. The build_project.sh script is called to build llvm and clang. This is called from the build_aomp.sh script. You will see the LLVM cmake variables set in the build_project.sh script.

I don't know that you want such a big package. Eventually, I was thinking each of the components would be a package unto itself with a correct set of dependencies. Until such time, I will update the package.py with the sha256 for each release of aomp. Do you still want this to be upstreamed into the public spack repo?

Also, notice that install does NOTHING in the Makefile. This is because build_aomp.sh does both the build and install for each component. This allows some components to use the partial installation to build. For example, the builtin device library (libdevice) is compiled by the clang compiler built by build_project.sh. You control where AOMP installs using the AOMP environment variable. The makefile is setting this to /usr/local/aomp which becomes a symlink to the latest install directory which is $AOMP_0.7-5 for the current tarball. This is so it does not collide with rocm or the AOMP standalone packages (deb and rpm) that install to /usr/lib/aomp

Lastly, as you can read from the release notes, aomp is a big set of patches on the stable llvm, currently llvm-9. You wont see the cool OpenMP 5. stuff in AOMP till we move to stable llvm-10 which should be around Feb or March 2020.

gregrodgers avatar Dec 10 '19 23:12 gregrodgers

On 10 Dec 2019, at 15:08, Greg Rodgers wrote:

Hey Tom, I am a novice at spack. I assume you are talking about this package.py file

Yup, that’s the one.

# Copyright 2013-2019 Lawrence Livermore National Security, LLC and 
other
# Spack Project Developers. See the top-level COPYRIGHT file for 
details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# 
----------------------------------------------------------------------------
from spack import *
class Aomp(MakefilePackage):
    """  llvm openmp compiler from AMD"""
    homepage = "https://github.com/ROCm-Developer-Tools/aomp"
    url      = 
"https://github.com/ROCm-Developer-Tools/aomp/releases/download/rel_0.7-5/aomp-0.7-5.tar.gz"
    version('0.7-5', 
sha256='8f3b20e57bf2032d388879429f29b729ce9a46bee5e7ba76976fc77ea48707a7')
    family = 'compiler'
    def edit(self, spec, prefix):
        makefile = FileFilter('Makefile')
    def install(self, spec, prefix):
        make()
        make("install")

**This simple Makefile in the root directory of this repo is used to build aomp using aomp's scripted build that starts with build_aomp.sh **

#-----------------------------------------------------------------------

Makefile: Makefile to build aomp from release source code/tarball

Set location of symbolic link AOMP. Link will be to versioned AOMP

install in parent of ${AOMP) AOMP ?= /usr/local/aomp AOMP_REPOS = $(shell pwd) all: AOMP=$(AOMP) AOMP_REPOS=$(AOMP_REPOS) AOMP_CHECK_GIT_BRANCH=0 AOMP_APPLY_ROCM_PATCHES=0 $(AOMP_REPOS)/aomp/bin/build_aomp.sh install: @echo "Installation complete to $(AOMP)"

The build script build_aomp.sh calls a build script for each component in a correct order. This is a standalone build subsystem. There are no rocm dependencies. Each needed rocm component is built from source code that is in that big tarball. For example, one of the directories in the tarball is llvm-project. The build_project.sh script is called to build llvm and clang. This is called from the build_aomp.sh script. You will see the LLVM cmake variables set in the build_project.sh script.

I don't know that you want such a big package. Eventually, I was thinking each of the components would be a package unto itself with a correct set of dependencies. Until such time, I will update the package.py with the sha256 for each release of aomp. Do you still want this to be upstreamed into the public spack repo?

Yeah, we really need at least a rocm package and an omp one probably, but what I’m after is to get the aomp build working in the normal llvm package that I maintain in spack. The libomptarget component has support for AMD in it, but says it’s looking for aomp, what all do I need to install for that check to pass?

Ideally we would also have a way to install the actual aomp compiler with all patches as well, but that’s what I’m trying to do right now.

Also, notice that install does NOTHING in the Makefile. This is because build_aomp.sh does both the build and install for each component. This allows some components to use the partial installation to build. For example, the builtin device library (libdevice) is compiled by the clang compiler built by build_project.sh. You control where AOMP installs using the AOMP environment variable. The makefile is setting this to /usr/local/aomp which becomes a symlink to the latest install directory which is $AOMP_0.7-5 for the current tarball. This is so it does not collide with rocm or the AOMP standalone packages (deb and rpm) that install to /usr/lib/aomp

Lastly, as you can read from the release notes, aomp is a big set of patches on the stable llvm, currently llvm-9. You wont see the cool OpenMP 5. stuff in AOMP till we move to stable llvm-10 which should be around Feb or March 2020.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/ROCm-Developer-Tools/aomp/issues/60#issuecomment-564301049

trws avatar Dec 11 '19 18:12 trws

Looking at it, the libomptarget for amdgcn check looks for a complete LLVM but doesn’t check at all for any capabilities of it. That’s probably part one to fix, I’m not sure what all we can do with it like that.

trws avatar Dec 11 '19 18:12 trws

We're also keen to have amdgcn/openmp working from trunk llvm. It's not there yet, you've discovered the initial scaffolding in tree. The deviceRTL will actually build with upstream clang, it's just rather incomplete at present.

The missing parts are the rest of deviceRTL from aomp, a plugin called hsa which is being cleaned up by a colleague for upstreaming, a bunch of clang patches to create the calls to deviceRTL.

That last set of patches are going to be trickier to upstream than the support libraries, but we're working on it.

Options for running code today:

  • install the rocm release package, e.g. from repos
  • install this aomp repo, which is roughly a dev branch for the fortran/openmp part of rocm, currently based on llvm 9, with 10 planned early next year
  • patch trunk with parts of this repo, which shouldn't be too painful

JonChesterfield avatar Dec 11 '19 19:12 JonChesterfield

this is 4 years old, Please reopen issue , or open new one ,

ronlieb avatar Nov 21 '23 16:11 ronlieb