Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MIOpen 5.2.3 #5630

Merged
merged 7 commits into from
Oct 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
t
pxl-th committed Oct 3, 2022
commit e81e79f8a45c81072c22da918b832c7014172e87
109 changes: 109 additions & 0 deletions M/MIOpen/common.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const NAME = "MIOpen"

const ROCM_GIT = "https://github.com/ROCmSoftwarePlatform/MIOpen"
const GIT_TAGS = Dict(
v"5.2.3" => "36f74ce53b82331a756c42f95f3138498d6f4a66f2fd370cff9ab18281bb1211",
)

const ROCM_PLATFORMS = [
Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11"),
# Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11"),
]
const PRODUCTS = [LibraryProduct(["libMIOpen"], :libMIOpen, ["lib"])]

function configure_build(version)
buildscript = raw"""
cd ${WORKSPACE}/srcdir/rocBLAS*/
mkdir build
export ROCM_PATH=${prefix}
export HIP_PATH=${prefix}/hip
export HIP_PLATFORM=amd
export HIP_RUNTIME=rocclr
export HIP_COMPILER=clang
export HSA_PATH=${prefix}
export HIP_CLANG_PATH=${prefix}/llvm/bin
# Other HIPCC env variables.
export HIPCC_VERBOSE=1
export HIP_LIB_PATH=${prefix}/hip/lib
export DEVICE_LIB_PATH=${prefix}/amdgcn/bitcode
export HIP_CLANG_HCC_COMPAT_MODE=1
# BB compile HIPCC flags:
BB_COMPILE_BASE_DIR=/opt/${target}/${target}
BB_COMPILE_CPP_DIR=${BB_COMPILE_BASE_DIR}/include/c++/*
OMP_DIR=/opt/${target}/lib/gcc/${target}/*/include
BB_COMPILE_FLAGS=" -isystem ${OMP_DIR} -isystem ${BB_COMPILE_CPP_DIR} -isystem ${BB_COMPILE_CPP_DIR}/${target} --sysroot=${BB_COMPILE_BASE_DIR}/sys-root"
# BB link HIPCC flags:
BB_LINK_GCC_DIR=/opt/${target}/lib/gcc/${target}/*
BB_LINK_FLAGS=" --sysroot=${BB_COMPILE_BASE_DIR}/sys-root -B ${BB_LINK_GCC_DIR} -L ${BB_LINK_GCC_DIR} -L ${BB_COMPILE_BASE_DIR}/lib64 -L ${prefix}/lib"
# Set compile & link flags for hipcc.
export HIPCC_COMPILE_FLAGS_APPEND=$BB_COMPILE_FLAGS
export HIPCC_LINK_FLAGS_APPEND=$BB_LINK_FLAGS
export PATH="${prefix}/hip/bin:${prefix}/llvm/bin:${PATH}"
export LD_LIBRARY_PATH="${prefix}/lib:$prefix/hip/lib:${prefix}/llvm/lib:${LD_LIBRARY_PATH}"
# NOTE
# Looking at hcc-cmd, it is clear that it is omitting 'hip/include' directory.
# Therefore we symlink to other directory that it looks at.
mkdir ${prefix}/lib/include
ln -s ${prefix}/hip/include/* ${prefix}/lib/include
# NOTE
# This is needed to avoid errors with zipping files older than 1980.
# See: https://github.com/pypa/wheel/issues/418
unset SOURCE_DATE_EPOCH
pip install -U pip wheel setuptools
CXX=${prefix}/hip/bin/hipcc \
cmake -S . -B build \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_PREFIX_PATH=${prefix} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=${prefix}/hip/bin/hipcc \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DROCM_PATH=${prefix} \
-DBUILD_VERBOSE=ON \
-DBUILD_WITH_TENSILE=ON \
-DBUILD_WITH_TENSILE_HOST=ON \
-DTensile_LIBRARY_FORMAT=yaml \
-DTensile_COMPILER=hipcc \
-DTensile_LOGIC=asm_full \
-DTensile_CODE_OBJECT_VERSION=V3 \
-DTensile_ARCHITECTURE=${AMDGPU_TARGETS} \
-DAMDGPU_TARGETS=${AMDGPU_TARGETS} \
-DBUILD_CLIENTS_TESTS=OFF \
-DBUILD_CLIENTS_BENCHMARKS=OFF \
-DBUILD_CLIENTS_SAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
make -j${nproc} -C build install
install_license ${WORKSPACE}/srcdir/MIOpen*/LICENSE.txt
"""

sources = [
ArchiveSource(
ROCM_GIT * "archive/rocm-$(version).tar.gz", GIT_TAGS[version]),
DirectorySource("../scripts"),
]
dependencies = [
BuildDependency(PackageSpec(; name="ROCmLLVM_jll", version)),
BuildDependency(PackageSpec(; name="rocm_cmake_jll", version)),
Dependency("ROCmCompilerSupport_jll", version),
Dependency("ROCmOpenCLRuntime_jll", version),
Dependency("ROCmDeviceLibs_jll", version),
Dependency("rocminfo_jll", version),
Dependency("hsa_rocr_jll", version),
Dependency("rocBLAS_jll", version),
Dependency("HIP_jll", version),
]
NAME, version, sources, buildscript, ROCM_PLATFORMS, PRODUCTS, dependencies
end
39 changes: 39 additions & 0 deletions M/MIOpen/scripts/rocm-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

ARGS=( "$@" )
PRE_FLAGS=()
POST_FLAGS=()

PRE_FLAGS+=( -target ${target} )
PRE_FLAGS+=( --sysroot=/opt/${target}/${target}/sys-root )
PRE_FLAGS+=( --gcc-toolchain=/opt/${target} )

if [[ " ${ARGS[@]} " != *' -x assembler '* ]]; then
PRE_FLAGS+=( -march=x86-64 )
PRE_FLAGS+=( -mtune=generic )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
COMPILE_CPP_DIR=${COMPILE_BASE_DIR}/include/c++/*
PRE_FLAGS+=(-isystem ${COMPILE_CPP_DIR} -isystem ${COMPILE_CPP_DIR}/${target})

if [[ " ${ARGS[@]} " != *' -c '* ]] && [[ " ${ARGS[@]} " != *' -E '* ]] && [[ " ${ARGS[@]} " != *' -M '* ]] && [[ " ${ARGS[@]} " != *' -fsyntax-only '* ]]; then
POST_FLAGS+=( -rtlib=libgcc )
POST_FLAGS+=( -stdlib=libstdc++ )
POST_FLAGS+=( -fuse-ld=lld )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
LINK_GCC_DIR=/opt/${target}/lib/gcc/${target}/*
POST_FLAGS+=(-B ${LINK_GCC_DIR} -L ${LINK_GCC_DIR} -L ${COMPILE_BASE_DIR}/lib64)

if [[ " ${ARGS[@]} " == *"-march="* ]]; then
echo "BinaryBuilder: Cannot force an architecture via -march" >&2
exit 1
fi

if [ ${USE_CCACHE} == "true" ]; then
CCACHE="ccache"
fi

${CCACHE} ${prefix}/llvm/bin/clang "${PRE_FLAGS[@]}" "${ARGS[@]}" "${POST_FLAGS[@]}"
39 changes: 39 additions & 0 deletions M/MIOpen/scripts/rocm-clang++
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

ARGS=( "$@" )
PRE_FLAGS=()
POST_FLAGS=()

PRE_FLAGS+=( -target ${target} )
PRE_FLAGS+=( --sysroot=/opt/${target}/${target}/sys-root )
PRE_FLAGS+=( --gcc-toolchain=/opt/${target} )

if [[ " ${ARGS[@]} " != *' -x assembler '* ]]; then
PRE_FLAGS+=( -march=x86-64 )
PRE_FLAGS+=( -mtune=generic )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
COMPILE_CPP_DIR=${COMPILE_BASE_DIR}/include/c++/*
PRE_FLAGS+=(-isystem ${COMPILE_CPP_DIR} -isystem ${COMPILE_CPP_DIR}/${target})

if [[ " ${ARGS[@]} " != *' -c '* ]] && [[ " ${ARGS[@]} " != *' -E '* ]] && [[ " ${ARGS[@]} " != *' -M '* ]] && [[ " ${ARGS[@]} " != *' -fsyntax-only '* ]]; then
POST_FLAGS+=( -rtlib=libgcc )
POST_FLAGS+=( -stdlib=libstdc++ )
POST_FLAGS+=( -fuse-ld=lld )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
LINK_GCC_DIR=/opt/${target}/lib/gcc/${target}/*
POST_FLAGS+=(-B ${LINK_GCC_DIR} -L ${LINK_GCC_DIR} -L ${COMPILE_BASE_DIR}/lib64)

if [[ " ${ARGS[@]} " == *"-march="* ]]; then
echo "BinaryBuilder: Cannot force an architecture via -march" >&2
exit 1
fi

if [ ${USE_CCACHE} == "true" ]; then
CCACHE="ccache"
fi

${CCACHE} ${prefix}/llvm/bin/clang++ "${PRE_FLAGS[@]}" "${ARGS[@]}" "${POST_FLAGS[@]}"