YASK
Yet Another Stencil Kit: a software framework for creating HPC stencil code. Copyright 2014-2023 Intel Corporation.
|
For an overview of YASK, see the YASK tutorial.
The typical high-level YASK workflow is as follows:
There are two sets of APIs provided by YASK corresponding to the first two tasks:
For each of the tasks, you can either use the YASK-provided application or create your own application built with the corresponding API.
These alternatives may be mixed-or-matched in all combinations. For example, you can use the YASK-provided stencil compiler to generate a YASK kernel library and then use that library via the kernel API to create your own stencil-based Python application.
The following sub-sections describe each of the tasks in the workflow and when the APIs may be used.
A stencil solution consists of the variables containing the problem data and one or more equations that describe how points in the variables are calculated. An equation consists of a point to be calculated that "EQUALS" an expression consisting of other points, constants, mathematical operators, etc.
u(t+1, x, y) EQUALS (u(t, x, y) + u(t, x+1, y) + u(t, x, y+1)) / 3
.A new stencil solution may be defined in one of the following ways:
bin/yask_compiler.exe
.Makefile
, or you can build it explicity via make compiler
and run it from your shell command-prompt.make
to build the kernel library, the generated output from the compiler utility is automatically written to a pre-determined temporary file and compiled into the optimized kernel library.src/stencils
.YK_CODE_FILE=
filename when running make
to build the kernel library.src/compiler/tests/yask_compiler_api_test.cpp
for an example stencil definition in C++ or src/compiler/tests/yask_compiler_api_test.py
for an example stencil definition in Python.In either case, the resulting generated code should written to the C++ stencil-code file to be compiled into the kernel library.
Once the stencil-code file is created, it must be compiled into a YASK kernel library.
Makefile
, e.g., via make -j stencil=iso3dfd arch=knl
, which builds the "iso3dfd" stencil for the Intel Xeon Phi processor.Makefile
; you'll just need to specify the filename via YK_CODE_FILE=
filename as described above. You'll also still need to specify the target architecture and give a descriptive name to the stencil. Example: make stencil=my-stencil arch=hsw kernel-only YK_CODE_FILE=my_stencil_code.hpp
.If make
is invoked as in one of the above examples, it will create the kernel library as lib/libyask_kernel.
stencil.arch.so
, where stencil and arch match the corresponding variables provided during make
. (If you want the file named differently, you can override stencil with YK_STENCIL=
stencil_name and/or arch with YK_ARCH=
arch_name.)
To use the kernel library, an executable must be created from it. This may be done in one of the following ways:
bin/yask_kernel.
stencil.arch.exe
when make
is invoked as in the above examples.bin/yask.sh
to obtain a performance measurement of the kernel.src/kernel/tests/yask_kernel_api_test.cpp
for an example kernel usage in C++ or src/kernel/tests/yask_kernel_api_test.py
for an example kernel usage in Python.make clean
to force the removal of all kernel-specific intermediate code. Otherwise, you will likely see some unexpected errors when building the new kernel.This section provides usage information for the YASK stencil compiler API (application-programmer interface).
The API is available for C++ and for Python via SWIG. Type names are prefixed with 'yc_' to indicate "YASK compiler"; this distinguishes them from the 'yk_'-prefixed types used in the "YASK kernel" API.
The types, classes, and functions are listed in YASK Compiler.
bin/yask_compiler.exe
:src/stencils
showing how to define solutions from these base classes.+
, *
, etc.), to build up larger expressions. Some math functions like square-root and cosine are also available.EQUALS
operator to specify an expression on the right-hand side (RHS) and the point in a variable that is defined to be equal to it on the left-hand side (LHS).src/stencils
directory.real_bytes=
4|8 make
parameter.fold=
fold-spec and cluster=
cluster-spec make
parameters.arch=
arch-name make
parameter.As discussed earlier, the kernel API is only needed for integrating a YASK kernel into your final application. For evaluating performance, use the provided bin/yask.sh
utility, which makes the needed calls to the kernel API for you.
This section provides usage information for the YASK stencil kernel API (application-programmer interface).
The API is available for C++ and for Python via SWIG. Type names are prefixed with 'yk_' to indicate "YASK kernel"; this distinguishes them from the 'yc_'-prefixed types used in the "YASK compiler" API.
The types, classes, and functions are listed in YASK Kernel.
The following examples illustrate possible combinations of compilers and kernels and show how to invoke a set of tests for each combination.
stencil=
_stencil-name_ to use a specific stencil for testing.arch=
_arch-name_ to target one of the architectures listed in the Makefile
if desired.make clean
before all of the example commands to ensure consistent builds.Stencil Compiler | Stencil Application | Test Command |
---|---|---|
YASK-provided | YASK-provided | make -j yc-and-yk-test |
YASK-provided | C++ test example | make -j yc-and-cxx-yk-api-test |
YASK-provided | Python test example | make -j yc-and-py-yk-api-test |
C++ test example | YASK-provided | make -j cxx-yc-api-and-yk-test |
C++ test example | C++ test example | make -j cxx-yc-api-and-cxx-yk-api-test |
C++ test example | Python test example | make -j cxx-yc-api-and-py-yk-api-test |
Python test example | YASK-provided | make -j py-yc-api-and-yk-test |
Python test example | C++ test example | make -j py-yc-api-and-cxx-yk-api-test |
Python test example | Python test example | make -j py-yc-api-and-py-yk-api-test |