Re: [firedrake] Feeding extra args into Kernels
Just to translate this more meaningfully, I think Lawrence at some point implemented an optional argument to pass a path to a C library to link against when compiling a kernel - maybe on a branch, it would be good if this could make it into the trunk version (Ali reports that it isn't). all the best --cjc On 2 March 2016 at 12:28, Gregory, Alastair <a.gregory14@imperial.ac.uk> wrote:
Hi,
I need to feed arguments (a C library) into a kernel that goes into a parallel loop. I have tried using the kernel function in https://github.com/OP2/PyOP2/pull/476 to do,
Kernel(str,args*),
but when I put this into par_loop, I get the error, 'Kernel' object doesn't have 'replace', as Kernel isn't a string, it's as above.
Does anyone know how I go about placing the Kernel with the extra arguments into par_loop?
Many Thanks,
*Alastair Gregory*
------------------------------------------------------------------------------------------
*Numerical Analysis Research Postgraduate Imperial College London -** Grantham Institute of Climate Change * Room 759 Huxley Building, South Kensington *(Tel: 07794 243913) | (Email: a.gregory14@imperial.ac.uk <a.gregory14@imperial.ac.uk>)*
-------------------------------------------------------------------------------------------
-- http://www.imperial.ac.uk/people/colin.cotter www.cambridge.org/9781107663916
On 02/03/16 14:04, Colin Cotter wrote:
Just to translate this more meaningfully, I think Lawrence at some point implemented an optional argument to pass a path to a C library to link against when compiling a kernel - maybe on a branch, it would be good if this could make it into the trunk version (Ali reports that it isn't).
It already works. Quoth the documentation:
Documentation for parloops.par_loop:
par_loop(kernel, measure, args, **kwargs)
A :func:`par_loop` is a user-defined operation which reads and writes :class:`.Function`\s by looping over the mesh cells or facets and accessing the degrees of freedom on adjacent entities.
:arg kernel: is a string containing the C code to be executed. :arg measure: is a UFL :class:`~ufl.measure.Measure` which determines the manner in which the iteration over the mesh is to occur. Alternatively, you can pass :data:`direct` to designate a direct loop. :arg args: is a dictionary mapping variable names in the kernel to :class:`.Function`\s or components of mixed :class:`.Function`\s and indicates how these :class:`.Function`\s are to be accessed. :arg kwargs: additional keyword arguments are passed to the :class:`~pyop2.op2.Kernel` constructor
So you can pass any additional arguments to your kernel by passing kwargs: par_loop(..., ldargs=["list" "of "things" "for" "the" "linker"]) Lawrence
participants (2)
- 
                
                Colin Cotter
- 
                
                Lawrence Mitchell