Skip to content

Bazel: DPC++ tests/examples cannot be analyzed in release link modes -- @onedal_release//:onedal_static_dpc does not exist #3791

Description

@napetrov

_get_dpc_deps in dev/bazel/dal.bzl builds a DPC++ target's dependencies by appending _dpc to every entry of dal_deps. For tests and examples, dal_deps comes from _test_link_mode_deps, which is a select over the link mode:

def _test_link_mode_deps(dal_deps, use_onedal_release_libs=True):
    return _select({
        "@config//:test_link_mode_dev": dal_deps,
        "@config//:test_link_mode_release_static":  ["@onedal_release//:onedal_static"],
        "@config//:test_link_mode_release_dynamic": ["@onedal_release//:onedal_dynamic"],
    })

So a DPC++ target in release_static mode asks for @onedal_release//:onedal_static_dpc, and neither dev/bazel/deps/onedal.tpl.BUILD nor dev/bazel/deps/onedal_win.tpl.BUILD declares such a target. Measured on Linux, main, against a Bazel-built release:

$ bazel cquery 'filter(":onedal_", deps(//examples/oneapi/dpc:_basic_statistics_dense_batch_dpc))' \
      --test_link_mode=release_static
ERROR: .../external/+onedal_repo+onedal_release/BUILD: no such target
  '@@+onedal_repo+onedal_release//:onedal_static_dpc': target 'onedal_static_dpc' not declared
  ... and referenced by '//examples/oneapi/dpc:_basic_statistics_dense_batch_dpc'
ERROR: Analysis of target '//examples/oneapi/dpc:_basic_statistics_dense_batch_dpc' failed

The same query in release_dynamic mode resolves, because onedal_dynamic_dpc happens to exist:

$ bazel cquery 'filter(":onedal_(dynamic|static)", deps(//examples/oneapi/dpc:_basic_statistics_dense_batch_dpc))' \
      --test_link_mode=release_dynamic
@onedal_release//:onedal_dynamic_dpc (431669a)

CI does not notice because no job builds a DPC++ test or example in a release link mode. The release-mode example steps in .ci/pipeline/ci.yml are //examples/daal/cpp:all and //examples/oneapi/cpp:all, and neither package contains a _dpc cc_test/cc_binary target — the only dpc-named entries there are the example_util_dpc header module. //examples/oneapi/dpc:all (94 targets) is never built in release_static or release_dynamic by any pipeline.

Two ways out, and I have no opinion strong enough to pick without a maintainer:

  1. Declare the missing release targets (onedal_static_dpc, and on Windows the DPC import library/DLL in onedal_repo first) so that DPC++ tests and examples can genuinely link against a release.
  2. Make the release-mode dependency selection non-DPC-aware, i.e. do not _dpc-mangle labels that come from _test_link_mode_deps, so DPC++ targets in release modes link the host release libraries deliberately rather than by accident.

Either way it would be worth adding a //examples/oneapi/dpc:all --test_link_mode=release_dynamic step, otherwise the configuration stays untested whichever fix lands.

Found while reviewing feedback on #3790, which removes the Windows onedal_dynamic_dpc stub; that target is unreachable in every configuration CI exercises, and this issue is the reason the asymmetry existed in the first place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions