Re: [gentoo-dev] New eclass cuda.eclass
Please review my inclusion of your suggestions. Additionally I move to src_prepare to be more binpackage compatible as things are only of interest at compile time. commit 366a690925f5cc5e4bdd2ea984d9ccca65d8f996 Author: Justin Lecher j...@gentoo.org Date: Wed Nov 28 11:54:16 2012 +0100 Be bin package friendly Move standard call of cuda_sanitize to src_prepapere as it isn't need for bin packages. Signed-off-by: Justin Lecher j...@gentoo.org diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 08cfb72..beac082 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -110,13 +110,23 @@ cuda_sanitize() { # @FUNCTION: cuda_pkg_setup # @DESCRIPTION: -# Sanitise and export NVCCFLAGS by default +# Call cuda_src_prepare for EAPIs not supporting src_prepare cuda_pkg_setup() { + cuda_src_prepare +} + +# @FUNCTION: cuda_src_prepare +# @DESCRIPTION: +# Sanitise and export NVCCFLAGS by default +cuda_src_prepare() { cuda_sanitize } -EXPORT_FUNCTIONS pkg_setup + case ${EAPI:-0} in - 0|1|2|3|4|5) ;; + 0|1) + EXPORT_FUNCTIONS pkg_setup ;; + 2|3|4|5) + EXPORT_FUNCTIONS src_prepare ;; *) die EAPI=${EAPI} is not supported ;; esac commit 07b5a629a7f6e9f163e0dfe9c1927010f527508f Author: Justin Lecher j...@gentoo.org Date: Wed Nov 28 11:24:51 2012 +0100 Fix typo in Copyright year Signed-off-by: Justin Lecher j...@gentoo.org diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 0b2e084..08cfb72 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-20012 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ commit 7319422dd7c7427cc741e9bdab2f1211b5af1be4 Author: Justin Lecher j...@gentoo.org Date: Wed Nov 28 11:24:16 2012 +0100 Implemented comments from g-dev review * Fix whitespacing * Fix man pages tags * Try to do things in functions instead of global scope * remove _ from local variables * inline check for presents and functionality of cuda-config Signed-off-by: Justin Lecher j...@gentoo.org diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index f8ebd81..0b2e084 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -13,49 +13,45 @@ inherit toolchain-funcs versionator # setting and/or sanitizing NVCCFLAGS, the compiler flags for nvcc. This is # automatically done and exported in src_prepare() or manually by calling # cuda_sanatize. -# -# Common usage: -# +# @EXAMPLE: # inherit cuda # @ECLASS-VARIABLE: NVCCFLAGS -# DESCRIPTION: +# @DESCRIPTION: # nvcc compiler flags (see nvcc --help), which should be used like # CFLAGS for c compiler : ${NVCCFLAGS:=-O2} # @ECLASS-VARIABLE: CUDA_VERBOSE -# DESCRIPTION: +# @DESCRIPTION: # Being verbose during compilation to see underlying commands : ${CUDA_VERBOSE:=true} -[[ ${CUDA_VERBOSE} == true ]] NVCCFLAGS+= -v - -# @ECLASS-FUNCTION: cuda_gccdir +# @FUNCTION: cuda_gccdir +# @USAGE: [-f] +# @RETURN: gcc bindir compatible with current cuda, optionally (-f) prefixed with --compiler-bindir= # @DESCRIPTION: # Helper for determination of the latest gcc bindir supported by # then current nvidia cuda toolkit. # -# Calling plain it returns simply the path, but you probably want to add \-f\ -# to get the full flag to add to nvcc call. -# # Example: -# +# @CODE # cuda_gccdir -f # - --compiler-bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3 +# @CODE cuda_gccdir() { - local _gcc_bindir _ver _args= _flag _ret + local gcc_bindir ver args= flag ret # Currently we only support the gnu compiler suite if [[ $(tc-getCXX) != *g++* ]]; then -ewarn Currently we only support the gnu compiler suite + ewarn Currently we only support the gnu compiler suite return 2 fi while [ $1 ]; do case $1 in -f) - _flag=--compiler-bindir= + flag=--compiler-bindir= ;; *) ;; @@ -63,43 +59,46 @@ cuda_gccdir() { shift done - if [[ ! $(type -P cuda-config) ]]; then + if ! args=$(cuda-config -s); then eerror Could not execute cuda-config eerror Make sure =dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed die cuda-config not found else - _args=$(version_sort $(cuda-config -s)) - if [[ ! -n ${_args} ]]; then + args=$(version_sort ${args}) + if [[ -z ${args} ]]; then die Could not determine supported gcc versions from cuda-config fi fi - for _ver in ${_args}; do - has_version sys-devel/gcc:${_ver} \ - _gcc_bindir=$(ls -d
Re: [gentoo-dev] New eclass cuda.eclass
On Sunday 25 November 2012 11:47:42 Justin wrote: # Copyright 1999-20012 Gentoo Foundation it is not yet 20012 also, this file too has whitespace damage (indenting with spaces) [[ ${CUDA_VERBOSE} == true ]] NVCCFLAGS+= -v wouldn't this be better done in cuda_sanitize ? local _gcc_bindir _ver _args= _flag _ret they're local vars, so you don't need to use _ prefixes if [[ ! $(type -P cuda-config) ]]; then it's more common to do something like: if cuda-config --help /dev/null ; then or, you could even inline it with the existing code: if ! args=$(cuda-config -s); then ... eerror/die ... else args=$(version_sort ${args}) ... if [[ ! -n ${_args} ]]; then use -z, not ! -n -mike signature.asc Description: This is a digitally signed message part.
Re: [gentoo-dev] New eclass cuda.eclass
On 28/11/12 00:11, Mike Frysinger wrote: On Sunday 25 November 2012 11:47:42 Justin wrote: # Copyright 1999-20012 Gentoo Foundation it is not yet 20012 also, this file too has whitespace damage (indenting with spaces) [[ ${CUDA_VERBOSE} == true ]] NVCCFLAGS+= -v wouldn't this be better done in cuda_sanitize ? local _gcc_bindir _ver _args= _flag _ret they're local vars, so you don't need to use _ prefixes if [[ ! $(type -P cuda-config) ]]; then it's more common to do something like: if cuda-config --help /dev/null ; then or, you could even inline it with the existing code: if ! args=$(cuda-config -s); then ... eerror/die ... else args=$(version_sort ${args}) ... if [[ ! -n ${_args} ]]; then use -z, not ! -n -mike Thanks for your comments, those are now integrated, Justin signature.asc Description: OpenPGP digital signature
[gentoo-dev] New eclass cuda.eclass
Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. justin # Copyright 1999-20012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit toolchain-funcs versionator # @ECLASS: cuda.eclass # @MAINTAINER: # Justin Lecher j...@gentoo.org # @BLURB: Common functions for cuda packages # @DESCRIPTION: # This eclass contains functions to be used with cuda package. Currently it is # setting and/or sanitizing NVCCFLAGS, the compiler flags for nvcc. This is # automatically done and exported in src_prepare() or manually by calling # cuda_sanatize. # # Common usage: # # inherit cuda # @ECLASS-VARIABLE: NVCCFLAGS # DESCRIPTION: # nvcc compiler flags (see nvcc --help), which should be used like # CFLAGS for c compiler : ${NVCCFLAGS:=-O2} # @ECLASS-VARIABLE: CUDA_VERBOSE # DESCRIPTION: # Being verbose during compilation to see underlying commands : ${CUDA_VERBOSE:=true} [[ ${CUDA_VERBOSE} == true ]] NVCCFLAGS+= -v # @ECLASS-FUNCTION: cuda_gccdir # @DESCRIPTION: # Helper for determination of the latest gcc bindir supported by # then current nvidia cuda toolkit. # # Calling plain it returns simply the path, but you probably want to add \-f\ # to get the full flag to add to nvcc call. # # Example: # # cuda_gccdir -f # - --compiler-bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3 cuda_gccdir() { local _gcc_bindir _ver _args= _flag _ret # Currently we only support the gnu compiler suite if [[ $(tc-getCXX) != *g++* ]]; then ewarn Currently we only support the gnu compiler suite return 2 fi while [ $1 ]; do case $1 in -f) _flag=--compiler-bindir= ;; *) ;; esac shift done if [[ ! $(type -P cuda-config) ]]; then eerror Could not execute cuda-config eerror Make sure =dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed die cuda-config not found else _args=$(version_sort $(cuda-config -s)) if [[ ! -n ${_args} ]]; then die Could not determine supported gcc versions from cuda-config fi fi for _ver in ${_args}; do has_version sys-devel/gcc:${_ver} \ _gcc_bindir=$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${_ver}* | tail -n 1) done if [[ -n ${_gcc_bindir} ]]; then if [[ -n ${_flag} ]]; then _ret=${_flag}\\\${_gcc_bindir}\\\ else _ret=${_gcc_bindir} fi echo ${_ret} return 0 else eerror Only gcc version(s) ${_args} are supported, eerror of which none is installed die Only gcc version(s) ${_args} are supported return 1 fi } # @ECLASS-FUNCTION: cuda_sanitize # @DESCRIPTION: # Correct NVCCFLAGS by adding the necessary reference to gcc bindir and # passing CXXFLAGS to underlying compiler without disturbing nvcc. cuda_sanitize() { # Tell nvcc where to find a compatible compiler NVCCFLAGS+= $(cuda_gccdir -f) # Tell nvcc which flags should be used for underlying C compiler NVCCFLAGS+= --compiler-options=\${CXXFLAGS}\ export NVCCFLAGS } # @ECLASS-FUNCTION: cuda_pkg_setup # @DESCRIPTION: # Sanitise and export NVCCFLAGS by default in pkg_setup cuda_pkg_setup() { cuda_sanitize } EXPORT_FUNCTIONS pkg_setup case ${EAPI:-0} in 0|1|2|3|4|5) ;; *) die EAPI=${EAPI} is not supported ;; esac signature.asc Description: OpenPGP digital signature
Re: [gentoo-dev] New eclass cuda.eclass
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/25/2012 11:47 AM, Justin wrote: Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. This whole idea seems great but I see two issues. Issue 1.) I'm stupid and don't really understand all the intricacy of the toolchain stuff and 2.) you didn't include an example ebuild. Fortunately issue 1 can (at least functionally) be solved by providing a solution for issue 2. If you need an ebuild to cuda.eclassify then I am happy to provide (or feel free to use a before and after of anything you have available). https://code.google.com/p/pentoo/source/browse/portage/trunk/app-crypt/cryptohaze-combined/cryptohaze-combined-.ebuild Thanks! Zero -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQIcBAEBAgAGBQJQslyDAAoJEKXdFCfdEflKiKIQAJUGuKxqRY/ruCcSC98PWkOq NsZr/C5YbZRfJlFlcb5LnA2qJJAxO04bun0zi6hbZWsMGLBI54qha/XGL9M0J+rm qIubv8xFRVXfmSRdQMYSAYnA5xrLJVAu/H7jpq8stOFdP7COuXKjwknOhccap6yF g8tMm5vClH7y+hLIMYn8xQ2ZIDO5cGTdFFNLIDOHk/el/ija+I+dR7BkMVeZ0tQc CgbiUyBdgz1Ijc2yr6x5vc+8QGWvmGZMNslgnrlMpICyUY25xPAdrySNcVHHIAoA 4zBqmO4VIaWuzKOcUZEkSdtJHtyQPbmTVMwVfuf8gRm2wec1rsfkWqCORQ2SYVEk aDcyZQFzb0D+vBc9Ic62+ejGe12GU++KZ3ivairT82Vls46Awkajepj0bILnC3jO 6shNvYLJTI38UEKMFWrTNMkeQgkOUZwftHylHF6AAtUTi4htMXdar9J9PV/uPQDJ Z4VpElKO9OB87N7eFHDeB3A3q8G++N1WHOC14/z2pTKUEyr9NoivBYOMo5RxBLtD mT8CbUe8NkVzcWJRoKu2EKg2i8fD7lpjZtw2/s8ADxtnyGZ4jZq73aOeY6hWgq4y CFigbKYQtorV30GeTks9Vgs9tbbxVjXupaQ/TgaWEOUYA7I5IfQIyfqBzfFwHMPm Uw6Kkmp5ihx0fH9gR8BH =/idk -END PGP SIGNATURE-
Re: [gentoo-dev] New eclass cuda.eclass
On 25.11.2012 18:59, Rick Zero_Chaos Farina wrote: On 11/25/2012 11:47 AM, Justin wrote: Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. This whole idea seems great but I see two issues. Issue 1.) I'm stupid and don't really understand all the intricacy of the toolchain stuff and 2.) you didn't include an example ebuild. Fortunately issue 1 can (at least functionally) be solved by providing a solution for issue 2. If you need an ebuild to cuda.eclassify then I am happy to provide (or feel free to use a before and after of anything you have available). https://code.google.com/p/pentoo/source/browse/portage/trunk/app-crypt/cryptohaze-combined/cryptohaze-combined-.ebuild Thanks! Zero 1) The build fails if you are using a compiler newer then the supported ones. In file included from /opt/cuda/include/cuda_runtime.h:59:0, from command-line:0: /opt/cuda/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.7 and up are not supported! make[1]: *** [obj/x86_64/release/segmentationTree.cu_13.o] Error 1 or similar. Solution, tell nvcc where to find a compatible compiler. 2) The underlying call of c compiler doesn't respect CXXFLAGS, therefore we need to tell nvcc what to use. Otherwise only the plain NVCCFLAGS are used. How to fix your package, depends on the buildsystem and where and how they are calling the nvcc. Normally you need to sed it in. Here as an example the nvidia-cuda-sdk version bump: https://github.com/gentoo-science/sci/blob/cuda/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-5.0.35.ebuild justin signature.asc Description: OpenPGP digital signature
Re: [gentoo-dev] New eclass cuda.eclass
On 11/25/2012 02:14 PM, Justin wrote: On 25.11.2012 18:59, Rick Zero_Chaos Farina wrote: On 11/25/2012 11:47 AM, Justin wrote: Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. This whole idea seems great but I see two issues. Issue 1.) I'm stupid and don't really understand all the intricacy of the toolchain stuff and 2.) you didn't include an example ebuild. Fortunately issue 1 can (at least functionally) be solved by providing a solution for issue 2. If you need an ebuild to cuda.eclassify then I am happy to provide (or feel free to use a before and after of anything you have available). https://code.google.com/p/pentoo/source/browse/portage/trunk/app-crypt/cryptohaze-combined/cryptohaze-combined-.ebuild Thanks! Zero 1) The build fails if you are using a compiler newer then the supported ones. In file included from /opt/cuda/include/cuda_runtime.h:59:0, from command-line:0: /opt/cuda/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.7 and up are not supported! make[1]: *** [obj/x86_64/release/segmentationTree.cu_13.o] Error 1 or similar. Solution, tell nvcc where to find a compatible compiler. I can see this improvement right away, love it. 2) The underlying call of c compiler doesn't respect CXXFLAGS, therefore we need to tell nvcc what to use. Otherwise only the plain NVCCFLAGS are used. How to fix your package, depends on the buildsystem and where and how they are calling the nvcc. Normally you need to sed it in. Here as an example the nvidia-cuda-sdk version bump: https://github.com/gentoo-science/sci/blob/cuda/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-5.0.35.ebuild I mostly get this, seems like a good thing. All in all, definitely ACK. I like it. Thanks, Zero
Re: [gentoo-dev] New eclass cuda.eclass
On 11/26/12 12:59 AM, Rick Zero_Chaos Farina wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/25/2012 11:47 AM, Justin wrote: Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. I don't know if this is helpful feedback, but it would be great if our CUDA compiler was also detected in your eclass. Notable differences : Probably a lot faster compilation times (needs benchmarking), no external userland dependencies (gcc or nvidia), we don't support nvcc flags and we have a driver just for the CUDA language Example: pathcu deadbeef.cu ./a.out (Unfortunately our recent nightly builds started to do a license check, but any interested open source dev just ping me to get setup) To validate simple things you could use an older nightly http://c591116.r16.cf2.rackcdn.com/enzo/nightly/Linux/enzo-2012-11-18-installer.run chmod +x enzo-2012-11-18-installer.run ; ./enzo-2012-11-18-installer.run --mode unattended # --prefix /opt/foobar ./C
Re: [gentoo-dev] New eclass cuda.eclass
On 26/11/12 01:26, C. Bergström wrote: On 11/26/12 12:59 AM, Rick Zero_Chaos Farina wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/25/2012 11:47 AM, Justin wrote: Hi, I would like to introduce a new eclass for packages using the nvidia cuda compiler suite. Currently the eclass simply sanitize the NVCCFLAGS. May be extended in the future. Two problems come up with using nvcc: * Each version only supports a limited number of gcc versions. Therefore we need to pass the path to a supported gcc bindir * nvcc calls CXX but doesn't pass CXXFLAGS on. I don't know if this is helpful feedback, but it would be great if our CUDA compiler was also detected in your eclass. Notable differences : Probably a lot faster compilation times (needs benchmarking), no external userland dependencies (gcc or nvidia), we don't support nvcc flags and we have a driver just for the CUDA language Example: pathcu deadbeef.cu ./a.out (Unfortunately our recent nightly builds started to do a license check, but any interested open source dev just ping me to get setup) To validate simple things you could use an older nightly http://c591116.r16.cf2.rackcdn.com/enzo/nightly/Linux/enzo-2012-11-18-installer.run chmod +x enzo-2012-11-18-installer.run ; ./enzo-2012-11-18-installer.run --mode unattended # --prefix /opt/foobar ./C Hi, its definitely a nice thing to have more choices. Could you file bug for that please, so that we can support it in future versions? Thanks justin signature.asc Description: OpenPGP digital signature