Platforms

class pystencils.backend.platforms.Platform(ctx)

Abstract base class for all supported platforms.

The platform performs all target-dependent tasks during code generation:

  • Translation of the iteration space to an index source (loop nest, GPU indexing, …)

  • Platform-specific optimizations (e.g. vectorization, OpenMP)

Parameters:

ctx (KernelCreationContext) –

abstract select_function(math_function, dtype)

Select an implementation for the given function on the given data type.

If no viable implementation exists, raise a MaterializationError.

Return type:

CFunction

Parameters:
  • math_function (PsMathFunction) –

  • dtype (PsType) –

class pystencils.backend.platforms.GenericCpu(ctx)

Generic CPU platform.

The GenericCPU platform models the following execution environment:

  • Generic multicore CPU architecture

  • Iteration space represented by a loop nest, kernels are executed as a whole

  • C standard library math functions available (#include <math.h> or #include <cmath>)

Parameters:

ctx (KernelCreationContext) –

select_function(math_function, dtype)

Select an implementation for the given function on the given data type.

If no viable implementation exists, raise a MaterializationError.

Return type:

CFunction

Parameters:
  • math_function (PsMathFunction) –

  • dtype (PsType) –

class pystencils.backend.platforms.GenericVectorCpu(ctx)

Base class for CPU platforms with vectorization support through intrinsics.

Parameters:

ctx (KernelCreationContext) –

abstract type_intrinsic(vector_type)

Return the intrinsic vector type for the given generic vector type, or raise an MaterializationError if type is not supported.

Return type:

PsCustomType

Parameters:

vector_type (PsVectorType) –

abstract constant_vector(c)

Return an expression that initializes a constant vector, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:

c (PsConstant) –

abstract op_intrinsic(op, vtype, args)

Return an expression intrinsically invoking the given operation on the given arguments with the given vector type, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:
abstract vector_load(acc)

Return an expression intrinsically performing a vector load, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:

acc (PsVectorArrayAccess) –

abstract vector_store(acc, arg)

Return an expression intrinsically performing a vector store, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:
class pystencils.backend.platforms.X86VectorCpu(vector_arch)

Platform modelling the X86 SSE/AVX/AVX512 vector architectures.

All intrinsics information is extracted from https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html.

Parameters:

vector_arch (X86VectorArch) –

type_intrinsic(vector_type)

Return the intrinsic vector type for the given generic vector type, or raise an MaterializationError if type is not supported.

Return type:

PsCustomType

Parameters:

vector_type (PsVectorType) –

constant_vector(c)

Return an expression that initializes a constant vector, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:

c (PsConstant) –

op_intrinsic(op, vtype, args)

Return an expression intrinsically invoking the given operation on the given arguments with the given vector type, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:
vector_load(acc)

Return an expression intrinsically performing a vector load, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:

acc (PsVectorArrayAccess) –

vector_store(acc, arg)

Return an expression intrinsically performing a vector store, or raise an MaterializationError if not supported.

Return type:

PsExpression

Parameters:
class pystencils.backend.platforms.X86VectorArch(value)

An enumeration.

class pystencils.backend.platforms.GenericGpu(ctx)
Parameters:

ctx (KernelCreationContext) –

select_function(math_function, dtype)

Select an implementation for the given function on the given data type.

If no viable implementation exists, raise a MaterializationError.

Return type:

CFunction

Parameters:
  • math_function (PsMathFunction) –

  • dtype (PsType) –