@@ -372,3 +372,112 @@ Note: please avoid using `REQUIRES: TEMPORARY_DISABLED` for this purpose, it's
372372a non-standard mechanism. Use ` UNSUPPORTED: true ` instead, we track
373373` UNSUPPORTED ` tests using the mechanism described above. Otherwise the test
374374risks remaining untraceable.
375+
376+ ## Compiling and executing tests on separate systems
377+
378+ The execution of e2e tests can be separated into compilation and execution
379+ stages via the ` test-mode ` lit parameter. This allows us to reduce testing time
380+ by compiling tests on more powerful systems and reusing the binaries on other
381+ machines. By default the ` test-mode ` parameter is set to ` full ` , indicating
382+ that both stages will run. This parameter can be set to ` build-only ` , or
383+ ` run-only ` , to only run the compilation stage, or the execution stage
384+ respectively.
385+
386+ ** NOTE:** This feature is a work-in-progress and current limitations are expected
387+ to be addressed in the near future.
388+
389+ The modes work as follow:
390+ ### ` --param test-mode=full `
391+ This is the default mode tests run in. Tests are marked as unsupported if no
392+ device on the machine can fulfill the ` REQUIRES ` /` UNSUPPORTED ` statements. In
393+ this mode all ` RUN: ` lines are executed normally, and two extra features are
394+ added: the ` build-and-run-mode ` and ` run-mode ` .
395+
396+ To make a test only run in ` full ` mode add a ` REQUIRES: build-and-run-mode ` line.
397+
398+ ### ` --param test-mode=build-only `
399+ This mode can be used to compile all test binaries. To do this all ` UNSUPPORTED `
400+ and ` REQUIRES ` statements are ignored unless they contain ` UNSUPPORTED: true ` or
401+ ` REQUIRES: build-and-run-mode ` . All ` RUN: ` lines within a test are ran in this
402+ mode unless they contain the following expansions: ` %{run} ` ,
403+ ` %{run-unfiltered-devices} ` , or ` %if run-mode ` .
404+
405+ Currently, the only triple supported for ` build-only ` mode is ` spir64 ` .
406+
407+ #### ` build-only ` future work
408+ Note, the fact that ` build-only ` ignores general ` UNSUPPORTED ` /` REQUIRES `
409+ statements is a current limitation. The logic for taking into account the
410+ features that affect compilation, and ignoring those that are only relevant to
411+ the execution of the program is currently being worked on.
412+
413+ ### ` --param test-mode=run-only `
414+ In this mode, tests will not be compiled, they will only run. To do this only the
415+ ` RUN: ` lines that contain ` %{run} ` , ` %{run-unfiltered-devices} ` or ` %if run-mode `
416+ are executed. Tests are marked as unsupported in the same manner as ` full ` mode.
417+ Since tests are not compiled in this mode, for any test to pass the test
418+ binaries should already be in the ` test_exec_root ` directory, either by having
419+ ran ` full ` or ` build-only ` modes previously on the system, or having
420+ transferred the test binaries into that directory. The ` run-mode ` feature is
421+ added when in this mode.
422+
423+ ### Resolving common Issues with separate compilation and execution:
424+ A number of extra considerations need to be taken to write tests that are able
425+ to be compiled and executed on separate machines.
426+
427+ - Tests that build and execute multiple binaries need to be written such that
428+ the output of each compilation has a different name. This way no files are
429+ overwritten, and all the necessary binaries can be transferred to the running
430+ system.
431+
432+ - Two scenarios need to be considered for tests that expectedly fail:
433+ - Tests that are expected to fail on compilation, and thus also during
434+ execution, need to be marked as ` XFAIL ` with a feature that is device
435+ agnostic, or with ` XFAIL: * ` . Device agnostic features are those which are
436+ added added through a method other than processing the output of sycl-ls, for
437+ example the OS, or the presence of a library. This needs to be done because
438+ sycl-ls is not ran in ` build-only ` mode.
439+ - If the expected failure occurs during run-time we will need to mark the test
440+ with ` XFAIL ` on a device specific feature (A feature that we add through
441+ processing sycl-ls output), or if its expected to always fail on run-time we
442+ can use ` XFAIL: run-mode ` . This is because otherwise the test would compile
443+ and pass on ` build-only ` mode and be reported as an ` XPASS ` .
444+
445+ - To separate compilation and execution of tests, we classify ` RUN: ` directives
446+ as being either build or run lines. If a line contains ` %{run} ` ,
447+ ` %{run-unfiltered-devices} ` or ` %if run-mode ` it is classified as a run line,
448+ otherwise it is classified as a build line.
449+ - All ` RUN: ` lines that execute test binaries should be marked with either
450+ ` %{run} ` or ` %{run-unfiltered-devices} ` . Otherwise they will be incorrectly
451+ marked as a build line, likely causing a failure at the ` build-only ` stage as
452+ we try to execute the program without having the appropriate devices.
453+ - The vast majority of ` RUN: ` lines that do not execute the test binaries are
454+ needed to either set up files prior to compilation, or to compile the binary,
455+ as such ` RUN: ` lines are by default considered as build lines. In the case
456+ that we need to run a line on the ` run-only ` system, and it does not make
457+ sense to mark them with ` %{run} ` or ` %{run-unfiltered-devices} ` , we can mark
458+ a line with ` %if run-mode ` to specifically make the line a run line. This
459+ situation usually appears when we need to run a command in response to the
460+ execution of the test binary.
461+
462+ - Currently the ` build-only ` mode does not support logic to properly assess the
463+ features in ` REQUIRES ` /` UNSUPPORTED ` to know if a test can be built in the
464+ system environment, or for ` spir64 ` . Only tests that are marked with
465+ ` REQUIRES: build-and-run-mode ` or ` UNSUPPORTED: true ` are skipped. Thus if a
466+ test will fail building for the build environment we have on CI or for ` spir64 `
467+ we will need to mark this as ` REQUIRES: build-and-run-mode ` . This is only
468+ temporary solution, until further work is done to properly mark tests as
469+ unsupported on ` build-only ` based on features.
470+
471+ - CPU and FPGA AOT tests are currently expected to fail when compiling and
472+ executing on separate machines. These failures occur on the ` run-only ` side,
473+ because during compilation the host machine's CPU architecture is targeted,
474+ which may be different than that of the running machine. These tests are marked
475+ as ` REQUIRES: build-and-run-mode ` as a result, until they can be refactored to
476+ compile for the architectures that will be used on the run side.
477+
478+ ### Falling back to ` full ` testing mode on ` run-only `
479+ To not lose coverage of tests marked as ` REQUIRES: build-and-run-mode ` when
480+ using ` run-only ` mode, lit can be called using
481+ ` --param fallback-to-build-if-requires-build-and-run=True ` . When this option is
482+ enabled in ` run-only ` mode, tests marked as requiring ` build-and-run-mode ` will
483+ fallback to running on ` full ` mode, instead of being reported as unsupported.
0 commit comments