Discussion:
[PyCUDA] multiple source modules
Ananth Sridharan
2015-03-30 16:46:42 UTC
Permalink
Hi,
I have a simulation code which requires the use of multiple kernels. Each
of these kernels (global functions) needs to call a common set of device
functions. To organize code better, I'd like to provide multiple source
modules - one (or more) for the kernels, and one for the common
dependencies.
I'm missing the syntax (if it exists) to let the source module containing
the kernels "know" the functions in the source module containing the device
functions. Can someone help me out?
(I'm a pyCuda novice, and have basic working knowledge of
cuda-c/cuda-fortran)
Ananth
Jerome Kieffer
2015-03-30 18:41:09 UTC
Permalink
On Mon, 30 Mar 2015 12:46:42 -0400
Post by Ananth Sridharan
I have a simulation code which requires the use of multiple kernels. Each
of these kernels (global functions) needs to call a common set of device
functions. To organize code better, I'd like to provide multiple source
modules - one (or more) for the kernels, and one for the common
dependencies.
Sometimes I concatenate sources (as python strings) before compilation ... in OpenCL.
This allows me to have less source code to maintain and a better factorisation.

This trick applies to your case a well.

Cheers,
--
Jérôme Kieffer
Data analysis unit - ESRF
Andreas Kloeckner
2015-03-30 19:08:25 UTC
Permalink
Post by Jerome Kieffer
On Mon, 30 Mar 2015 12:46:42 -0400
Post by Ananth Sridharan
I have a simulation code which requires the use of multiple kernels. Each
of these kernels (global functions) needs to call a common set of device
functions. To organize code better, I'd like to provide multiple source
modules - one (or more) for the kernels, and one for the common
dependencies.
Sometimes I concatenate sources (as python strings) before compilation ... in OpenCL.
This allows me to have less source code to maintain and a better factorisation.
This trick applies to your case a well.
Alternatively, include files are supported by the compiler (and
dependencies are tracked for caching purposes).

Andreas
Ananth Sridharan
2015-04-03 21:18:21 UTC
Permalink
Thanks for the suggestions! I tried the include file option, and it works
nicely. For someone who runs into the same problem later on, detailed
answer here:
http://stackoverflow.com/questions/11290536/passing-a-c-cuda-class-to-pycudas-sourcemodule
Hi,
I have a simulation code which requires the use of multiple kernels.
Each of these kernels (global functions) needs to call a common set of
device functions. To organize code better, I'd like to provide multiple
source modules - one (or more) for the kernels, and one for the common
dependencies.
I'm missing the syntax (if it exists) to let the source module
containing the kernels "know" the functions in the source module containing
the device functions. Can someone help me out?
(I'm a pyCuda novice, and have basic working knowledge of
cuda-c/cuda-fortran)
Ananth
Loading...