Skip to content

Add support for raw_kernel_arg extension #2038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sommerlukas
Copy link
Contributor

Add support for the DPC++ SYCL extension raw_kernel_arg that allows to pass a binary blob as kernel arguments.

This is for example useful if the kernel uses a struct as kernel parameter, but is loaded from SPIR-V and the argument type is unknown for set_arg.

The implementation follows #1984.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

@coveralls
Copy link
Collaborator

coveralls commented Apr 2, 2025

Coverage Status

coverage: 86.321% (-0.06%) from 86.379%
when pulling 1ea6b9c on sommerlukas:raw-kernel-arg
into 67317b0 on IntelPython:master.

DPCTL_API
void DPCTLRawKernelArg_Delete(__dpctl_take DPCTLSyclRawKernelArgRef Ref)
{
delete unwrap<RawKernelArgData>(Ref);

Choose a reason for hiding this comment

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

auto RawArg = unwrap<RawKernelArgData>(Ref);
delete[] RawArg->bytes;
delete RawArg;

std::memcpy(rawData.get(), bytes, count);
auto RawKernelArg = std::unique_ptr<RawKernelArgData>(
new RawKernelArgData{rawData.release(), count});
rka = wrap<RawKernelArgData>(RawKernelArg.release());

Choose a reason for hiding this comment

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

Sorry. I've misled you in my previous comment about unique_ptr. To make it work it should be something like this:

        auto rawData =
            std::unique_ptr<unsigned char[]>(new unsigned char[count]);
        std::memcpy(rawData.get(), bytes, count);
        auto RawKernelArg = std::unique_ptr<RawKernelArgData>(
            new RawKernelArgData{rawData.get(), count});
        rka = wrap<RawKernelArgData>(RawKernelArg.get());
        RawKernelArg.release();
        rawData.release();

Otherwise rawData would leak if new RawKernelArgData{rawData.release(), count} throws.

@ndgrigorian
Copy link
Collaborator

@sommerlukas
Master now has a fix for nightly build, so please merge or rebase on master so the tests run on nightly compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants