On Wed, Apr 17, 2013, Olivier Delalleau wrote:
> I'm not sure how the nvcc compilation is handled right now in Theano,
> but I think a good approach would be to abstract out the compiler
> (with a Compiler class and subclasses appropriate for various
> configs). It could come in handy as well if we want to support MS
> compiler on Windows.
We already have that sort of thing: a GCC_Compiler class, that handles
compilation of C++ code, and an NVCC_Compiler that handles compilation
of CUDA Code.
Here, the problem is how to specify compilation options for some Ops.
The interface of Ops allows to specify, separately, different things:
include directories, library directories, libraries to link with, other arguments.
There are also a Theano config option that can be used to pass arbitrary
options a given compiler (here, config.nvcc.flags).
A first solution would be for people using Windows, who want to use GPU
ops needing pthreads (for the moment, cuda_convnet) to specify:
nvcc.flags="-I 'c:\\path\\to\\pthreads' -L 'c:\\path\\to\\pthreads' -l pthreadlibname"
We do not have a generic way of dealing with that in Theano for the
moment. The closest thing we have is for blas, where we specify all
the arguments in config.blas.ldflags. These arguments are then parsed
by a function that sorts them between the 4 supported categories
(header_dirs, lib_dirs, libraries, compile_args), and that is used by
Ops using BLAS.
A second solution would be to add a new config parameter, say
config.pthreads.ldflags, and either put it in compile_args, or refactor
and reuse the machinery of blas ld flags.
If we want to avoid the complexity of parsing these flags, and be
more robust to different compilers using different ways of passing
flags (for instance, VC uses "/I" instead of "-I", and so on), a third
solution would be to add 4 options: config.pthreads.header_dirs,
config.pthreads.lib_dirs, config.pthreads.libraries, and
config.pthreads.compile_args. We could also do that for blas afterwards.
--
Pascal