Skip to content

Contributing

Braden Stefanuk edited this page Sep 30, 2024 · 17 revisions

This page is deprecated as of 2024-06-14 and will be removed for ROCm 6.4. New documentation is being created to replace it.

We'd love your help, but...

  1. Never check in a tab (\t); use 4 spaces.
  2. Follow the coding style of the file you're editing (also see the linting procedure below).
  3. Make pull requests against develop branch.
  4. Rebase your develop branch against ROCmSoftwarePlatform::Tensile::develop branch right before pull-requesting.
  5. In your pull request, state what you tested (which OS, what drivers, what devices, which config.yaml's) so we can ensure that your changes haven't broken anything.
  6. To verify your change passes the automated tests, follow the testing procedure below.

Testing

Lint

Python scripts can be run through a linting program using tox (needs tox 4.0+, python 3.8+, pytest 7.2+, and pytest-xdist 3.3+):

tox -e lint

Or by running flake8 directly from the repo's root directory:

flake8 ./Tensile

Clang format check for CPP/.H files (Static Analysis)

Clang-Format relies on a set of rules (styles) configured in a ".clang-format" file. This file can be found in the root of tensile directory. Clang format executable can be found in $CLANG_FORMAT_DIR folder, For ROCm version 5.2.3 it is /opt/rocm-5.2.3/llvm/bin/clang-format.

Below command would format .cpp files and .h files according to the .clang-format rules. It is better to make the editor setup to run it on save. clang-format -i -style=file <files>

Example command to display clang-format coding errors. This command is executed for each .cpp/.h file committed in Git. sh -c '$CLANG_FORMAT_DIR/clang-format -style=file ./Tensile/Source/client/source/HardwareMonitor.cpp | diff - ./Tensile/Source/client/source/HardwareMonitor.cpp'

Client Tests

HostLibraryTests are built on gtest. To run these tests you must download the submodule:

git submodule update --init

The following steps show how to build and run all host library tests:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=<Debug|RelWithDebInfo> -DCMAKE_CXX_COMPILER=<hcc|hipcc> -DCODE_OBJECT_VERSION=<V3|V2> -DTensile_ROOT=<Path to repo>/Tensile ../HostLibraryTests
make -j
./TensileTests

For more info on running unit tests, like filtering or repeating test cases, see the following documentation: gtest docs

Kernel Tests

Kernel tests are built in pytest, and require the filelock package. A tox.ini file is provided to help setup and run tests (needs tox 3.14.5 and python 3.5 or newer):

tox -v --workdir <Path to temp directory> -e py35 -- ./Tensile/Tests -m <Test marks to run>

Alternatively, you can install pytest and filelock and run the tests directly:

py.test Tensile/Tests/ -m <Test marks to run> -n <Number of test processes> -v

Marks let you filter the tests you want to run. Omitting the parameter will run all available tests. Typically you can use the marks unit, pre_checkin, or extended to run the corresponding category of tests. Other marks are available to further narrow down a set of tests; for a full list, see pytest.ini in the main Tensile directory.

Build Directory

Specifying a build directory can speed up the tests by reusing the client executable between invocations of pytest. An absolute path should be specified:

py.test Tensile/Tests/ -m <Test marks to run> -n <Number of test processes> -v --builddir `pwd`/build

Tensile options override

You can also override any options that can be specified at the command line with --tensile-options

py.test Tensile/Tests/ ... --tensile-options=--debug