ROCm / aomp

AOMP is an open source Clang/LLVM based compiler with added support for the OpenMP® API on Radeon™ GPUs. Use this repository for releases, issues, documentation, packaging, and examples.
https://github.com/ROCm/aomp
Apache License 2.0
199 stars 45 forks source link

How do I add openmp support when I have built hipcc #695

Open JiaJiDuan opened 9 months ago

JiaJiDuan commented 9 months ago

Hi,I have built all the hipcc related libraries from tag rocm-5.7.0(llvm-project ROCm-Device-Libs ROCm-CompilerSupport ROCT-Thunk-Interface ROCR-Runtime HIPCC clr). I want to add openmp support but don't want to build from scratch.
So what should I do.
My current cmake configuration for llvm-project is cmake -S llvm -B build -G Ninja -DCMAKE_INSTALL_PREFIX=$ROCM_PATH -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="llvm;clang;lld;compiler-rt;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release

JiaJiDuan commented 9 months ago

In aomp with tag rocm-5.7.0. The branch used by each project is actually rocm-3.3.x, why?

estewart08 commented 8 months ago

In aomp with tag rocm-5.7.0. The branch used by each project is actually rocm-3.3.x, why?

The branch used for building ROCm is not kept up to date with AOMP doc updates as they do not apply. AOMP is considered to be a research compiler and is built differently than ROCm. AOMP has separate releases to ROCm that do not match one to one. If you wanted to build a specific version of AOMP then the manifests will have the correct ROCm branches. However, you are building ROCm from 5.7 sources so that involves a different process. That being said the documentation on how to build ROCm openmp support from this repo is lacking and I will work on fixing that.

I would suggest adding -DCLANG_DEFAULT_LINKER=lld to your llvm cmake options.

Adjust SRC_DIR path to point where you are keeping the source files for ROCm.

You can use repo to sync repos needed for openmp-support: $ cd $SRC_DIR $ repo init -u https://github.com/RadeonOpenCompute/ROCm.git -b roc-5.7.x $ repo sync -j4 openmp-extras/aomp openmp-extras/aomp-extras openmp-extras/flang

$ ls $SRC_DIR should look something like this (This process assumes llvm-project, ROCm-Device-Libs, ROCR-Runtime, and ROCT-Thunk-Interface have been built and installed at $ROCM_PATH): llvm-project openmp-extras ROCm-Device-Libs ROCR-Runtime ROCT-Thunk-Interface

$ ls $SRC_DIR/openmp-extras aomp aomp-extras flang

Build openmp-support $ cd $SRC_DIR/openmp-extras/aomp/bin

$ OUT_DIR=$ROCM_PATH SRC_DIR=/path/to/src AOMP=$OUT_DIR/openmp_extras AOMP_STANDALONE_BUILD=0 ROCM_DIR=$OUT_DIR AOMP_APPLY_ROCM_PATCHES=0 AOMP_CHECK_GIT_BRANCH=0 AOMP_REPOS=$SRC_DIR/openmp-extras DEVICELIBS_ROOT=$SRC_DIR/ROCm-Device-Libs ./build_aomp.sh select extras openmp pgmath flang flang_runtime

Finally copy the files to the correct location: $ cp -R $AOMP/devel/* $OUT_DIR/llvm $ cp -R $AOMP/runtime/* $OUT_DIR/llvm

The files are separated for packaging separate devel/runtime packages. This final copy step will not be necessary in the future for source builds as I will streamline that as well.