Coder Social home page Coder Social logo

alpaka-job-matrix-library's Introduction

alpaka-job-matrix-library

A library to provide a job generator for CI's for alpaka based projects.

The library provides everything needed to generate a sparse combination matrix for alpaca-based projects, including a set of general-purpose combination rules.

The provision of the input parameters, the reordering of the jobs, the filtering of the job matrix and the generation of the job yaml are project specific. Therefore, the library provides an example of how most parts can be implemented.

Installation

Install via pip:

pip install alpaka-job-coverage

See pypi.org

Usage

The main function of the library is create_job_list(). It takes a list of parameters, creates the combinations, applies the combination rules, thins them and returns the sparse job matrix.

The thinning is done according to the principle all-pairs testing. The principle means that every combination of the values of at least two parameters must be part of a job, unless a filter rule forbids this. The pair_size parameter of the create_job_list() function decides how large the combination tuple must be. For example, if we have the parameter fields A, B, C and D and pair size 2, each combination of the values of AB, AC, AD, BC, BD and CD must be part of a job. If the parameter is 3, any combination of the values of ABC, ABD and BCD must be part of a job. Normally, a larger pairwise factor increases the calculation time and the number of orders.

The general form of the parameter matrix is an OrderedDict of List[Tuples[str, str]]. The first value of a tuple is the name of the software and the second value is the version. An exception is the parameter field BACKENDS. BACKENDS is a list[list[tuple[str, str]]. The inner list contains a combination of alpaka backends. This can be a complete combination matrix of all backends (the inner list contains n entries), or it can be only one backend (size of the inner list is 1), as required for cupla. A mixture of both is also possible, e.g. [(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, ON), (ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLE, ON), (ALPAKA_ACC_CPU_B_SEQ_T_OMP2_ENABLE, ON)],[(ALPAKA_ACC_GPU_CUDA_ENABLE, "11. 0")],[(ALPAKA_ACC_GPU_CUDA_ENABLE, "11.0")] ...].

In order to apply the filter rules correctly, it is necessary to use the variables defined in alpaka_job_coverage.global.

There are 3 parameters with special meaning:

  • HOST_COMPILER: Compiler for the host code, or if there is no host device code separation, the compiler for all the code.
  • DEVICE_COMPILER: Compiler for the device code, or if there is no host device code separation, the compiler is the same as the host compiler.
  • BACKENDS: See description above.

If one of these 3 parameter fields is missing, it is not guaranteed that the generator will provide correct results. All other parameter fields provided by the alpaka_job_coverage.global are optional.

Adding own parameter and rules

If you want to use a project-specific parameter, you can simply add it to the parameter list and the library will apply it. To limit the possible combinations of your new parameter, you need to add a new filter function. The create_job_list() function applies a chain of filter functions to each possible combination. Before and after each filter function is a function hook where you can insert your own filter function. The order is described in the doc string of create_job_list(). When you create a new filter rule, you must comply with the following rules:

  • The filter returns True if a combination is valid and False if not. All filters in the library follow the rule that every combination is valid until it is forbidden (blacklist).
  • The input of the filter is a combination of the values of the individual parameter fields, and the combination does not have to be complete. The list can contain at least 2 parameter fields up to all. You must check whether a parameter field is included in the current combination.
  • If a parameter field is not included in the current combination, it means that it can contain any possible value of this parameter. In practice, this means that if you only check for the presence of the parameter and return False, if the parameter is not present, no combination is possible.

ajc-validate

ajc-validate is a tool which is installed together with the alpaka-job-coverage library. The tool allows to check whether a combination of parameters passes the different filters and displays the reason if not.

ajc-validate example

Hint: The source code of the tool is located in the file validate.py.

Developing

It is strongly recommended to use a Python environment for developing the code, such as virtualenv or a conda environment. The following code uses a virtualenv.

  1. Create the environment: virtualenv -p python3 env
  2. Activate the environment: source env/bin/activate
  3. Install the library: python setup.py develop
  4. Test the installation with the example: python3 example/example.py 3.0
  5. You can run the unit tests by going to the test directory and running python -m unittest

If the example works correctly, a job.yml will be created in the current directory. You can also run python3 example/example.py --help to see additional options.

Now the library is available in the environment. Therefore you can easily use the library in your own projects via import alpaka_job_coverage as ajc.

Formatting the source code

The source code is formatted using the black formatter and the default style guide. You must install it and run black /path/to/file to format a file. A CI job checks that all files are formatted correctly. If the job fails, a PR cannot be merged.

Contribution

This section contains some hints for developing new functions. The hints are mainly for people who have no experience with setuptools and building pip packages.

  • The python setup.py develop command installs the source code files as a symbolic link. This means that changes in the source code of the Python files in the src/alpaka_job_coverage folder are directly available without any additional installation step (only a restart of the Python process/interpreter is required).
  • The software requirements are defined in setup.py and not in an additional requirements.txt.
  • It is necessary to increase the version number in version.txt before a new feature can be merged in the master branch. Otherwise the upload to pypy.org will fail because existing versions cannot be changed.

alpaka-job-matrix-library's People

Contributors

j-stephan avatar simeonehrig avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

alpaka-job-matrix-library's Issues

add formatter CI job

In my IDE, everything is automatically formatted with black and the default template. This should be checked by a CI job.

Automatically generate sanitizer jobs

It would be nice to have the sanitizer jobs (just ASan for now, but the others would also be nice in the future) automatically generated. Maybe it would be possible to always use the latest gcc/clang version that is available in the scripts?

Add version compatibility checks

It would be great if we could specify minimum / maximum versions of other components (like CUDA and CMake) to be tested with the compilers. Example:

gcc-12 was released in May 2022. It makes sense to only test this compiler together with Boost >= 1.80 since older Boost versions are notoriously not forward compatible. In a similar way we should use CMake versions that were released after gcc-12 since we don't want our build system to be older than the compiler we actually use. If we have a CUDA job, it should only run with CUDA >= 12.0. And so on.

Add `stdlib` to the list combination arguments

On Linux, the libstdc++ (shipped with GCC) and libc++ (part of the LLVM project) available. Clang can be freely combined with different libstdc++ versions or with the matching libc++ version.

add code coverage CI job

Since issue #14 is still open not all filter rules are tested, a code coverage CI job could help to solve the problem.

extend test to check if new version was added

Some of the tests test against the latest release of a software or test all versions of a software. Therefore the test should fail, if a new software version was added in versions.py until the version is covered in the tests.

define wording

During the work on Issue #35 I recognize I'm pretty inconsistent with the wording in the documentation. Therefore I should do some wording for major terms.

Rename the library in caravanbashi

The current name is complicated to remember and not fancy ๐Ÿ˜‰

@j-stephan suggest caravanbashi, which is a leader of a caravan, see here. The name sounds fancy and we can it short it to bashi, which provides also the opportunity to do bad bash jokes ๐Ÿ˜„

Let's determine the effort to rename the package in the pypi registry.

change API from parameter list to parameter dict

During my work on the unit tests, I found out that the unit test framework execute tests in parallel via multithreading. This is problematic, because the generator is not thread safe, because it use the global variable param_map to map a parameter name to an index. There is no easy way to disable multithreading. So the problem cannot be solved easily. In the meantime, I found out, that the allpairspy pairwise library supports OrderedDict. If I replace the list input with a OrderedDict, the param_map variable becomes obsolete and the generator is thread safe. Also API and functions becomes much easier.

The disadvantage of the approach is a lot of work and an API break. So this issue moves the library to version 2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.