Skip to content

Commit

Permalink
Merge branch 'release/rocm-rel-5.3' into jd/master_5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JehandadKhan committed Oct 4, 2022
2 parents 4df6527 + 6c94c7b commit d4272db
Show file tree
Hide file tree
Showing 531 changed files with 346,607 additions and 32,168 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Language: Cpp
AccessModifierOffset: 0
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.kdb filter=lfs diff=lfs merge=lfs -text
2 changes: 2 additions & 0 deletions .lfsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lfs]
fetchexclude = *
122 changes: 101 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ project ( MIOpen C CXX )

enable_testing()

find_package(ROCM REQUIRED PATHS /opt/rocm)
find_package(ROCM 0.7.3 REQUIRED PATHS /opt/rocm)

include(ROCMInstallTargets)
include(ROCMPackageConfigHelpers)
include(ROCMSetupVersion)
include(ROCMInstallSymlinks)
include(ROCMCreatePackage)
include(CheckCXXCompilerFlag)
include(ROCMHeaderWrapper)


set(MIOPEN_ENABLE_SQLITE On CACHE BOOL "")
# Use SQLITE for compiled kernels, when turned off this will use raw files
Expand All @@ -84,7 +86,7 @@ if(NOT WIN32 AND NOT APPLE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif()

rocm_setup_version(VERSION 2.16.0)
rocm_setup_version(VERSION 2.18.0)

list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
include(TargetFlags)
Expand Down Expand Up @@ -131,6 +133,7 @@ else()
option(MIOPEN_DISABLE_SYSDB "Disable sys database access" ${MIOPEN_EMBED_BUILD})
endif()
set(MIOPEN_BINCACHE_PATH "" CACHE STRING "URL or path containing binary cache files to embed")
option(MIOPEN_EMBED_BINCACHE "Embed Binary Cache or KDB" Off)
option(MIOPEN_EMBED_BUILD "Build with the set of embed flags." Off)
option(MIOPEN_DISABLE_USERDB "Disable user database access" ${MIOPEN_EMBED_BUILD})

Expand Down Expand Up @@ -164,7 +167,7 @@ if( MIOPEN_BACKEND STREQUAL "OpenCL")
${CMAKE_INSTALL_PREFIX}/llvm
)
if(MIOPEN_HIP_COMPILER)
message("hip compiler: ${MIOPEN_HIP_COMPILER}")
message(STATUS "hip compiler: ${MIOPEN_HIP_COMPILER}")
else()
message(FATAL_ERROR "hip compiler not found")
endif()
Expand All @@ -190,9 +193,12 @@ message(STATUS "Build with HIP ${hip_VERSION}")
target_flags(HIP_COMPILER_FLAGS hip::device)
# Remove cuda arch flags
string(REGEX REPLACE --cuda-gpu-arch=[a-z0-9]+ "" HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
string(REGEX REPLACE --offload-arch=[a-z0-9]+ "" HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
string(REPLACE "$<LINK_LANGUAGE:CXX>" "1" HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
string(REPLACE "SHELL:" "" HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
string(REGEX REPLACE --offload-arch=[a-z0-9:+-]+ "" HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
# Skip library paths since hip will incorrectly treat it as a source file
string(APPEND HIP_COMPILER_FLAGS " ")
foreach(_unused RANGE 2)
string(REGEX REPLACE " /[^ ]+\\.(a|so) " " " HIP_COMPILER_FLAGS "${HIP_COMPILER_FLAGS}")
endforeach()

# Override HIP version in config.h, if necessary.
# The variables set by find_package() can't be overwritten,
Expand Down Expand Up @@ -251,7 +257,7 @@ if( MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPOC" OR MIOPEN_B
message(STATUS "OpenCL compiler: ${HIP_OC_COMPILER}")
set(HIP_OC_COMPILER "${HIP_OC_COMPILER}")
else()
message(FATAL_ERROR "OpenCL compiler not found")
message(STATUS "OpenCL compiler not found")
endif()

# Hcc's clang always defines __HCC__ even when not using hcc driver
Expand All @@ -263,7 +269,7 @@ if( MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPOC" OR MIOPEN_B
set(MIOPEN_USE_ROCBLAS ON CACHE BOOL "")
if(MIOPEN_USE_ROCBLAS)
find_package(rocblas REQUIRED PATHS /opt/rocm)
message(STATUS "Build with rocblas")
message(STATUS "Build with rocblas ${rocblas_VERSION}")
else()
message(STATUS "Build without rocblas")
endif()
Expand Down Expand Up @@ -352,16 +358,18 @@ endif()
# miopengemm
if(MIOPEN_USE_MIOPENGEMM)
find_package(miopengemm PATHS /opt/rocm)
if(miopengemm_FOUND)
message(STATUS "Build with miopengemm")
set(MIOPEN_USE_MIOPENGEMM 1)
else()
message(STATUS "Build without miopengemm")
if(NOT miopengemm_FOUND)
set(MIOPEN_USE_MIOPENGEMM 0)
endif()
endif()

if(MIOPEN_USE_MIOPENGEMM)
message(STATUS "Build with miopengemm")
else()
if(MIOPEN_BACKEND_OPENCL)
message(FATAL_ERROR "MIOpen OpenCL backend requires MIOpenGEMM")
endif()
message(STATUS "Build without miopengemm")
set(MIOPEN_USE_MIOPENGEMM 0)
endif()

if(MIOPEN_USE_COMGR)
Expand All @@ -387,8 +395,11 @@ message(STATUS "HALF_INCLUDE_DIR: ${HALF_INCLUDE_DIR}")

option( MIOPEN_DEBUG_FIND_DB_CACHING "Use system find-db caching" ON)

# FOR HANDLING ENABLE/DISABLE OPTIONAL BACKWARD COMPATIBILITY for FILE/FOLDER REORG
option(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY "Build with file/folder reorg with backward compatibility enabled" ON)

set( MIOPEN_INSTALL_DIR miopen)
set( DATA_INSTALL_DIR ${MIOPEN_INSTALL_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/miopen )
set( DATA_INSTALL_DIR ${CMAKE_INSTALL_DATAROOTDIR}/miopen )

set(MIOPEN_GPU_SYNC Off CACHE BOOL "")
if(BUILD_DEV)
Expand All @@ -405,8 +416,8 @@ else()
endif()
set(MIOPEN_SYSTEM_FIND_DB_SUFFIX "${MIOPEN_BACKEND}" CACHE PATH "Filename suffix for the system find-db files")

set(MIOPEN_PACKAGE_REQS "hip-rocclr")

set(MIOPEN_PACKAGE_REQS "rocm-clang-ocl, hip-rocclr")
if(MIOPEN_USE_MIOPENGEMM)
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, miopengemm")
endif()
Expand All @@ -415,22 +426,79 @@ if(MIOPEN_USE_ROCBLAS)
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, rocblas")
endif()

set(CPACK_DEBIAN_PACKAGE_DEPENDS "${MIOPEN_PACKAGE_REQS}, rocm-opencl-dev")
set(CPACK_RPM_PACKAGE_REQUIRES "${MIOPEN_PACKAGE_REQS}, rocm-opencl-devel")

# Make backends explicitly conflict
if(MIOPEN_BACKEND STREQUAL "HIP")
# In HIP backend, there is a posibility of COMGR disabled.
# In this case add the clang-ocl as dependency for runtime kernel compilation
if(NOT MIOPEN_USE_COMGR)
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, rocm-clang-ocl")
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${MIOPEN_PACKAGE_REQS}")
set(CPACK_RPM_PACKAGE_REQUIRES "${MIOPEN_PACKAGE_REQS}")

# Make backends explicitly conflict
set(CPACK_DEBIAN_PACKAGE_CONFLICTS miopen-opencl)
set(CPACK_RPM_PACKAGE_CONFLICTS miopen-opencl)

elseif(MIOPEN_BACKEND STREQUAL "OpenCL")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${MIOPEN_PACKAGE_REQS}, rocm-opencl-dev")
set(CPACK_RPM_PACKAGE_REQUIRES "${MIOPEN_PACKAGE_REQS}, rocm-opencl-devel")

# Make backends explicitly conflict
set(CPACK_DEBIAN_PACKAGE_CONFLICTS miopen-hip)
set(CPACK_RPM_PACKAGE_CONFLICTS miopen-hip)
endif()
# Begin KDB component install
function(install_kdb)
set(oneValueArgs NAME COMPONENT_NAME)
cmake_parse_arguments(PARSE "" "${oneValueArgs}" "" ${ARGN})

if(PARSE_NAME)
set(FILE_NAME ${PARSE_NAME})
endif()
STRING(REPLACE - _ FILE_NAME "${ARCH_NAME}")
file(READ "${CMAKE_SOURCE_DIR}/src/kernels/${FILE_NAME}.kdb" FILE_CONTENTS LIMIT 7)
string(STRIP "${FILE_CONTENTS}" FILE_CONTENTS)
if(FILE_CONTENTS STREQUAL "version")
set(LFS_MISSING_FILES ${LFS_MISSING_FILES} ${FILE_NAME}.kdb PARENT_SCOPE)
else()
message("Installing ${FILE_NAME} in component ${PARSE_COMPONENT_NAME}")
rocm_install(FILES
src/kernels/${FILE_NAME}.kdb
DESTINATION ${DATA_INSTALL_DIR}/db
COMPONENT ${PARSE_COMPONENT_NAME})
endif()
endfunction()

# Both the lists below should be in sync always
list(APPEND ARCH_LST gfx90a68 gfx90a6e gfx1030-36 gfx90878 gfx906-64 gfx906-60 gfx900-64 gfx900-56)
list(APPEND ARCH_FILE_LST gfx90a-104kdb gfx90a-110kdb gfx1030-36kdb gfx908-120kdb gfx906-64kdb gfx906-60kdb gfx900-64kdb gfx900-56kdb)

list(LENGTH ARCH_LST FULL_LEN)
math(EXPR ARCH_LST_LEN "${FULL_LEN} - 1")


foreach(IDX RANGE ${ARCH_LST_LEN})
list(GET ARCH_LST ${IDX} ARCH_NAME)
list(GET ARCH_FILE_LST ${IDX} ARCH_FILE_NAME)
install_kdb(
NAME ${ARCH_NAME}
COMPONENT_NAME ${ARCH_FILE_NAME}
)
endforeach()

if(LFS_MISSING_FILES)
string(REPLACE ";" "; " LFS_MISSING_FILES "${LFS_MISSING_FILES}")
message(WARNING "GIT LFS Files not pulled down, skipped: ${LFS_MISSING_FILES}")
set(MIOPEN_NO_LFS_PULLED TRUE CACHE INTERNAL "")
endif()

set(CPACK_COMPONENTS_ALL ${ARCH_FILE_LST})
#end kdb package creation

rocm_create_package(
NAME MIOpen-${MIOPEN_BACKEND}
DESCRIPTION "AMD's DNN Library"
MAINTAINER "Paul Fultz II <paul.fultz@amd.com>"
MAINTAINER "MIOpen Maintainer <miopen-lib.support@amd.com>"
LDCONFIG
# DEPENDS rocm-opencl hip-rocclr tinygemm
)
Expand Down Expand Up @@ -536,6 +604,18 @@ enable_clang_tidy(
-readability-qualified-auto
-readability-redundant-string-init
-readability-uppercase-literal-suffix
#TODO Code Quality WORKAROUND ROCm 5.1 update
-altera-id-dependent-backward-branch
-bugprone-easily-swappable-parameters
-bugprone-implicit-widening-of-multiplication-result
-cert-err33-c
-google-readability-casting
-hicpp-use-emplace
-modernize-use-emplace
-performance-unnecessary-copy-initialization
-readability-container-data-pointer
-readability-identifier-length
-readability-suspicious-call-argument

${MIOPEN_TIDY_CHECKS}
${MIOPEN_TIDY_ERRORS}
Expand Down
47 changes: 32 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
FROM ubuntu:18.04

ARG PREFIX=/usr/local
ARG GPU_ARCH=";"
ARG MIOTENSILE_VER="default"
ARG USE_TARGETID="OFF"
ARG USE_MLIR="OFF"
ARG USE_FIN="OFF"

# Support multiarch
RUN dpkg --add-architecture i386
Expand All @@ -15,24 +10,28 @@ RUN dpkg --add-architecture i386
# unless MLIR library is incompatible with current ROCm.

RUN if [ "$USE_MLIR" = "ON" ] ; \
then export ROCM_APT_VER=.apt_4.3.1;\
else export ROCM_APT_VER=.apt_4.3.1; \
then export ROCM_APT_VER=.apt_5.1;\
else \
export ROCM_APT_VER=.apt_5.1; \
fi && \
echo $ROCM_APT_VER &&\
sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/$ROCM_APT_VER/ xenial main > /etc/apt/sources.list.d/rocm.list'
RUN sh -c "echo deb http://mirrors.kernel.org/ubuntu xenial main universe | tee -a /etc/apt/sources.list"
sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/$ROCM_APT_VER/ ubuntu main > /etc/apt/sources.list.d/rocm.list'
RUN sh -c "echo deb http://mirrors.kernel.org/ubuntu bionic main universe | tee -a /etc/apt/sources.list"

#Add gpg keys
# Install dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
wget \
ca-certificates \
curl \
libnuma-dev \
gnupg && \
gnupg \
apt-utils && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9386B48A1A693C5C && \
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
apt-utils \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
build-essential \
cmake \
comgr \
Expand Down Expand Up @@ -78,6 +77,8 @@ ENV LANG=C.UTF-8
# Install an init system
RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb
RUN dpkg -i dumb-init_*.deb && rm dumb-init_*.deb
# Install cget
RUN pip3 install https://github.com/pfultz2/cget/archive/a426e4e5147d87ea421a3101e6a3beca541c8df8.tar.gz

# Install rbuild
RUN pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/6d78a0553babdaea8d2da5de15cbda7e869594b8.tar.gz
Expand All @@ -94,21 +95,37 @@ ADD requirements.txt /requirements.txt
ADD dev-requirements.txt /dev-requirements.txt
# Install dependencies
# TODO: Add --std=c++14
ARG GPU_ARCH=";"
ARG PREFIX=/usr/local
ARG USE_FIN="OFF"
ARG CCACHE_SECONDARY_STORAGE=""
ARG CCACHE_DIR="/tmp"
RUN env
# RUN cget -p $PREFIX install https://github.com/ccache/ccache/archive/7f1572ae9ca958fa923a66235f6a64a360b03523.tar.gz -DZSTD_FROM_INTERNET=ON -DHIREDIS_FROM_INTERNET=ON
RUN rm -rf /tmp/ccache* && mkdir /tmp/ccache && wget https://github.com/ccache/ccache/archive/7f1572ae9ca958fa923a66235f6a64a360b03523.tar.gz -O /tmp/ccache.tar.gz && \
tar zxvf /tmp/ccache.tar.gz -C /tmp/ && mkdir /tmp/ccache-7f1572ae9ca958fa923a66235f6a64a360b03523/build && \
cd /tmp/ccache-7f1572ae9ca958fa923a66235f6a64a360b03523/build && \
cmake -DZSTD_FROM_INTERNET=ON -DHIREDIS_FROM_INTERNET=ON .. && make -j install
RUN ccache -s
ARG COMPILER_LAUNCHER=""
RUN if [ "$USE_FIN" = "ON" ]; then \
rbuild prepare -s fin -d $PREFIX -DAMDGPU_TARGETS=${GPU_ARCH}; \
rbuild prepare -s fin -d $PREFIX -DAMDGPU_TARGETS=${GPU_ARCH} -DCMAKE_CXX_COMPILER_LAUNCHER="${COMPILER_LAUNCHER}"; \
else \
rbuild prepare -s develop -d $PREFIX -DAMDGPU_TARGETS=${GPU_ARCH}; \
rbuild prepare -s develop -d $PREFIX -DAMDGPU_TARGETS=${GPU_ARCH} -DCMAKE_CXX_COMPILER_LAUNCHER="${COMPILER_LAUNCHER}"; \
fi

RUN ccache -s
# Install doc requirements
ADD doc/requirements.txt /doc-requirements.txt
RUN pip3 install -r /doc-requirements.txt

# Use parallel job to accelerate tensile build
# Workaround for Tensile with TargetID feature
ARG USE_TARGETID="OFF"
RUN if [ "$USE_TARGETID" = "ON" ] ; then export HIPCC_LINK_FLAGS_APPEND='-O3 -parallel-jobs=4' && export HIPCC_COMPILE_FLAGS_APPEND='-O3 -Wno-format-nonliteral -parallel-jobs=4' && rm -f /usr/bin/hipcc; fi

# install last released miopentensile in default (master), install latest commits when MIOTENSILE_VER="latest" (develop)
ARG MIOTENSILE_VER="default"
RUN if [ "$USE_TARGETID" = "OFF" ] ; then echo "MIOpenTensile is not installed."; elif [ "$MIOTENSILE_VER" = "latest" ] ; then cget -p $PREFIX install ROCmSoftwarePlatform/MIOpenTensile@94a9047741d16a8eccd290131b78fb1aa69cdcdf; else cget -p $PREFIX install ROCmSoftwarePlatform/MIOpenTensile@94a9047741d16a8eccd290131b78fb1aa69cdcdf; fi

RUN groupadd -f render
Loading

0 comments on commit d4272db

Please sign in to comment.