From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 19FF4138334 for ; Tue, 18 Sep 2018 06:39:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4EFFBE0E2D; Tue, 18 Sep 2018 06:39:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 06F2CE0E29 for ; Tue, 18 Sep 2018 06:39:20 +0000 (UTC) Received: from localhost (unknown [IPv6:2404:e800:e600:402:a043:dee9:8fe1:5766]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: perfinion) by smtp.gentoo.org (Postfix) with ESMTPSA id 3B950335D1F; Tue, 18 Sep 2018 06:39:16 +0000 (UTC) From: Jason Zaman To: gentoo-dev@lists.gentoo.org Cc: Jason Zaman Subject: [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods Date: Tue, 18 Sep 2018 14:38:17 +0800 Message-Id: <20180918063817.19338-3-perfinion@gentoo.org> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180918063817.19338-1-perfinion@gentoo.org> References: <20180918063817.19338-1-perfinion@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Archives-Salt: 1a6c59cf-5141-4363-be35-8348c1df30b2 X-Archives-Hash: 234a2f3fccdcc9ff78f522e9489974a9 cuda_toolkit_version returns the version of dev-util/nvidia-cuda-toolkit cuda_cudnn_version returns the version of dev-libs/cudnn cuda_add_sandbox adds the nvidia dev nodes to the sandbox Signed-off-by: Jason Zaman --- eclass/cuda.eclass | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 3a6fc3a31d1..f1c09ca2e45 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -144,6 +144,48 @@ cuda_sanitize() { export NVCCFLAGS } +# @FUNCTION: cuda_add_sandbox +# @USAGE: [-w] +# @DESCRIPTION: +# Add nvidia dev nodes to the sandbox predict list. +# with -w, add to the sandbox write list. +cuda_add_sandbox() { + debug-print-function ${FUNCNAME} "$@" + + local i + for i in /dev/nvidia*; do + if [[ $1 == '-w' ]]; then + addwrite $i + else + addpredict $i + fi + done +} + +# @FUNCTION: cuda_toolkit_version +# @DESCRIPTION: +# echo the installed version of dev-util/nvidia-cuda-toolkit +cuda_toolkit_version() { + debug-print-function ${FUNCNAME} "$@" + + local v + v="$(best_version dev-util/nvidia-cuda-toolkit)" + v="${v##*cuda-toolkit-}" + ver_cut 1-2 "${v}" +} + +# @FUNCTION: cuda_cudnn_version +# @DESCRIPTION: +# echo the installed version of dev-libs/cudnn +cuda_cudnn_version() { + debug-print-function ${FUNCNAME} "$@" + + local v + v="$(best_version dev-libs/cudnn)" + v="${v##*cudnn-}" + ver_cut 1-2 "${v}" +} + # @FUNCTION: cuda_src_prepare # @DESCRIPTION: # Sanitise and export NVCCFLAGS by default -- 2.16.4