Skip to content

Commit

Permalink
Squashed 'fin/' changes from 53d2563fe..30d699b9e
Browse files Browse the repository at this point in the history
30d699b9e Perf Eval Update (#60)
3535b948c PerfCompile and PerfEval changes (#59)
de79468d2 remove unneccessary solution check, add check for previously modified kernel names (#56)
6924286a2 miopen hash update (#55)
530399575 Refactor googletest infra to align with MIOpen (#53)
71c50d146 Datatype fix for BN (#57)
8abe2f5c6 Perf Eval updates, Add find info (#51)
e1c1ef0f5 filter find compile by solver input (#54)
722feea66 sp/chk precomp kernel 264 (#41)
b9aba2034 Batch norm find compile (#50)
359f3da80 Fix missing link directives in fin binary (#48)
a4020c1ba Cache Miss Fixes (#46)
2ec7ef44d Enable google test and compiling fin in the CI (#47)
8b6b453bc Applicability support for batch norm (#45)
44323aae9 Perf compile/eval for fin (#42)
ebd9aa6bd update member name (#43)
d6d798efe add cu count (#39)
8e1989a9f Add find option for selecting only dynamic solvers (#38)
0e164bf66 setting json version (#37)
f3f7fed18 Remove function redefinition (#36)
e1de51a58 Performance DB de-serialize test (#34)
043cdcdaa Layout support in Fin (#33)
3a1d58236 Hotfix (#32)
ee3f0d543 4.4 Tuning Bugfixes (#31)
832dbe234 Tunability Reporting (#27)
a564a229f include gfx90a_110 (#28)

git-subtree-dir: fin
git-subtree-split: 30d699b9edc014c6076a9649f849bd3c4588d4ab
  • Loading branch information
cderb committed Aug 3, 2022
1 parent 8e0a630 commit 41b34da
Show file tree
Hide file tree
Showing 28 changed files with 4,961 additions and 1,096 deletions.
31 changes: 10 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ else()
endif()

project ( fin C CXX )
option( BUILD_SHARED_LIBS "Build as a shared library" ON )
enable_testing()

find_package(ROCM REQUIRED PATHS /opt/rocm)

Expand All @@ -53,12 +51,6 @@ include(CheckCXXCompilerFlag)

option( BUILD_DEV "Build for development only" OFF)

# Strip symbols for release
if(NOT WIN32 AND NOT APPLE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif()

rocm_setup_version(VERSION 1.0.0)

list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
Expand Down Expand Up @@ -100,15 +92,6 @@ set_property( CACHE FIN_BACKEND PROPERTY STRINGS

# HIP is always required
find_package(hip REQUIRED PATHS /opt/rocm)
find_package(rocblas REQUIRED PATHS /opt/rocm)
# probably not required
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}")

message(STATUS "Hip compiler flags: ${HIP_COMPILER_FLAGS}")

add_definitions("-DHIP_COMPILER_FLAGS=${HIP_COMPILER_FLAGS}")

# OpenCL 1.2
if( FIN_BACKEND STREQUAL "OpenCL")
Expand Down Expand Up @@ -194,7 +177,7 @@ set(CPACK_RPM_PACKAGE_REQUIRES "${MIOPEN_PACKAGE_REQS}, rocm-opencl-devel")
rocm_create_package(
NAME fin-${FIN_BACKEND}
DESCRIPTION "Fin MIOpen Driver"
MAINTAINER "Jehandad Khan <jehandad.khan@amd.com>"
MAINTAINER "Tuna Devs <dl.MITunaX@amd.com>"
LDCONFIG
# DEPENDS rocm-opencl rocm-utils hip-hcc tinygemm
)
Expand All @@ -208,6 +191,8 @@ elseif(FIN_BACKEND STREQUAL "HIP")
set(MIOPEN_TIDY_ERRORS ALL)
endif()

if(NOT MIOPEN_ENABLE_FIN)
message("MIOPEN_ENABLE_FIN is NOT SET")
include(ClangTidy)
enable_clang_tidy(
CHECKS
Expand Down Expand Up @@ -329,9 +314,13 @@ enable_cppcheck(
MIOPEN_USE_MIOPENGEMM=1
__linux__=1
)
else()
message("MIOPEN_ENABLE_FIN is SET")
endif()

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
find_package(miopen)
find_package(rocblas) #MIOpen depends on rocBlas
find_package(Threads REQUIRED)

add_subdirectory(src)
add_subdirectory(tests)
52 changes: 39 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
FROM ubuntu:18.04

ARG PREFIX=/usr/local
ARG PREFIX=/opt/rocm

# Support multiarch
RUN dpkg --add-architecture i386

# Add rocm repository
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl apt-utils wget gnupg2
RUN curl https://raw.githubusercontent.com/RadeonOpenCompute/ROCm-docker/master/add-rocm.sh | bash

#RUN curl https://raw.githubusercontent.com/RadeonOpenCompute/ROCm-docker/master/add-rocm.sh | bash
ARG ROCMVERSION=4.5
ARG DEB_ROCM_REPO=http://repo.radeon.com/rocm/apt/.apt_$ROCMVERSION/
RUN wget -qO - http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -
RUN sh -c "echo deb [arch=amd64] $DEB_ROCM_REPO ubuntu main > /etc/apt/sources.list.d/rocm.list"

# Install dependencies required to build hcc
# Ubuntu csomic contains llvm-7 required to build Tensile
Expand Down Expand Up @@ -69,21 +74,42 @@ RUN pip install https://github.com/pfultz2/cget/archive/57b3289000fcdb3b7e424c60
# Install rclone
RUN pip install https://github.com/pfultz2/rclone/archive/master.tar.gz

# Install hcc from ROCm 3.0
RUN rclone -b roc-3.0.x -c 286651a04d9c3a8e3052dd84b1822985498cd27d https://github.com/RadeonOpenCompute/hcc.git /hcc
RUN LDFLAGS=-fuse-ld=gold cget -p $PREFIX install hcc,/hcc && rm -rf /hcc

# Make sure /opt/rcom is in the paths
ENV PATH="/opt/rocm:${PATH}"
# Install MIOpen
ARG MIOPEN_DIR=/root/dMIOpen
#Clone MIOpen
RUN git clone https://github.com/ROCmSoftwarePlatform/MIOpen.git $MIOPEN_DIR
WORKDIR $MIOPEN_DIR

ARG MIOPEN_DEPS=$MIOPEN_DIR/cget
# Install dependencies
RUN wget --no-check-certificate -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add -
RUN sh -c "echo deb https://apt.kitware.com/ubuntu/ bionic main | tee -a /etc/apt/sources.list"
RUN apt-get update && apt-get install -y --allow-unauthenticated cmake-data=3.15.1-0kitware1 cmake=3.15.1-0kitware1
RUN cget install pfultz2/rocm-recipes
RUN cget install -f min-requirements.txt
RUN CXXFLAGS='-isystem $PREFIX/include' cget install -f ./mlir-requirements.txt

# Build using hcc
RUN cget -p $PREFIX init --cxx $PREFIX/bin/hcc --std=c++14
ARG TUNA_USER=miopenpdb
ARG BACKEND=HIP
# Build MIOpen
WORKDIR $MIOPEN_DIR/build
ARG MIOPEN_BRANCH=05169b091cf3d0b752c94ba51d63f7af6463d731
ARG MIOPEN_CACHE_DIR=/tmp/${TUNA_USER}/cache
ARG MIOPEN_USER_DB_PATH=/tmp/$TUNA_USER/config/miopen
ARG MIOPEN_USE_MLIR=On
RUN git pull && git checkout $MIOPEN_BRANCH
RUN echo "MIOPEN: Selected $BACKEND backend."
RUN if [ $BACKEND = "OpenCL" ]; then \
cmake -DMIOPEN_INSTALL_CXX_HEADERS=On -DMIOPEN_INSTALL_CXX_HEADERS=On -DMIOPEN_USE_COMGR=Off -DMIOPEN_USE_MLIR=${MIOPEN_USE_MLIR} -DMIOPEN_CACHE_DIR=${MIOPEN_CACHE_DIR} -DMIOPEN_USER_DB_PATH={MIOPEN_USER_DB_PATH} -DMIOPEN_BACKEND=OpenCL -DMIOPEN_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ -DCMAKE_PREFIX_PATH="$MIOPEN_DEPS" $MIOPEN_DIR ; \
else \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DMIOPEN_INSTALL_CXX_HEADERS=On -DMIOPEN_USE_COMGR=Off -DMIOPEN_USE_MLIR=${MIOPEN_USE_MLIR} -DMIOPEN_INSTALL_CXX_HEADERS=On -DMIOPEN_CACHE_DIR=${MIOPEN_CACHE_DIR} -DMIOPEN_USER_DB_PATH=${MIOPEN_USER_DB_PATH} -DMIOPEN_BACKEND=$BACKEND -DCMAKE_PREFIX_PATH=$MIOPEN_DEPS $MIOPEN_DIR ; \
fi

RUN make -j $(nproc)
RUN make install

# Install dependencies
ADD requirements.txt /requirements.txt
RUN CXXFLAGS='-isystem $PREFIX/include' cget -p $PREFIX install -f /requirements.txt

# Install doc requirements
#ADD doc/requirements.txt /doc-requirements.txt
#RUN pip install -r /doc-requirements.txt

53 changes: 32 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def rocmnode(name) {

def cmake_build(compiler, flags, prefixpath="/opt/rocm"){
def workspace_dir = pwd()
def vcache = "/var/jenkins/.cache/miopen/vcache"
def archive = (flags == '-DCMAKE_BUILD_TYPE=release')
def config_targets = "all" // "check doc MIOpenDriver"
def config_targets = "all"
def test_flags = "--disable-verification-cache"
def debug_flags = "-g -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined"
def compilerpath = ""
Expand All @@ -46,8 +45,8 @@ def cmake_build(compiler, flags, prefixpath="/opt/rocm"){
rm -rf build
mkdir build
cd build
CXX=${compilerpath} CXXFLAGS='-Werror' cmake ${configargs} -DMIOPEN_GPU_SYNC=On -DMIOPEN_TEST_FLAGS='${test_flags}' -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' ${flags} ..
MIOPEN_DEBUG_CONV_IMPLICIT_GEMM_XDLOPS=1 CTEST_PARALLEL_LEVEL=4 MIOPEN_VERIFY_CACHE_PATH=${vcache} MIOPEN_CONV_PRECISE_ROCBLAS_TIMING=0 dumb-init make -j\$(nproc) ${config_targets}
CXX=${compilerpath} cmake ${configargs} ${flags} ..
dumb-init make -j\$(nproc) ${config_targets}
"""
echo cmd
sh cmd
Expand Down Expand Up @@ -110,26 +109,12 @@ pipeline {
parallelsAlwaysFailFast()
}
environment{
image = "miopen"
image = "fin"
}
stages{
// Run all static analysis tests
stage("Static checks"){
parallel{
stage('Clang Tidy') {
agent{ label rocmnode("rocmtest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX='clang++-3.9' cmake -DBUILD_DEV=On ..; \
make -j\$(nproc) -k analyze;"
}
steps{
buildJob('clang++-3.9', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}

stage('Clang Format') {
agent{ label rocmnode("rocmtest") }
environment{
Expand All @@ -155,11 +140,37 @@ pipeline {
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/usr/local/bin/hcc cmake -DBUILD_DEV=On ..; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DBUILD_DEV=On ..; \
make -j\$(nproc) -k analyze;"
}
steps{
buildJob('hcc', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
stage('Build Fin') {
agent{ label rocmnode("rocmtest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DBUILD_DEV=On -DCMAKE_PREFIX_PATH=/root/dMIOpen/cget ..; \
make -j\$(nproc) all;"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
stage('Fin Tests') {
agent{ label rocmnode("rocmtest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DBUILD_DEV=On -DCMAKE_PREFIX_PATH=/root/dMIOpen/cget ..; \
make -j\$(nproc) check;"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion cmake/EnableCompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#
################################################################################
# - Enable warning all for gcc/clang or use /W4 for visual studio

## Strict warning level
if (MSVC)
# Use the highest warning level for visual studio.
Expand Down
39 changes: 39 additions & 0 deletions cmake/googletest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
include(FetchContent)

set(GOOGLETEST_DIR "" CACHE STRING "Location of local GoogleTest repo to build against")

if(GOOGLETEST_DIR)
set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST ${GOOGLETEST_DIR} CACHE STRING "GoogleTest source directory override")
endif()

message(STATUS "Fetching GoogleTest")

list(APPEND GTEST_CMAKE_CXX_FLAGS
-Wno-undef
-Wno-reserved-identifier
-Wno-global-constructors
-Wno-missing-noreturn
-Wno-disabled-macro-expansion
-Wno-used-but-marked-unused
-Wno-switch-enum
-Wno-zero-as-null-pointer-constant
-Wno-unused-member-function
-Wno-comma
-Wno-old-style-cast
)
message(STATUS "Suppressing googltest warnings with flags: ${GTEST_CMAKE_CXX_FLAGS}")

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929
)

# Will be necessary for windows build
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

target_compile_options(gtest PRIVATE ${GTEST_CMAKE_CXX_FLAGS})
target_compile_options(gtest_main PRIVATE ${GTEST_CMAKE_CXX_FLAGS})
target_compile_options(gmock PRIVATE ${GTEST_CMAKE_CXX_FLAGS})
target_compile_options(gmock_main PRIVATE ${GTEST_CMAKE_CXX_FLAGS})
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
RadeonOpenCompute/rocm-cmake@cdd0f632b3a65bd4411593bb827eb664e25c80bc --build
# ROCmSoftwarePlatform/MIOpen@9b2d37f9f1e4b5492ef8256cf8168363ca5fd2da
nlohmann/json
#ROCmSoftwarePlatform/rocBLAS@9790a8658341bc665c11c311129ad0dfc533d5c4
# RadeonOpenCompute/rocm-cmake@cdd0f632b3a65bd4411593bb827eb664e25c80bc --build
nlohmann/json@v3.10.4

5 changes: 1 addition & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
################################################################################
cmake_minimum_required( VERSION 2.8.12 )
list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip /opt/rocm/hcc /opt/rocm/opencl)
find_package(miopen)

find_package(Threads REQUIRED)

configure_file("${PROJECT_SOURCE_DIR}/src/include/config.h.in" "${PROJECT_BINARY_DIR}/src/include/config.h")

include_directories(include "${PROJECT_BINARY_DIR}/src/include")
add_executable(fin main.cpp fin.cpp base64.cpp)
target_compile_definitions( fin PRIVATE -D__HIP_PLATFORM_HCC__=1 )
target_link_libraries(fin MIOpen ${Boost_LIBRARIES})
target_link_libraries(fin MIOpen ${Boost_LIBRARIES} hip::host)
target_link_libraries(fin ${CMAKE_THREAD_LIBS_INIT})
if(rocblas_FOUND)
target_link_libraries( fin $<BUILD_INTERFACE:roc::rocblas> )
Expand Down
51 changes: 49 additions & 2 deletions src/fin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ miopenDataType_t GetDataType<bfloat16>()
{
return miopenBFloat16;
}
[[gnu::noreturn]] void Fin::Usage()
[[gnu::noreturn]] void BaseFin::Usage()
{
std::cout << "Usage: ./MIOpenFin *base_arg* *other_args*\n";
std::cout << "Supported Base Arguments: conv[fp16][bfp16]\n";
Expand All @@ -37,7 +37,7 @@ void PadBufferSize(size_t& sz, int datatype_sz)
}
}

std::string Fin::ParseBaseArg(const int argc, const char* argv[])
std::string BaseFin::ParseBaseArg(const int argc, const char* argv[])
{
if(argc < 2)
{
Expand All @@ -57,4 +57,51 @@ std::string Fin::ParseBaseArg(const int argc, const char* argv[])
else
return arg;
}
void BaseFin::InitNoGpuHandle(miopen::Handle& handle,
const std::string& arch,
const unsigned long num_cu)
{
#if MIOPEN_MODE_NOGPU
handle.impl->device_name = arch;
handle.impl->num_cu = num_cu;
handle.impl->max_mem_alloc_size = 32UL * 1024 * 1024 * 1024; // 32 GB
handle.impl->global_mem_size = 32UL * 1024 * 1024 * 1024;
handle.impl->target_properties.Init(&handle);
#else
std::ignore = handle;
std::ignore = arch;
std::ignore = num_cu;
#endif
}

void BaseFin::VerifyDevProps(const std::string& in_arch, const unsigned long in_num_cu)
{
std::cerr << "Verifying device properties" << std::endl;
std::string arch = in_arch;
arch = arch.substr(0, arch.find(':'));
const size_t num_cu = in_num_cu;
std::ignore = num_cu;
if(arch == "gfx900")
{
assert(num_cu == 56 || num_cu == 64);
}
else if(arch == "gfx906")
{
assert(num_cu == 60 || num_cu == 64);
}
else if(arch == "gfx908")
{
assert(num_cu == 120);
}
else if(arch == "gfx1030")
{
assert(num_cu == 72 || num_cu == 36);
}
else if(arch == "gfx90a")
{
assert(num_cu == 110 || num_cu == 104);
}
else
throw std::runtime_error("Invalid Arch Name");
}
} // namespace fin
Loading

0 comments on commit 41b34da

Please sign in to comment.