Skip to content

Commit

Permalink
Merge pull request #62 from ROCm-Developer-Tools/develop
Browse files Browse the repository at this point in the history
merge develop into mainline
  • Loading branch information
david-salinas committed Jun 14, 2023
2 parents e8a4f17 + d65e8f0 commit d48f284
Show file tree
Hide file tree
Showing 26 changed files with 1,702 additions and 102 deletions.
12 changes: 12 additions & 0 deletions amd/hipcc/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/docs/.sphinx" # Location of package manifests
open-pull-requests-limit: 10
schedule:
interval: "daily"
17 changes: 17 additions & 0 deletions amd/hipcc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Merge files created by git.
*.orig
# Reject files created by patch.
*.rej

# Nested build directory.
/build*

# documentation artifacts
build/
_build/
_images/
_static/
_templates/
_toc.yml
docBin/
_doxygen/
76 changes: 44 additions & 32 deletions amd/hipcc/.jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,18 @@ def hipBuildTest(String backendLabel) {
env.HIP_DIR = "${WORKSPACE}" + "/hip"
}

// Clone hipamd repository
dir("${WORKSPACE}/hipamd") {
// Clone clr repository
dir("${WORKSPACE}/clr") {
git branch: 'develop',
url: 'https://github.com/ROCm-Developer-Tools/hipamd'
credentialsId: 'branch-credentials',
url: 'https://github.com/ROCm-Developer-Tools/clr'
env.CLR_DIR = "${WORKSPACE}" + "/clr"
}

// Clone vdi and opencl for only amd backend server
if (backendLabel =~ /.*amd.*/) {
dir("${WORKSPACE}/ROCm-OpenCL-Runtime") {
git branch:'develop',
url: 'https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime'
env.OPENCL_DIR = "${WORKSPACE}" + "/ROCm-OpenCL-Runtime"
}
dir("${WORKSPACE}/ROCclr") {
git branch:'develop',
url: 'https://github.com/ROCm-Developer-Tools/ROCclr'
env.ROCclr_DIR = "${WORKSPACE}" + "/ROCclr"
}
// Clone hip-tests repository
dir("${WORKSPACE}/hip-tests") {
git branch: 'develop',
url: 'https://github.com/ROCm-Developer-Tools/hip-tests'
}
}

Expand All @@ -50,43 +44,61 @@ def hipBuildTest(String backendLabel) {
}
}

stage("Build - Catch2 framework") {
// Running the build on hipamd workspace
dir("${WORKSPACE}/hipamd") {
stage("BUILD HIP - ${backendLabel}") {
// Running the build on clr workspace
dir("${WORKSPACE}/clr") {
sh """#!/usr/bin/env bash
set -x
rm -rf build
mkdir -p build
cd build
# Check if backend label contains string "amd" or backend host is a server with amd gpu
if [[ $backendLabel =~ amd ]]; then
cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=\$HIP_DIR -DAMD_OPENCL_PATH=\$OPENCL_DIR -DROCCLR_PATH=\$ROCclr_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install ..
cmake -DHIPCC_BIN_DIR=\$HIPCC_DIR/bin -DCLR_BUILD_HIP=ON -DHIP_PATH=\$PWD/install -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install ..
else
export HIP_PLATFORM=nvidia
export HIP_COMPILER=nvcc
export HIP_RUNTIME=cuda
cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install ..
cmake -DHIPCC_BIN_DIR=\$HIPCC_DIR/bin -DCLR_BUILD_HIP=ON -DHIP_PLATFORM=nvidia -DHIP_COMMON_DIR=\$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install ..
fi
make -j\$(nproc)
make install -j\$(nproc)
if [[ $backendLabel =~ amd ]]; then
make build_tests -j\$(nproc)
else
HIP_COMPILER=nvcc HIP_PLATFORM=nvidia make build_tests -j\$(nproc)
fi
"""
}
}

stage('HIP Unit Tests - Catch2 framework') {
dir("${WORKSPACE}/hipamd/build") {
stage("BUILD HIP TESTS - ${backendLabel}") {
// Running the build on HIP TESTS workspace
dir("${WORKSPACE}/hip-tests") {
env.HIP_PATH = "${CLR_DIR}" + "/build/install"
sh """#!/usr/bin/env bash
set -x
rm -rf build
mkdir -p build
cd build
echo "testing $HIP_PATH"
# Check if backend label contains string "amd" or backend host is a server with amd gpu
if [[ $backendLabel =~ amd ]]; then
LLVM_PATH=/opt/rocm/llvm ctest -E 'Unit_hiprtc_saxpy'
cmake -DHIP_PLATFORM=amd ../catch
else
export HIP_PLATFORM=nvidia
cmake -DHIP_PLATFORM=nvidia ../catch
fi
make -j\$(nproc) build_tests
"""
}
}

timeout(time: 1, unit: 'HOURS') {
stage("TEST - ${backendLabel}") {
dir("${WORKSPACE}/hip-tests") {
sh """#!/usr/bin/env bash
set -x
cd build
if [[ $backendLabel =~ amd ]]; then
ctest --overwrite BuildDirectory=. --output-junit hiptest_output_catch_amd.xml
else
make test
ctest --overwrite BuildDirectory=. --output-junit hiptest_output_catch_nvidia.xml -E 'Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior|Unit_hipMemcpy_Positive_Synchronization_Behavior|Unit_hipFreeNegativeHost'
fi
"""
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions amd/hipcc/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

sphinx:
configuration: docs/conf.py

formats: [htmlzip]

python:
version: "3.8"
install:
- requirements: docs/.sphinx/requirements.txt
135 changes: 121 additions & 14 deletions amd/hipcc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,129 @@
cmake_minimum_required(VERSION 3.16.3)
project (hipcc.bin)
cmake_minimum_required(VERSION 3.13.4)

project(hipcc VERSION "1.0.0" LANGUAGES C CXX)
set(hipcc_NAME "${PROJECT_NAME}")

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

find_package(ROCM QUIET)
if(ROCM_FOUND)
include(ROCMSetupVersion)
rocm_setup_version(VERSION "${hipcc_VERSION}")
endif()

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set (LINK_LIBS libstdc++fs.so)
add_executable(hipcc.bin src/hipBin.cpp)
if (NOT WIN32) # C++17 does not require the std lib linking
target_link_libraries(hipcc.bin ${LINK_LIBS} ) # for hipcc.bin
set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK
libstdc++fs.so)

set(HIPCC_BIN
hipcc.bin)
set(HIPCC_SOURCES
src/hipBin.cpp)

set(HIPCONFIG_BIN
hipconfig.bin)
set(HIPCONFIG_SOURCES
src/hipBin.cpp)

add_executable(${HIPCC_BIN} ${HIPCC_SOURCES})
if(NOT WIN32)
# C++17 does not require std lib linking.
target_link_libraries(${HIPCC_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
endif()

add_executable(${HIPCONFIG_BIN} ${HIPCONFIG_SOURCES})
if(NOT WIN32)
# C++17 does not require std lib linking.
target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
endif()

# Copy scripts and batch files to build directory.
file(COPY ${CMAKE_SOURCE_DIR}/bin/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators")
set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support <rocm.compiler.support@amd.com>")
set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_VERSION_MAJOR "${hipcc_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${hipcc_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${hipcc_VERSION_PATCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")

# Debian-specific packaging variables.
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), libfile-basedir-perl, hip-dev, rocm-core, rocm-llvm")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC")
if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
else()
set(CPACK_DEBIAN_PACKAGE_RELEASE "local")
endif()

# RPM-specific packaging variables.
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, perl-File-BaseDir, hip-devel, rocm-core, rocm-llvm")
set(CPACK_RPM_PACKAGE_AUTOREQROV 0)
if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE})
set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE})
else()
set(CPACK_RPM_PACKAGE_RELEASE "local")
endif()
if(CPACK_RPM_PACKAGE_RELEASE)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
endif()

# ROCM versioning.
set(ROCM_VERSION_FOR_PACKAGE "")
if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION})
elseif(DEFINED ENV{ROCM_VERSION})
string(REGEX REPLACE "." "" ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_VERSION})
else()
set(ROCM_VERSION_FOR_PACKAGE "99999")
endif()
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}")

# Exclude Windows specific BAT scripts from install/packaging for Linux.
if (NOT WIN32)
set(exclusion_pattern "*.bat")
else ()
set(exclusion_pattern "")
endif()

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
FILES_MATCHING
PATTERN "*"
PATTERN ${exclusion_pattern} EXCLUDE )

install(FILES
"LICENSE.txt"
"README.md"
COMPONENT ${hipcc_NAME}
DESTINATION ${CMAKE_INSTALL_DOCDIR})

install(TARGETS ${HIPCC_BIN}
COMPONENT ${hipcc_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(TARGETS ${HIPCONFIG_BIN}
COMPONENT ${hipcc_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

project (hipconfig.bin)
add_executable(hipconfig.bin src/hipBin.cpp)
if (NOT WIN32) # C++17 does not require the std lib linking
target_link_libraries(hipconfig.bin ${LINK_LIBS} ) # for hipconfig.bin
# TODO: WIN32 check need to be removed if backward
# compatibility is required for WIN32.
option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON)
if(NOT WIN32)
if(HIPCC_BACKWARD_COMPATIBILITY)
include(hipcc-backward-compat.cmake)
endif()
endif()

set(HIP_VERSION_MAJOR 4 PARENT_SCOPE)
set(HIP_VERSION_MINOR 4 PARENT_SCOPE)
set(HIP_VERSION_PATCH 4 PARENT_SCOPE)
include(CPack)
17 changes: 14 additions & 3 deletions amd/hipcc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
<!-- toc -->

- [hipcc](#hipcc)
* [Documentation](#documentation)
* [Environment Variables](#envVar)
* [Usage](#hipcc-usage)
* [Building](#building)
* [Testing](#testing)
* [Linux](#linux)
* [Windows](#windows)

<!-- tocstop -->

Expand All @@ -20,6 +19,18 @@

`hipcc` will pass-through options to the target compiler. The tools calling hipcc must ensure the compiler options are appropriate for the target compiler.

## Documentation

Run the steps below to build documentation locally.

```
cd docs
pip3 install -r .sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
```

### <a name="envVar"></a> Environment Variables

The environment variable HIP_PLATFORM may be used to specify amd/nvidia:
Expand Down Expand Up @@ -63,4 +74,4 @@ The hipcc and hipconfig executables are created in the current build folder. The

### <a name="testing"></a> hipcc: testing

Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Seperate tests for hipcc/hipconfig is currently not planned.
Currently hipcc/hipconfig executables are tested by building and executing HIP tests. Separate tests for hipcc/hipconfig is currently not planned.
Loading

0 comments on commit d48f284

Please sign in to comment.