public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Jason Zaman <perfinion@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: Jason Zaman <perfinion@gentoo.org>
Subject: [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods
Date: Tue, 18 Sep 2018 14:38:17 +0800	[thread overview]
Message-ID: <20180918063817.19338-3-perfinion@gentoo.org> (raw)
In-Reply-To: <20180918063817.19338-1-perfinion@gentoo.org>

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 <perfinion@gentoo.org>
---
 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



  parent reply	other threads:[~2018-09-18  6:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18  6:38 [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
2018-09-18  6:38 ` [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4 Jason Zaman
2018-09-18  6:38 ` Jason Zaman [this message]
2018-09-21 16:07 ` [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180918063817.19338-3-perfinion@gentoo.org \
    --to=perfinion@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox