summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaman <perfinion@gentoo.org>2018-09-18 13:55:03 +0800
committerJason Zaman <perfinion@gentoo.org>2018-09-22 00:05:41 +0800
commitbce7726afd984518ea4ad9eddddf78df03ff36b9 (patch)
treea98a1127bc9173242026205c25cdc7c360e04e2c /eclass/cuda.eclass
parentcuda.eclass: update to EAPI7, remove 0-4 (diff)
downloadgentoo-bce7726afd984518ea4ad9eddddf78df03ff36b9.tar.gz
gentoo-bce7726afd984518ea4ad9eddddf78df03ff36b9.tar.bz2
gentoo-bce7726afd984518ea4ad9eddddf78df03ff36b9.zip
cuda.eclass: Add version and sandbox helper methods
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>
Diffstat (limited to 'eclass/cuda.eclass')
-rw-r--r--eclass/cuda.eclass42
1 files changed, 42 insertions, 0 deletions
diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass
index 3a6fc3a31d18..f1c09ca2e453 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