adding new rpp package (#38942)

* initial commit for adding new rpp package
* fix styling
This commit is contained in:
afzpatel 2023-08-15 17:04:35 -04:00 committed by GitHub
parent 36394aab2f
commit 87d4bdaa02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 189 additions and 0 deletions

View file

@ -28,3 +28,5 @@ class Half(Package):
def install(self, spec, prefix): def install(self, spec, prefix):
mkdirp(prefix.include) mkdirp(prefix.include)
install_tree("include", prefix.include) install_tree("include", prefix.include)
mkdirp(prefix.include.half)
symlink("../half.hpp", join_path(self.prefix.include.half, "half.hpp"))

View file

@ -0,0 +1,80 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae50d00..c2deefc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -129,7 +129,9 @@ include_directories(${Boost_INCLUDE_DIRS})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
# OpenMP
-find_package(OpenMP REQUIRED)
+find_path(HALF_INCLUDE_DIR half.hpp)
+message(STATUS "HALF_INCLUDE_DIR: ${HALF_INCLUDE_DIR}")
+
if(APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}")
@@ -151,7 +153,7 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
-set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} OpenMP::OpenMP_CXX)
+ set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCM_OPENMP_EXTRAS_DIR}/lib/libomp.so)
# Threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -269,6 +271,8 @@ target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${ROCM_PATH}/include
+ ${HALF_INCLUDE_DIR}
+ ${ROCM_OPENMP_EXTRAS_DIR}/include
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/include/cpu
${CMAKE_CURRENT_SOURCE_DIR}/src/include/common
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
index f133128..65cb6d5 100644
--- a/src/modules/CMakeLists.txt
+++ b/src/modules/CMakeLists.txt
@@ -81,6 +81,8 @@ if("${TIME_INFO}" STREQUAL "1")
endif()
# Backend specific settings
+find_path(HALF_INCLUDE_DIR half.hpp)
+message(STATUS "HALF_INCLUDE_DIR: ${HALF_INCLUDE_DIR}")
if( "${BACKEND}" STREQUAL "HIP")
# Add HIP kernels
@@ -99,7 +101,7 @@ if( "${BACKEND}" STREQUAL "HIP")
# Add HIP specific includes
set(ROCM_INC ${ROCM_PATH}/include/)
list(APPEND HIP_LOCAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/include/hip/ ${CMAKE_SOURCE_DIR}/src/include/common/)
- set(INCLUDE_LIST ${ROCM_INC} ${HIP_LOCAL_INCLUDE_DIRS} ${INCLUDE_LIST})
+ set(INCLUDE_LIST ${ROCM_INC} ${HIP_LOCAL_INCLUDE_DIRS} ${INCLUDE_LIST} ${HALF_INCLUDE_DIR} ${ROCM_OPENMP_EXTRAS_DIR}/include)
elseif( "${BACKEND}" STREQUAL "OCL")
# Add OpenCL kernels
file(GLOB MOD_CL_CPP "cl/*.cpp" )
@@ -114,7 +116,7 @@ elseif( "${BACKEND}" STREQUAL "OCL")
# Add OpenCL specific includes
set(ROCM_INC ${ROCM_PATH}/include/)
list(APPEND OCL_LOCAL_INCLUDE_LIST ${CMAKE_SOURCE_DIR}/src/include/cl/ ${CMAKE_SOURCE_DIR}/src/include/common/)
- set(INCLUDE_LIST ${ROCM_INC} ${OCL_LOCAL_INCLUDE_LIST} ${INCLUDE_LIST})
+ set(INCLUDE_LIST ${ROCM_INC} ${OCL_LOCAL_INCLUDE_LIST} ${INCLUDE_LIST} ${HALF_INCLUDE_DIR} ${ROCM_OPENMP_EXTRAS_DIR}/include)
elseif( "${BACKEND}" STREQUAL "CPU")
# Add CPU specific includes
set(INCLUDE_LIST ${CMAKE_SOURCE_DIR}/src/include/common/)
@@ -134,6 +136,8 @@ target_include_directories( ${PROJECT_NAME}
PUBLIC
${CMAKE_SOURCE_DIR}/include
${ROCM_INC}
+ ${HALF_INCLUDE_DIR}
+ ${ROCM_OPENMP_EXTRAS_DIR}/include
PRIVATE
${CMAKE_SOURCE_DIR}/src/include/cpu
${CMAKE_SOURCE_DIR}/src/include/common
@@ -152,4 +156,4 @@ elseif( "${BACKEND}" STREQUAL "OCL")
PRIVATE
${CMAKE_SOURCE_DIR}/src/include/cl
)
-endif()
\ No newline at end of file
+endif()

View file

@ -0,0 +1,12 @@
diff --git a/src/include/common/rpp/handle.hpp b/src/include/common/rpp/handle.hpp
index 7dc29e4..6e5ccea 100644
--- a/src/include/common/rpp/handle.hpp
+++ b/src/include/common/rpp/handle.hpp
@@ -99,6 +99,7 @@ struct Handle : rppHandle
// Device handle related
Handle(rppAcceleratorQueue_t stream);
Handle(rppAcceleratorQueue_t stream, size_t nBatchSize);
+ Handle(size_t nBatchSize);
void rpp_destroy_object_gpu();
rppAcceleratorQueue_t GetStream() const;
void SetStream(rppAcceleratorQueue_t streamID) const;

View file

@ -0,0 +1,95 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
from spack.pkg.builtin.boost import Boost
class Rpp(CMakePackage):
"""Radeon Performance Primitives (RPP) library is a comprehensive high-
performance computer vision library for AMD (CPU and GPU) with HIP
and OPENCL back-ends"""
homepage = "https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp"
git = "https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp.git"
url = "https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp/archive/0.97.tar.gz"
maintainers = ["srekolam", "afzpatel"]
tags = ["rocm"]
version("1.1.0", sha256="9b1b9e721df27ee577819710b261071c68b2dccba96d9daf5d0535ee5f0e045f")
version("1.0.0", sha256="040601e356b0a06c4ffb2043320ae822ab0da78af867392002c7b68dbd85989c")
version("0.99", sha256="f1d7ec65d0148ddb7b3ce836a7e058727036df940d72d1683dee590a913fd44a")
version("0.98", sha256="191b5d89bf990ae22b5ef73675b89ed4371c3ce342ab9cc65383fa12ef13086e")
version("0.97", sha256="8ce1a869ff67a29579d87d399d8b0bd97bf12ae1b6b1ca1f161cb8a262fb9939")
variant(
"build_type",
default="Release",
values=("Release", "Debug", "RelWithDebInfo"),
description="CMake build type",
)
# Adding 3 variants OPENCL ,HIP , CPU with HIP as default.
variant("opencl", default=False, description="Use OPENCL as the backend")
variant("hip", default=True, description="Use HIP as backend")
variant("cpu", default=False, description="Use CPU as backend")
patch("0001-include-half-openmp-through-spack-package.patch")
patch("0002-declare-handle-in-header.patch")
def patch(self):
if self.spec.satisfies("+hip"):
filter_file(
"${ROCM_PATH}/llvm", self.spec["llvm-amdgpu"].prefix, "CMakeLists.txt", string=True
)
if self.spec.satisfies("+opencl"):
filter_file(
"${ROCM_PATH}",
self.spec["rocm-opencl"].prefix,
"cmake/FindOpenCL.cmake",
string=True,
)
depends_on("cmake@3.5:", type="build")
depends_on("pkgconfig", type="build")
depends_on(Boost.with_default_variants)
depends_on("boost@1.72.0:1.80.0")
depends_on("bzip2")
depends_on("half")
depends_on("hwloc")
depends_on(
"opencv@4.5:"
"+calib3d+features2d+highgui+imgcodecs+imgproc"
"+video+videoio+flann+photo+objdetect",
type="build",
when="@1.0:",
)
depends_on("libjpeg-turbo", type="build")
depends_on("rocm-openmp-extras")
conflicts("+opencl+hip")
with when("+hip"):
depends_on("hip@5:")
with when("~hip"):
depends_on("rocm-opencl@5:")
def cmake_args(self):
spec = self.spec
args = []
args.append(self.define("ROCM_OPENMP_EXTRAS_DIR", spec["rocm-openmp-extras"].prefix))
if self.spec.satisfies("+opencl"):
args.append(self.define("BACKEND", "OPENCL"))
if self.spec.satisfies("+cpu"):
args.append(self.define("BACKEND", "CPU"))
if self.spec.satisfies("+hip"):
args.append(self.define("BACKEND", "HIP"))
args.append(self.define("HIP_PATH", spec["hip"].prefix))
args.append(
self.define(
"COMPILER_FOR_HIP", "{0}/bin/clang++".format(spec["llvm-amdgpu"].prefix)
)
)
return args