Definitions

From AQUAgpusph
Jump to: navigation, search

Introduction

Since version 2.0, AQUAgpusph is designed like a sandbox, such that the way the simulation will be computed can be modified "on the fly". In order to make it easy to use OpenCL kernels, the user may set definitions that will be passed as compiler options (like -D flags) for the OpenCL codes.

The definitions are parsed and evaluated (if it is required) right after the Variables have been registered.

Adding new definitions

In order to add new definitions an specific section should be opened in the simulation definition XML input files (take a look on the examples to learn more about this):

<Definitions>
    <!-- ... -->
</Definitions>

The new definitions will be generated between the new "Definitions" opened section:

<Define name="NAME" value="VALUE" evaluate="EVALUATE">

Where NAME, VALUE and EVALUATE should be conveniently set as it is described in the following subsections.

Name

The name of the definition can be arbitrary selected, being mindful that the name should be ISO C compliance. Also some definition names may fail depending on the OpenCL vendor (or more specifically on the compiler).

Value

It is the value that the compiler will use to replace each instance found of the Definition name in the OpenCL codes.

If Evaluation is set as "true", this field is evaluated using libmatheval, such that you can use scalar variables referring to their name (followed by an underscore "_" and the component "x, y, z, w" if it is a vectorial scalar).

In case that this attribute is not set, the variable will be treated as a pure definition, such that the compiler is interpreting as true the preprocessor statement (retaining therefore the content inside):

#ifdef NAME
    // ...
#endif

where NAME is the provided Name.

Evaluation

"true" if the Value should be evaluated as a numeric input using libmatheval, "false" otherwise. This parameter is ignored if #Value is not set.