← Back to team overview

ffc team mailing list archive

Re: Override cpp.format dictionary depending on -l parameter to ffc

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02.08.2010 16:08, Kristian Ølgaard wrote:
> On 2 August 2010 15:45, Florian Rathgeber
> <florian.rathgeber@xxxxxxxxxxxxxx> wrote:
> Hi,
> 
> I modified FFC to accept an additional option for the -l parameter to
> output tensor tabulation code suitable for execution in a CUDA kernel on
> the GPU. For that the indexing for coordinates, coefficients and the
> element tensor needs to be changed since the data structures look
> differently on the GPU (foremost they are flattened). The Jacobi
> computations look differently as well due to the way coordinates are stored.
> 
> What I did was to provide a function override_gpu() in cpp.py that
> updates the cpp.format dictionary to generate the correct index into the
> data structures. This function is called at the beginning of
> codegeneration.py:generate_code if the GPU target was specified by the
> -l parameter.
> 
> This works for tensor representation, but not functions values
> (including coefficients) for quadrature, since the corresponding code is
> generated by the class "QuadratureTransformerBase". I'm no Python
> expert, but I assume the override of cpp.format on the global scope is
> not visible inside the class scope.
> 
>> It will be if you call override_gpu() in the representation stage
>> instead of the code generation stage.

It does, thank you!

> Since "QuadratureTransformerBase" does not get the parameters, it cannot
> know if the target is GPU and override_gpu() should be called.
> 
> My changes are more of a quick hack and certainly not a well-designed
> way to solve this. I would be happy about suggestions both to quickly
> fix the quadrature and also how to adapt the whole design to make it
> more "clean" and straightforward.
> 
>> We handle the formatting of floats in a similar way so I don't think
>> the solution is too bad for now.

OK, I guess I'll leave it like that for the moment.

> (The corresponding wrapper code, which is different from the ordinary
> DOLFIN wrapper code, is also generated depending on the -l option, but
> that is a different topic, so I just mention it for the sake of
> completeness)
> 
>> and the option is '-l dolfin-gpu' if anyone wonders.

Right, I should have mentioned that.

Florian

>> Kristian
> 
> I published my branch here:
> https://code.launchpad.net/~florian-rathgeber/ffc/gpu-wrappers
> 
> Florian
>>
>>
_______________________________________________
Mailing list: https://launchpad.net/~ffc
Post to     : ffc@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~ffc
More help   : https://help.launchpad.net/ListHelp
>>
>>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)

iEYEARECAAYFAkxXKaQACgkQ8Z6llsctAxZD0wCg04bTYowqcMIEivVueHas30eU
1z0AoKJ3LAVK2319JztaUbiC2n6vemwh
=XZE6
-----END PGP SIGNATURE-----

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


References