[Numpy-discussion] Questions on GUFUNCS

Charles R Harris charlesr.harris@gmail....
Mon Aug 5 12:16:37 CDT 2013


On Sun, Aug 4, 2013 at 11:49 PM, Jaime Fernández del Río <
jaime.frio@gmail.com> wrote:

> Hi!
>
> I have spent the last couple of weeks playing around with GUFUNCS, and am
> literally blown away by the power that a C compiler and NumPy put at the
> tip of my fingers! I still have many questions, but the following ones are
> the most pressing in my current state of amazed ignorance:
>
> 1. **The data argument to the GUFUNC loop function** Where in the source
> code can I find example of it's use? I remember reading that many UFUNCS
> are just the same looping, with a pointer to a different function passed in
> this argument. I think I understand the idea, but would like to see it
> implemented.
>
> 2. **Is there a place for initializations?** I have a GUFNC in mind that
> will need, in each iteration, a small dynamically allocated array, which
> can be reused by other iterations. Rather than malloc-ing it for every
> loop, I am thinking of wrapping the GUFUNC in a Python interface that
> creates a numpy array for this, and passes it down as another parameter. Is
> there an easy way to keep this all bundled in the C code, e.g. by defining
> some initialization code to be run before doing any looping?
>
> 3. **What happens with missing types?** Say I only register a function
> that takes unsigned ints. What happens if I try to call it with ints? I
> figure it will complain, but not if it is the other way around and the type
> can be safely casted. Is that really so? Can this behavior be in any way
> configured? Is it documented anywhere?
>
> 4. **.src files** The prime example of GUFUNC implementation I have found
> is "umath_linalg.c.src" Correct me if I am wrong, but this is simply C code
> plus the special syntax to generate multiple versions of the same functions
> changing only a few types and names, using the @tag@ syntax. While the
> way it works seems clear, I had never seen this done like this before. Is
> this standard or just a numpy thing? How do you parse and expand this code
> to its full glory before compiling?
>

It's a numpy thing. The code can be expanded like so if you are working in
the repository:
```
$ python numpy/distutils/conv_template.py <filename>
```

Chuck

>
> Thanks!
>
> Jaime
>
> --
> (\__/)
> ( O.o)
> ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
> de dominación mundial.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130805/e9fd80be/attachment.html 


More information about the NumPy-Discussion mailing list