diff options
author | afzpatel <122491982+afzpatel@users.noreply.github.com> | 2023-11-16 13:29:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 10:29:00 -0800 |
commit | 8d2e76e8b5c14a9c0604abff8fa0e653402dbc57 (patch) | |
tree | c5c77c8d7c260d4082ed93cbd88264eb1641b228 | |
parent | 0798bd0915a49e4ea267ca1c01f03ee661627588 (diff) | |
download | spack-8d2e76e8b5c14a9c0604abff8fa0e653402dbc57.tar.gz spack-8d2e76e8b5c14a9c0604abff8fa0e653402dbc57.tar.bz2 spack-8d2e76e8b5c14a9c0604abff8fa0e653402dbc57.tar.xz spack-8d2e76e8b5c14a9c0604abff8fa0e653402dbc57.zip |
enable rocAL and add MIVisionX tests (#39630)
* initial commit to enable rocAL and add MIVisionX tests
* fix styling
* updated checksum for libjpeg patches
* update for 5.6
* use satisfies for checking spec version
6 files changed, 239 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/libjpeg-turbo/package.py b/var/spack/repos/builtin/packages/libjpeg-turbo/package.py index a30e29b138..2542555785 100644 --- a/var/spack/repos/builtin/packages/libjpeg-turbo/package.py +++ b/var/spack/repos/builtin/packages/libjpeg-turbo/package.py @@ -59,6 +59,22 @@ class LibjpegTurbo(CMakePackage, AutotoolsPackage): variant("shared", default=True, description="Build shared libs") variant("static", default=True, description="Build static libs") variant("jpeg8", default=False, description="Emulate libjpeg v8 API/ABI") + variant( + "partial_decoder", + default=False, + description="add partial_decode_scale functionality required for rocAL", + ) + + patch( + "https://github.com/libjpeg-turbo/libjpeg-turbo/commit/09c71da06a6346dca132db66f26f959f7e4dd5ad.patch?full_index=1", + sha256="4d5bdfb5de5b04399144254ea383f5357ab7beb830b398aeb35b65f21dd6b4b0", + when="@2.0.6 +partial_decoder", + ) + patch( + "https://github.com/libjpeg-turbo/libjpeg-turbo/commit/640d7ee1917fcd3b6a5271aa6cf4576bccc7c5fb.patch?full_index=1", + sha256="dc1ec567c2356b652100ecdc28713bbf25f544e46f7d2947f31a2395c362cc48", + when="@2.0.6 +partial_decoder", + ) # Can use either of these. But in the current version of the package # only nasm is used. In order to use yasm an environmental variable diff --git a/var/spack/repos/builtin/packages/migraphx/package.py b/var/spack/repos/builtin/packages/migraphx/package.py index 81bf1bff2b..09d340d01c 100644 --- a/var/spack/repos/builtin/packages/migraphx/package.py +++ b/var/spack/repos/builtin/packages/migraphx/package.py @@ -131,6 +131,7 @@ class Migraphx(CMakePackage): depends_on("py-pybind11", type="build", when="@:4.0.0") depends_on("py-pybind11@2.6:", type="build", when="@4.1.0:") depends_on("pkgconfig", type="build", when="@5.3.0:") + depends_on("abseil-cpp") for ver in [ "3.5.0", diff --git a/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path-5.6.patch b/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path-5.6.patch new file mode 100644 index 0000000000..364a4a4036 --- /dev/null +++ b/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path-5.6.patch @@ -0,0 +1,13 @@ +diff --git a/rocAL/rocAL/CMakeLists.txt b/rocAL/rocAL/CMakeLists.txt +index 7ae8cb8..195f387 100644 +--- a/rocAL/rocAL/CMakeLists.txt ++++ b/rocAL/rocAL/CMakeLists.txt +@@ -122,6 +122,8 @@ if(NOT Threads_FOUND) + endif() + + if(${BUILD_ROCAL}) ++ find_path(HALF_INCLUDE_DIR half.hpp) ++ include_directories(${HALF_INCLUDE_DIR}) + # AMD OpenVX & VX_RPP + set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} openvx vx_rpp) + # AMD RPP diff --git a/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path.patch b/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path.patch new file mode 100644 index 0000000000..2e935e9cee --- /dev/null +++ b/var/spack/repos/builtin/packages/mivisionx/0001-add-half-include-path.patch @@ -0,0 +1,21 @@ +diff --git a/rocAL/rocAL/CMakeLists.txt b/rocAL/rocAL/CMakeLists.txt +index bb28810..3c97eab 100644 +--- a/rocAL/rocAL/CMakeLists.txt ++++ b/rocAL/rocAL/CMakeLists.txt +@@ -39,6 +39,8 @@ find_package(Boost COMPONENTS ${BOOST_COMPONENTS} QUIET) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads QUIET) + ++find_path(HALF_INCLUDE_DIR half.hpp) ++ + if( GPU_SUPPORT AND "${BACKEND}" STREQUAL "HIP") + if(NOT DEFINED HIP_PATH) + if(NOT DEFINED ENV{HIP_PATH}) +@@ -120,6 +122,7 @@ if(NOT Threads_FOUND) + endif() + + if(${BUILD_ROCAL}) ++ include_directories(${HALF_INCLUDE_DIR}) + # AMD OpenVX & RPP + include_directories(${AMDRPP_INCLUDE_DIRS}) + set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} openvx vx_rpp) diff --git a/var/spack/repos/builtin/packages/mivisionx/0002-add-half-include-path-for-tests.patch b/var/spack/repos/builtin/packages/mivisionx/0002-add-half-include-path-for-tests.patch new file mode 100644 index 0000000000..c3aec55979 --- /dev/null +++ b/var/spack/repos/builtin/packages/mivisionx/0002-add-half-include-path-for-tests.patch @@ -0,0 +1,62 @@ +diff --git a/model_compiler/python/nnir_to_clib.py b/model_compiler/python/nnir_to_clib.py +index b688094..26fcfe3 100644 +--- a/model_compiler/python/nnir_to_clib.py ++++ b/model_compiler/python/nnir_to_clib.py +@@ -151,6 +151,10 @@ if (OPENVX_BACKEND_OPENCL_FOUND) + include_directories (${OpenCL_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS}/Headers ) + endif() + ++find_path(HALF_INCLUDE_DIR half.hpp) ++message(STATUS "HALF_INCLUDE_DIR: ${HALF_INCLUDE_DIR}") ++include_directories(${HALF_INCLUDE_DIR}) ++ + find_package(OpenCV QUIET) + include_directories (/opt/rocm/include/mivisionx) + include_directories (${PROJECT_SOURCE_DIR}/lib) +diff --git a/samples/inference/mv_objdetect/CMakeLists.txt b/samples/inference/mv_objdetect/CMakeLists.txt +index 9b92b84..d82b71e 100644 +--- a/samples/inference/mv_objdetect/CMakeLists.txt ++++ b/samples/inference/mv_objdetect/CMakeLists.txt +@@ -50,7 +50,10 @@ if (OPENVX_BACKEND_OPENCL_FOUND) + include_directories (${OpenCL_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS}/Headers ) + endif() + +-include_directories (${ROCM_PATH}/include/mivisionx ${PROJECT_SOURCE_DIR} ) ++find_path(HALF_INCLUDE_DIR half.hpp) ++message(STATUS "HALF_INCLUDE_DIR: ${HALF_INCLUDE_DIR}") ++ ++include_directories (${ROCM_PATH}/include/mivisionx ${PROJECT_SOURCE_DIR} ${HALF_INCLUDE_DIR} ) + link_directories (${ROCM_PATH}/lib ${PROJECT_SOURCE_DIR}/lib) + option (USE_POSTPROC "Use postprocessing module implementation" ON) + set(SOURCES mvobjdetect.cpp mvdeploy_api.cpp visualize.cpp) +diff --git a/utilities/rocAL/rocAL_unittests/CMakeLists.txt b/utilities/rocAL/rocAL_unittests/CMakeLists.txt +index 6500003..20de035 100644 +--- a/utilities/rocAL/rocAL_unittests/CMakeLists.txt ++++ b/utilities/rocAL/rocAL_unittests/CMakeLists.txt +@@ -43,9 +43,10 @@ include(GNUInstallDirs) + + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../amd_openvx/cmake) + ++find_path(HALF_INCLUDE_DIR half.hpp) + find_package(OpenCV QUIET) + find_package(AMDRPP QUIET) +-include_directories(${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal) ++include_directories(${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal ${HALF_INCLUDE_DIR}) + link_directories(${ROCM_PATH}/lib/) + file(GLOB My_Source_Files ./*.cpp) + add_executable(${PROJECT_NAME} ${My_Source_Files}) +diff --git a/utilities/rocAL/rocAL_video_unittests/CMakeLists.txt b/utilities/rocAL/rocAL_video_unittests/CMakeLists.txt +index bd64a5b..3aa6172 100644 +--- a/utilities/rocAL/rocAL_video_unittests/CMakeLists.txt ++++ b/utilities/rocAL/rocAL_video_unittests/CMakeLists.txt +@@ -46,8 +46,8 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../amd_openvx/cmake) + + find_package(OpenCV QUIET) + find_package(AMDRPP QUIET) +- +-include_directories(${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal) ++find_path(HALF_INCLUDE_DIR half.hpp) ++include_directories(${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal ${HALF_INCLUDE_DIR}) + link_directories(${ROCM_PATH}/lib/) + file(GLOB My_Source_Files ./*.cpp) + add_executable(${PROJECT_NAME} ${My_Source_Files}) diff --git a/var/spack/repos/builtin/packages/mivisionx/package.py b/var/spack/repos/builtin/packages/mivisionx/package.py index b298160520..f30ae2a9c2 100644 --- a/var/spack/repos/builtin/packages/mivisionx/package.py +++ b/var/spack/repos/builtin/packages/mivisionx/package.py @@ -116,8 +116,19 @@ class Mivisionx(CMakePackage): variant("opencl", default=False, description="Use OPENCL as the backend") variant("hip", default=True, description="Use HIP as backend") + variant("add_tests", default=False, description="add tests and samples folder") + patch("0001-add-half-include-path.patch", when="@5.5") + patch("0001-add-half-include-path-5.6.patch", when="@5.6:") + patch("0002-add-half-include-path-for-tests.patch", when="@5.5: +add_tests") + + patch( + "https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/commit/da24882438b91a0ae1feee23206b75c1a1256887.patch?full_index=1", + sha256="41caff199224f904ef5dc2cd9c5602d6cfa41eba6af0fcc782942a09dd202ab4", + when="@5.6", + ) conflicts("+opencl", when="@5.6.0:") + conflicts("+add_tests", when="@:5.4") def patch(self): if self.spec.satisfies("@4.2.0"): @@ -179,6 +190,86 @@ class Mivisionx(CMakePackage): "amd_openvx_extensions/amd_nn/nn_hip/CMakeLists.txt", string=True, ) + if self.spec.satisfies("@5.5.0: + hip"): + filter_file( + "${ROCM_PATH}/llvm/bin/clang++", + "{0}/bin/clang++".format(self.spec["llvm-amdgpu"].prefix), + "rocAL/rocAL/rocAL_hip/CMakeLists.txt", + string=True, + ) + if self.spec.satisfies("+add_tests"): + filter_file( + "${ROCM_PATH}/include/mivisionx", + "{0}/include/mivisionx".format(self.spec.prefix), + "tests/amd_migraphx_tests/mnist/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/lib", + "{0}/lib".format(self.spec.prefix), + "tests/amd_migraphx_tests/mnist/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/include/mivisionx", + "{0}/include/mivisionx".format(self.spec.prefix), + "tests/amd_migraphx_tests/resnet50/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/lib", + "{0}/lib".format(self.spec.prefix), + "tests/amd_migraphx_tests/resnet50/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/include/mivisionx", + "{0}/include/mivisionx".format(self.spec.prefix), + "samples/inference/mv_objdetect/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/lib", + "{0}/lib".format(self.spec.prefix), + "samples/inference/mv_objdetect/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/include/mivisionx", + "{0}/include/mivisionx".format(self.spec.prefix), + "model_compiler/python/nnir_to_clib.py", + string=True, + ) + filter_file( + "/opt/rocm", + "{0}".format(self.spec.prefix), + "model_compiler/python/nnir_to_clib.py", + string=True, + ) + filter_file( + "${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal", + "{0}/include/mivisionx/rocal".format(self.spec.prefix), + "utilities/rocAL/rocAL_unittests/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/lib", + "{0}/lib".format(self.spec.prefix), + "utilities/rocAL/rocAL_unittests/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR}/mivisionx/rocal", + "{0}/include/mivisionx/rocal".format(self.spec.prefix), + "utilities/rocAL/rocAL_video_unittests/CMakeLists.txt", + string=True, + ) + filter_file( + "${ROCM_PATH}/lib", + "{0}/lib".format(self.spec.prefix), + "utilities/rocAL/rocAL_video_unittests/CMakeLists.txt", + string=True, + ) depends_on("cmake@3.5:", type="build") depends_on("ffmpeg@:4", type="build", when="@:5.3") @@ -203,7 +294,17 @@ class Mivisionx(CMakePackage): depends_on("miopen-opencl@3.5.0", when="@1.7+opencl") depends_on("miopengemm@1.1.6", when="@1.7+opencl") depends_on("openssl", when="@4.0.0:") - depends_on("libjpeg-turbo", type="build") + depends_on("libjpeg-turbo@2.0.6+partial_decoder", type="build") + depends_on("rpp", when="@5.5:") + depends_on("lmdb", when="@5.5:") + depends_on("py-setuptools", when="@5.6:") + depends_on("py-wheel", when="@5.6:") + depends_on("py-pybind11", when="@5.6:") + depends_on("py-google-api-python-client", when="+add_tests") + depends_on("py-protobuf@3.20.3", type=("build", "run"), when="+add_tests") + depends_on("py-future", when="+add_tests") + depends_on("py-numpy", when="+add_tests") + depends_on("py-pytz", when="+add_tests") conflicts("^cmake@3.22:", when="@:5.0.0") # need to choose atleast one backend and both cannot be set @@ -265,11 +366,15 @@ class Mivisionx(CMakePackage): depends_on("miopen-hip@" + ver, when="@" + ver) for ver in ["5.3.3", "5.4.0", "5.4.3", "5.5.0", "5.5.1", "5.6.0", "5.6.1"]: depends_on("migraphx@" + ver, when="@" + ver) + depends_on("hip@" + ver, when="@" + ver) for ver in ["5.5.0", "5.5.1", "5.6.0", "5.6.1"]: depends_on("rocm-core@" + ver, when="@" + ver) depends_on("python@3.5:", type="build") + def setup_run_environment(self, env): + env.set("MIVISIONX_MODEL_COMPILER_PATH", self.spec.prefix.libexec.mivisionx.model_compiler) + def flag_handler(self, name, flags): spec = self.spec protobuf = spec["protobuf"].prefix.include @@ -290,4 +395,24 @@ class Mivisionx(CMakePackage): args.append(self.define("HIP_PATH", spec["hip"].prefix)) if self.spec.satisfies("~hip~opencl"): args.append(self.define("BACKEND", "CPU")) + if self.spec.satisfies("@5.5:"): + args.append( + self.define("AMDRPP_LIBRARIES", "{0}/lib/librpp.so".format(spec["rpp"].prefix)) + ) + args.append( + self.define("AMDRPP_INCLUDE_DIRS", "{0}/include/rpp".format(spec["rpp"].prefix)) + ) + args.append( + self.define( + "TurboJpeg_LIBRARIES_DIRS", "{0}/lib64".format(spec["libjpeg-turbo"].prefix) + ) + ) + args.append(self.define("CMAKE_INSTALL_PREFIX_PYTHON", spec.prefix)) return args + + @run_after("install") + def add_tests(self): + if self.spec.satisfies("+add_tests"): + install_tree("tests", self.spec.prefix.tests) + install_tree("samples", self.spec.prefix.samples) + install_tree("utilities", self.spec.prefix.utilities) |