From 0d4dad4dd95c4a645743d63a4ed9ee3386673f26 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 24 Feb 2023 22:06:44 -0500 Subject: opensubdiv cuda 12 --- media-libs/opensubdiv/Manifest | 6 ++ .../opensubdiv-3.3.0-use-gnuinstalldirs.patch | 39 +++++++++ ...ensubdiv-3.4.3-install-tutorials-into-bin.patch | 52 ++++++++++++ ...opensubdiv-3.4.4-add-CUDA12-compatibility.patch | 21 +++++ .../files/opensubdiv-3.4.4-tbb-2021.patch | 65 +++++++++++++++ media-libs/opensubdiv/opensubdiv-3.4.4-r4.ebuild | 94 ++++++++++++++++++++++ 6 files changed, 277 insertions(+) create mode 100644 media-libs/opensubdiv/Manifest create mode 100644 media-libs/opensubdiv/files/opensubdiv-3.3.0-use-gnuinstalldirs.patch create mode 100644 media-libs/opensubdiv/files/opensubdiv-3.4.3-install-tutorials-into-bin.patch create mode 100644 media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA12-compatibility.patch create mode 100644 media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch create mode 100644 media-libs/opensubdiv/opensubdiv-3.4.4-r4.ebuild diff --git a/media-libs/opensubdiv/Manifest b/media-libs/opensubdiv/Manifest new file mode 100644 index 0000000..c1de040 --- /dev/null +++ b/media-libs/opensubdiv/Manifest @@ -0,0 +1,6 @@ +AUX opensubdiv-3.3.0-use-gnuinstalldirs.patch 1133 BLAKE2B f762b52e23c60c2dded82948be891654923adae6a2e4f870857e357478f92cb9a239c282f0d09f75f6f2a58682c50d8f437989859710668071b46b1cde499424 SHA512 4f463fbea3e94e93711888a077faa375054aae193abfbe4c600081fae43efa4adf5dc5687ceb7c59795c20ae97ec158ce4035e72dfdb0c89ee5943e41e58bdef +AUX opensubdiv-3.4.3-install-tutorials-into-bin.patch 2239 BLAKE2B d35a7118b742244f045aa5c0e5e1ab42a8eea98cac377b9fb0efd8948e2b13d2be973aa17714a8554a97061a8de0769861947cf9c890bcf81acff593b3f34ae5 SHA512 2e86d3f73568c16c839d783574abfb765432b3bf9171b73da8eab9c86be4c736912b892879cb04d974046fb90c5fdf2e60669cc94d468d5aec51573c0ffdcaa6 +AUX opensubdiv-3.4.4-add-CUDA12-compatibility.patch 969 BLAKE2B cfc957617b5d4e2c5f92b5e8eba82726fbfba7600547648ea06b4dbc76e7f041ed3a55fc5e0353a112d519482b370d90cfda17b9ecc9b36b189e394de8ba59e6 SHA512 df815b52d5d52cdca70ccefacb4c676668a9119d2a3b59c83bb7604a758dadbfa1147c8962cea6f19625517716b12c82a90890cca97fb53448601c6e17570b89 +AUX opensubdiv-3.4.4-tbb-2021.patch 2147 BLAKE2B 69f1ae0689fa1a21cb6ee74ff1d6cedd474b38881e49cb5887fbc87bd2b2cc71c7b37b782751390426cc200ea2d488909555c698321c50b5891922f6eb7320ae SHA512 adc5a5126bd1433f4edf8239d7cf48755c8c84d688c8d877121598e8833a352cd3da399577dae918c66b1c4f7d90dd5af08e42d86e66a7532e3b0ae2ad59d048 +DIST opensubdiv-3.4.4.tar.gz 39228037 BLAKE2B 53bada3ff2652c6041a3becaf037b593c0e1e4c1bd57a285e6c068c11060b06f9ab0617284a57d0e8974f80082abd6563930ede8b1d6bfb801bfa61dd3256445 SHA512 fc8f28b79347015c8991150535c1339e695d96947c72fadd4fa27b546a0813c1125cd175ee03bed5aacdb3609f74c4e526ef70103d1195ba9f7df041e73ea9fb +EBUILD opensubdiv-3.4.4-r4.ebuild 2446 BLAKE2B b54e745744841b68d854c7b59c8c1ef43d7d403fb80dcc1e49a27d2dfd5c95d5b037221e08e7df15777b66b8a7bf03c60951a641901d0c50007b92303978cff9 SHA512 14b393dce699d009aceda2d6fb0937815f9f0d2c8a108b512810f137de2b5b38d62464a5b4291a2613391aad9472faf2eabcce83c00d178f7181732565a2892f diff --git a/media-libs/opensubdiv/files/opensubdiv-3.3.0-use-gnuinstalldirs.patch b/media-libs/opensubdiv/files/opensubdiv-3.3.0-use-gnuinstalldirs.patch new file mode 100644 index 0000000..0202776 --- /dev/null +++ b/media-libs/opensubdiv/files/opensubdiv-3.3.0-use-gnuinstalldirs.patch @@ -0,0 +1,39 @@ +diff -purN a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2017-07-25 21:58:09.000000000 +0100 ++++ b/CMakeLists.txt 2017-08-15 14:51:36.771044414 +0100 +@@ -23,6 +23,7 @@ + # + + project(OpenSubdiv) ++include(GNUInstallDirs) + + cmake_minimum_required(VERSION 2.8.6) + +@@ -63,15 +64,15 @@ if (NOT DEFINED CMAKE_INSTALL_PREFIX) + endif() + + if (NOT DEFINED CMAKE_INCDIR_BASE) +- set( CMAKE_INCDIR_BASE include/opensubdiv ) ++ set( CMAKE_INCDIR_BASE ${CMAKE_INSTALL_INCLUDEDIR}/opensubdiv ) + endif() + + if (NOT DEFINED CMAKE_BINDIR_BASE) +- set( CMAKE_BINDIR_BASE bin ) ++ set( CMAKE_BINDIR_BASE ${CMAKE_INSTALL_BINDIR} ) + endif() + + if (NOT DEFINED CMAKE_LIBDIR_BASE) +- set( CMAKE_LIBDIR_BASE lib ) ++ set( CMAKE_LIBDIR_BASE ${CMAKE_INSTALL_LIBDIR} ) + endif() + + if (NOT DEFINED CMAKE_FRAMEWORKDIR_BASE) +@@ -83,7 +84,7 @@ if (NOT DEFINED CMAKE_PLUGINDIR_BASE) + endif() + + if (NOT DEFINED CMAKE_DOCDIR_BASE) +- set( CMAKE_DOCDIR_BASE share/doc/opensubdiv ) ++ set( CMAKE_DOCDIR_BASE ${CMAKE_INSTALL_DOCDIR} ) + else() + if (IS_ABSOLUTE ${CMAKE_DOCDIR_BASE}) + set( CMAKE_DOCDIR_BASE "${CMAKE_DOCDIR_BASE}" ) diff --git a/media-libs/opensubdiv/files/opensubdiv-3.4.3-install-tutorials-into-bin.patch b/media-libs/opensubdiv/files/opensubdiv-3.4.3-install-tutorials-into-bin.patch new file mode 100644 index 0000000..f042967 --- /dev/null +++ b/media-libs/opensubdiv/files/opensubdiv-3.4.3-install-tutorials-into-bin.patch @@ -0,0 +1,52 @@ +diff -Naur a/tutorials/far/CMakeLists.txt b/tutorials/far/CMakeLists.txt +--- a/tutorials/far/CMakeLists.txt 2020-05-11 14:48:35.145797436 +1000 ++++ b/tutorials/far/CMakeLists.txt 2020-05-11 14:49:39.445969003 +1000 +@@ -30,7 +30,7 @@ + $ + ) + +- install(TARGETS ${NAME} DESTINATION "${CMAKE_BINDIR_BASE}/tutorials") ++ install(TARGETS ${NAME} DESTINATION "${CMAKE_BINDIR_BASE}") + + endmacro() + +diff -Naur a/tutorials/hbr/tutorial_0/CMakeLists.txt b/tutorials/hbr/tutorial_0/CMakeLists.txt +--- a/tutorials/hbr/tutorial_0/CMakeLists.txt 2020-05-11 14:48:35.145797436 +1000 ++++ b/tutorials/hbr/tutorial_0/CMakeLists.txt 2020-05-11 14:50:38.076125987 +1000 +@@ -30,5 +30,5 @@ + ${SOURCE_FILES} + ) + +-install(TARGETS hbr_tutorial_0 DESTINATION "${CMAKE_BINDIR_BASE}/tutorials") ++install(TARGETS hbr_tutorial_0 DESTINATION "${CMAKE_BINDIR_BASE}") + +diff -Naur a/tutorials/hbr/tutorial_1/CMakeLists.txt b/tutorials/hbr/tutorial_1/CMakeLists.txt +--- a/tutorials/hbr/tutorial_1/CMakeLists.txt 2020-05-11 14:48:35.145797436 +1000 ++++ b/tutorials/hbr/tutorial_1/CMakeLists.txt 2020-05-11 14:50:10.406051839 +1000 +@@ -30,5 +30,5 @@ + ${SOURCE_FILES} + ) + +-install(TARGETS hbr_tutorial_1 DESTINATION "${CMAKE_BINDIR_BASE}/tutorials") ++install(TARGETS hbr_tutorial_1 DESTINATION "${CMAKE_BINDIR_BASE}") + +diff -Naur a/tutorials/hbr/tutorial_2/CMakeLists.txt b/tutorials/hbr/tutorial_2/CMakeLists.txt +--- a/tutorials/hbr/tutorial_2/CMakeLists.txt 2020-05-11 14:48:35.145797436 +1000 ++++ b/tutorials/hbr/tutorial_2/CMakeLists.txt 2020-05-11 14:50:20.706079428 +1000 +@@ -30,5 +30,5 @@ + ${SOURCE_FILES} + ) + +-install(TARGETS hbr_tutorial_2 DESTINATION "${CMAKE_BINDIR_BASE}/tutorials") ++install(TARGETS hbr_tutorial_2 DESTINATION "${CMAKE_BINDIR_BASE}") + +diff -Naur a/tutorials/osd/tutorial_0/CMakeLists.txt b/tutorials/osd/tutorial_0/CMakeLists.txt +--- a/tutorials/osd/tutorial_0/CMakeLists.txt 2020-05-11 14:48:35.145797436 +1000 ++++ b/tutorials/osd/tutorial_0/CMakeLists.txt 2020-05-11 14:50:51.446161856 +1000 +@@ -35,5 +35,5 @@ + osd_static_cpu + ) + +-install(TARGETS osd_tutorial_0 DESTINATION "${CMAKE_BINDIR_BASE}/tutorials") ++install(TARGETS osd_tutorial_0 DESTINATION "${CMAKE_BINDIR_BASE}") + diff --git a/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA12-compatibility.patch b/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA12-compatibility.patch new file mode 100644 index 0000000..413659e --- /dev/null +++ b/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA12-compatibility.patch @@ -0,0 +1,21 @@ +From: "Alexander Golubev" + +Set correct default minimal -arch for CUDA 9 and 11 +--- OpenSubdiv-3_4_4/CMakeLists.txt 2021-11-07 02:01:07.899484952 +0300 ++++ OpenSubdiv-3_4_4/CMakeLists.txt.new 2021-11-07 02:01:23.402764409 +0300 +@@ -587,8 +587,14 @@ + if (NOT DEFINED OSD_CUDA_NVCC_FLAGS) + if (CUDA_VERSION_MAJOR LESS 6) + set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_11 ) +- else() ++ elseif (CUDA_VERSION_MAJOR LESS 9) + set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_20 ) ++ elseif (CUDA_VERSION_MAJOR LESS 11) ++ set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_30 ) ++ elseif (CUDA_VERSION_MAJOR LESS 12) ++ set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_35 ) ++ else() ++ set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_52 ) + endif() + endif() + endif() diff --git a/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch b/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch new file mode 100644 index 0000000..bae9c4a --- /dev/null +++ b/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch @@ -0,0 +1,65 @@ +https://github.com/PixarAnimationStudios/OpenSubdiv/pull/1234 +https://bugs.gentoo.org/820824 + +From 7375c99a4d1337f9b79775fb2c753e7865968642 Mon Sep 17 00:00:00 2001 +From: Artur Sinila +Date: Sun, 25 Jul 2021 20:34:48 +0300 +Subject: [PATCH 1/2] Fix typo: schedular -> scheduler + +--- + opensubdiv/osd/tbbEvaluator.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/opensubdiv/osd/tbbEvaluator.h b/opensubdiv/osd/tbbEvaluator.h +index 6bd365bc5..886a94837 100644 +--- a/opensubdiv/osd/tbbEvaluator.h ++++ b/opensubdiv/osd/tbbEvaluator.h +@@ -1226,7 +1226,7 @@ class TbbEvaluator { + /// \brief synchronize all asynchronous computation invoked on this device. + static void Synchronize(void *deviceContext = NULL); + +- /// \brief initialize tbb task schedular ++ /// \brief initialize tbb task scheduler + /// (optional: client may use tbb::task_scheduler_init) + /// + /// @param numThreads how many threads + +From 9079a517f406afba9ea50657b0a0786ad7a7bdcb Mon Sep 17 00:00:00 2001 +From: Artur Sinila +Date: Sun, 25 Jul 2021 20:58:27 +0300 +Subject: [PATCH 2/2] Support oneTBB 2021 + +--- + opensubdiv/osd/tbbEvaluator.cpp | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/opensubdiv/osd/tbbEvaluator.cpp b/opensubdiv/osd/tbbEvaluator.cpp +index c98db9f6d..66c2ed58f 100644 +--- a/opensubdiv/osd/tbbEvaluator.cpp ++++ b/opensubdiv/osd/tbbEvaluator.cpp +@@ -25,7 +25,8 @@ + #include "../osd/tbbEvaluator.h" + #include "../osd/tbbKernel.h" + +-#include ++#define TBB_PREVIEW_GLOBAL_CONTROL true ++#include + + namespace OpenSubdiv { + namespace OPENSUBDIV_VERSION { +@@ -215,10 +216,11 @@ TbbEvaluator::Synchronize(void *) { + /* static */ + void + TbbEvaluator::SetNumThreads(int numThreads) { +- if (numThreads == -1) { +- tbb::task_scheduler_init init; +- } else { +- tbb::task_scheduler_init init(numThreads); ++ if (numThreads != -1) { ++ tbb::global_control tbb_global_control( ++ tbb::global_control::max_allowed_parallelism, ++ numThreads ++ ); + } + } + diff --git a/media-libs/opensubdiv/opensubdiv-3.4.4-r4.ebuild b/media-libs/opensubdiv/opensubdiv-3.4.4-r4.ebuild new file mode 100644 index 0000000..d33eaf9 --- /dev/null +++ b/media-libs/opensubdiv/opensubdiv-3.4.4-r4.ebuild @@ -0,0 +1,94 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +CMAKE_MAKEFILE_GENERATOR=emake + +inherit cmake cuda toolchain-funcs + +MY_PV="$(ver_rs "1-3" '_')" +DESCRIPTION="An Open-Source subdivision surface library" +HOMEPAGE="https://graphics.pixar.com/opensubdiv/docs/intro.html" +SRC_URI="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz" +S="${WORKDIR}/OpenSubdiv-${MY_PV}" + +# Modfied Apache-2.0 license, where section 6 has been replaced. +# See for example CMakeLists.txt for details. +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="amd64 ~arm ~arm64 ~x86" +IUSE="cuda examples opencl openmp ptex tbb test tutorials" +RESTRICT="!test? ( test )" + +RDEPEND=" + media-libs/glew:= + media-libs/glfw:= + x11-libs/libXinerama + cuda? ( dev-util/nvidia-cuda-toolkit:* ) + opencl? ( virtual/opencl ) + ptex? ( media-libs/ptex ) +" +DEPEND=" + ${RDEPEND} + tbb? ( dev-cpp/tbb:= ) +" + +PATCHES=( + "${FILESDIR}/${PN}-3.3.0-use-gnuinstalldirs.patch" + "${FILESDIR}/${PN}-3.4.3-install-tutorials-into-bin.patch" + "${FILESDIR}/${P}-add-CUDA12-compatibility.patch" + "${FILESDIR}/${PN}-3.4.4-tbb-2021.patch" +) + +pkg_pretend() { + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +} + +pkg_setup() { + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +} + +src_prepare() { + cmake_src_prepare + + use cuda && cuda_src_prepare +} + +src_configure() { + # GLTESTS are disabled as portage is unable to open a display during test phase + # TODO: virtx work? + local mycmakeargs=( + -DGLEW_LOCATION="${ESYSROOT}/usr/$(get_libdir)" + -DGLFW_LOCATION="${ESYSROOT}/usr/$(get_libdir)" + -DNO_CLEW=ON + -DNO_CUDA=$(usex !cuda) + # Docs needed Python 2 so disabled + # bug #815172 + -DNO_DOC=ON + -DNO_EXAMPLES=$(usex !examples) + -DNO_GLTESTS=ON + -DNO_OMP=$(usex !openmp) + -DNO_OPENCL=$(usex !opencl) + -DNO_PTEX=$(usex !ptex) + -DNO_REGRESSION=$(usex !test) + -DNO_TBB=$(usex !tbb) + -DNO_TESTS=$(usex !test) + -DNO_TUTORIALS=$(usex !tutorials) + ) + + if use cuda; then + # old cmake CUDA module doesn't use environment variable to initialize flags + mycmakeargs+=( -DCUDA_NVCC_FLAGS="${NVCCFLAGS}" ) + + # check if user provided --gpu-architecture/-arch flag and prevent cmake from overriding it if so + for f in ${NVCCFLAGS}; do + if [[ ${f} == -arch* || ${f} == --gpu-architecture* ]]; then + mycmakeargs+=( -DOSD_CUDA_NVCC_FLAGS="" ) + break + fi + done + fi + + cmake_src_configure +} -- cgit v1.2.3