Skip to content

[SYCL][NewOffloadModel] Support -fno-sycl-rdc with native_cpu and -fsycl-embed-ir #23407

Description

@srividya-sundaram

With the new offload model, -fno-sycl-rdc finalizes each translation unit's device code at compile time: a per-TU clang-linker-wrapper --no-sycl-rdc --emit-fatbin-only job produces a single wrapper module (bitcode), which the host compilation links in via -foffload-include-binary.

Two configurations produce additional host objects in clang-linker-wrapper besides that wrapper module, which the compile-step embedding cannot carry. They are currently rejected in the driver (#22833):

error: '-fno-sycl-rdc' is not supported with '-fsycl-targets=native_cpu' when using the new offloading model
error: '-fno-sycl-rdc' is not supported with '-fsycl-embed-ir' when using the new offloading model

Gaps to address

  1. -fsycl-targets=native_cpu: each split kernel module is compiled to a host object and added to the wrapper output (postLinkProcessModule in ClangLinkerWrapper.cpp, Triple.isNativeCPU() branch). The wrapper module only declares the kernel functions in its __sycl_native_cpu_decls table; their definitions live in those objects.
  2. -fsycl-embed-ir with NVPTX/AMDGCN targets: the embedded-IR image is wrapped and compiled to an extra host object (runWrapperAndCompile(..., IsEmbeddedIR=true) in postLinkProcessModule).

Supporting these with -fno-sycl-rdc requires the compile step to produce a single artifact the host compilation can consume, for example by keeping the device output as bitcode and folding it into the same wrapper module. Once supported, the diagnostic in Driver::CreateOffloadingDeviceToolChains and its tests in clang/test/Driver/sycl-no-rdc-new-driver.cpp should be removed.

Related

  • Before [SYCL][NewOffloadModel] Support -fno-sycl-rdc at compile step (-c) #22833, -fsycl-targets=native_cpu -fno-sycl-rdc -c exited successfully but embedded an empty device binary (no kernels).
  • Independently of this, any -fno-sycl-rdc compile for NVPTX currently hits a driver assertion in NVPTX::FatBinary::ConstructJob (Cuda.cpp, !GpuArch.empty()), so the -fsycl-embed-ir case is not reachable for NVPTX today.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions