ppmd.kernel module¶
-
class
ppmd.kernel.
Constant
(name, value)¶ Bases:
object
Class representing a numerical constant.
This class can be used to use placeholders for constants in kernels.
- Parameters
name (str) – Name of constant
value – Numerical value (can actually be any data type)
-
replace
(s)¶ Replace all occurrences in a string and return result
Ignores the constant if it is not a C-variable. For example, if the name of the constant is
mass
, then it would not replace it inmass1
orHmass
.- Parameters
s (str) – string to work on
-
class
ppmd.kernel.
Header
(name=None, system=True, block=None)¶ Bases:
object
-
class
ppmd.kernel.
Kernel
(name, code, constants=None, headers=None, reductions=None, static_args=None)¶ Bases:
object
Computational kernel, i.e. C-code + numerical constants.
Stores the C source code of a kernel and substitutes in any numerical constants that are to be copied it when the class is created.
- Parameters
name – name of the kernel
code – C source code
constants – List of constants (type
Constant
) which are to be substituted in.reductions – list of reductions required by kernel if using parallel looping.
-
property
code
¶ Kernel source code after substitution of numerical constants
-
property
headers
¶ Return C headers required for kernel
-
hexdigest
()¶ Unique md5 hexdigest which is used for identifying the kernel.
-
property
name
¶ Kernel name.
-
reduction_variable_lookup
(var)¶ Provides a method to determine if a variable undergoes a Reduction.
-
property
static_args
¶
-
class
ppmd.kernel.
Reduction
(variable, pointer, operator='+')¶ Bases:
object
Object to store Reduction operations required by kernels. Currently holds only one Reduction per instance.
- Parameters
variable (str) – Variable name eg ‘u’.
pointer (str) – C pointer syntax of variable being reduced upon eg ‘u[0]’.
operator (char) – operator performed in Reduction, default ‘+’.
-
property
index
¶ Returns index in C pointer syntax, eg u[0] returns 0
-
property
operator
¶ Returns C operator
-
property
pointer
¶ Returns C pointer syntax
-
property
variable
¶ Returns variable name
-
ppmd.kernel.
analyse
(kernel_in=None, dat_dict=None)¶ - Parameters
kernel_in (kernel) – Kernel to analyse.
dat_dict (list) – List of variables which should be assumed are in global memory.
- Returns
Dict of operations and their estimated number of occurences.