Skip to content

Conversation

@vkarak
Copy link
Contributor

@vkarak vkarak commented Sep 3, 2019

This PR offers a new syntax for attaching arbitrary regression test methods to pipeline stages. This is achieved using the @run_before(stage) or @run_after(stage) decorators, where stage is a string representing a pipeline stage. Valid pipeline stages are the following: setup, compile, run, sanity, performance and cleanup. This syntax will render less common or even obsolete the overriding of the pipeline methods, such as setup() for doing common tasks, such as setting the compilation flags. Users will not have to remember the signatures of the pipeline methods and to always call super(). For example, setting the compilation flags based on the programming environment can now be written very nicely as follows:

@rfm.simple_test
class Example2bTest(rfm.RegressionTest):
    def __init__(self):
        self.descr = 'Matrix-vector multiplication example with OpenMP'
        self.valid_systems = ['*']
        self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu',
                                    'PrgEnv-intel', 'PrgEnv-pgi']
        self.sourcepath = 'example_matrix_vector_multiplication_openmp.c'
        self.build_system = 'SingleSource'
        self.executable_opts = ['1024', '100']
        self.prgenv_flags = {
            'PrgEnv-cray':  ['-homp'],
            'PrgEnv-gnu':   ['-fopenmp'],
            'PrgEnv-intel': ['-openmp'],
            'PrgEnv-pgi':   ['-mp']
        }
        self.variables = {
            'OMP_NUM_THREADS': '4'
        }
        self.sanity_patterns = sn.assert_found(
            r'time for single matrix vector multiplication', self.stdout)
        self.maintainers = ['you-can-type-your-email-here']
        self.tags = {'tutorial'}

    @rfm.run_before('compile')
    def setflags(self):
        self.build_system.cflags = self.prgenv_flags[self.current_environ.name]

Some pipeline stages, namely compile and run, are implemented as two phases: (a) launch the operation asynchronously and (b) wait for the operation to complete. In such cases the @run_after decorated functions will run after the stage is completed (i.e., after it is waited for).

This is still WIP, because I need to update the documentation. Other than that, you are free to review.

Vasileios Karakasis added 2 commits September 2, 2019 23:42
- Users may decorate any method in their test class and mark it to run before or
  after any pipeline stage.
- This takes out the burden of remembering the function signatures and calling
  super().
@vkarak vkarak requested a review from teojgo September 3, 2019 09:41
@vkarak vkarak changed the title [wip] [feat] Add new syntax for hooking functions to pipeline stages [wip] [feat] Add new syntax for hooking regression test methods to pipeline stages Sep 3, 2019
@vkarak vkarak self-assigned this Sep 3, 2019
@vkarak vkarak requested a review from victorusu September 3, 2019 09:43
@vkarak vkarak added this to the ReFrame sprint 2019w35 milestone Sep 3, 2019
@vkarak vkarak changed the title [wip] [feat] Add new syntax for hooking regression test methods to pipeline stages [wip] [feat] Add new syntax for attaching regression test methods to pipeline stages Sep 3, 2019
@vkarak vkarak changed the title [wip] [feat] Add new syntax for attaching regression test methods to pipeline stages [wip] [feat] Add new syntax for attaching arbitrary regression test methods to pipeline stages Sep 3, 2019
Copy link
Contributor

@victorusu victorusu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vkarak vkarak changed the title [wip] [feat] Add new syntax for attaching arbitrary regression test methods to pipeline stages [feat] Add new syntax for attaching arbitrary regression test methods to pipeline stages Sep 5, 2019
@vkarak vkarak removed this from the ReFrame sprint 2019w35 milestone Sep 10, 2019
@vkarak vkarak merged commit 2eec249 into reframe-hpc:master Sep 11, 2019
@vkarak vkarak deleted the feat/pipeline-hooks branch September 11, 2019 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants