[Users] Optional capabilities
Erik Schnetter
schnetter at cct.lsu.edu
Mon Nov 29 19:24:27 CST 2010
On Mon, Nov 29, 2010 at 5:19 PM, Ian Hinder <ian.hinder at aei.mpg.de> wrote:
> Hi,
>
> (Sent to Einstein Toolkit mailing list because Cactus mailing lists are down)
>
> I am trying to introduce an optional dependency on HDF5 in my thorn. The idea is that the thorn could work either with or without HDF5 support in the configuration, and the code in the thorn would be conditionally compiled depending on whether HDF5 is present.
>
> The Cactus capability mechanism has an "optional" keyword, so you can say that a thorn depends optionally on a particular capability (in this case, HDF5). However, in the Einstein Toolkit thorns, this is very rarely used, and never for conditional compilation, so I suspect that this feature has not been well tested.
>
> Indeed, it appears that it doesn't work. In order to detect at compile time whether a given capability is present, it is necessary to have a preprocessor (#define) macro defined. The file that would do this is Cactus/lib/sbin/CreateConfigurationBindings.pl. This file sets a make-system definition for the given capability (i.e. HDF5 = 1) but it does not set a preprocessor macro. This could be done manually in the configuration script of the thorn providing the capability, by outputting the lines
>
> echo "BEGIN DEFINE"
> echo "HAVE_HDF5 1"
> echo "END DEFINE"
>
> This would cause the line "#define HAVE_HDF5 1" to be included whenever the thorn that requires the capability includes cctki_Capabilities.h. However, since this is a "cctki" file (with 'i' for internal?), I assume that it is not supposed to be included by user thorns. Instead, I think it is supposed to be included automatically, but I can't find any code that would do that, and I think it is missing.
>
> Further, there is a line in CreateConfigurationBindings.pl which seems to be wrong. Line 166 says
>
> $incs .= "#define " . $cfg->{"\U$thorn\E OPTIONAL \U$providedcap\E DEFINE"} . " 1\n";
>
> which doesn't make sense because $cfg->{"\U$thorn\E OPTIONAL \U$providedcap\E DEFINE"} is a list of defines, not a single one, and anyway these definitions have already been provided earlier in the file which will be included, so this line is redundant. It leads to the output #define 1, presumably because the list evaluates to an empty string. This causes a compilation failure when you include cctki_Capabilities.h.
>
> 1. Do we want all capabilities to generate automatically a preprocessor macro which can be checked? e.g. HAVE_CAPABILITY_HDF5, (to avoid conflicts with autoconf-generated macros)
Yes, this should be the case.
> 2. If not, then we could add the BEGIN_DEFINE...END_DEFINE lines above to HDF5.sh to manually set the define.
I don't mind whether it is automatic or whether the scripts provide this.
> 3. I think line 166 of CreateConfigurationBindings.pl should be removed.
Could be -- do you want to post a patch? Or is this the line that
needs to be corrected to generate the #defines automatically?
> 4. There should be some mechanism for each thorn to include cctki_Capabilities.h automatically.
Yes, definitely. It should probably be part of cctk.h.
-erik
--
Erik Schnetter <schnetter at cct.lsu.edu> http://www.cct.lsu.edu/~eschnett/
More information about the Users
mailing list