Skip to content

Offload safe mutable args with Region and PartitioningStrategy - #158076

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Sa4dUs:offload-region
Oct 21, 2026
Merged

rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Sa4dUs:offload-region

Conversation

@Sa4dUs

@Sa4dUs Sa4dUs commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Now Region are lang items and mapped as slices.
needs #156620 to work

r? @ZuseZ4

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 18, 2026
@rust-log-analyzer

This comment has been minimized.

@Sa4dUs
Sa4dUs force-pushed the offload-region branch 2 times, most recently from c075a56 to 2a627bf Compare August 13, 2026 14:05
@rust-log-analyzer

This comment has been minimized.

@Sa4dUs Sa4dUs changed the title offload region Offload safe mutable args with Region and PartitioningStrategy Aug 13, 2026
@Sa4dUs
Sa4dUs marked this pull request as ready for review August 13, 2026 16:21
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

Comment thread library/core/src/offload/mod.rs Outdated
Comment thread tests/codegen-llvm/gpu_offload/region_host.rs Outdated
Comment thread library/core/src/offload/mod.rs Outdated
@rustbot

This comment has been minimized.

@ZuseZ4

ZuseZ4 commented Sep 5, 2026

Copy link
Copy Markdown
Member

Next round. I think we should actually refuse all cases (for now) where we have a Region within any ADT/struct/slice, etc. not just &Region. Most of them would be transfered incorrectly, and I don't think we gain much. The other direction is something like Region<Vec<f32>, S>, where we also transfer T incorrectly. But to be fair, I think that direction is already unchecked on main. I assume that offloading a vec will still do the wrong thing, so I'm fine if we accept that here as well till we implement a proper handling. But also feel free to already reject it already if you want.

Comment thread compiler/rustc_middle/src/ty/offload_meta.rs
Comment thread library/core/src/offload/mod.rs Outdated
@rustbot

This comment has been minimized.

@ZuseZ4 ZuseZ4 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I left another round, mostly about comments and tightening the checks.
I feel like we'll need to restrict get and get_mut a bit further (or at least describe them better), but we can leave that for the last round (and discuss on Wednesday).

Now that it seems closer to the final version, can you add a description to
https://rustc-dev-guide.rust-lang.org/offload/internals.html ?
Probably best as a new subsection, so that we have one about the build pipeline, and one about the safety/region design?

View changes since this review

Comment thread tests/codegen-llvm/gpu_offload/auxiliary/offload_strategies.rs Outdated
Comment thread library/core/src/offload/mod.rs Outdated
Comment thread library/core/src/offload/mod.rs
Comment thread compiler/rustc_hir_typeck/src/intrinsicck.rs Outdated
Comment thread library/core/src/offload/mod.rs
@rustbot

rustbot commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

The rustc-dev-guide subtree was changed. If your future PRs only touch the subtree, consider submitting them directly to rust-lang/rustc-dev-guide, which is where the document is primarily maintained (and has faster CI).

cc @BoxyUwU, @tshepang

@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label Sep 21, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread library/core/src/offload/mod.rs
@ZuseZ4

ZuseZ4 commented Oct 21, 2026

Copy link
Copy Markdown
Member

The intrinsic bypasses the safety checks but I think that's fine and actually good for experimenting. End-users shouldn't call our intrinsics anyway, and use the safe macro.

The number of tests looks good now, real uses are in our rajaperf implementation. We should talk in the next PR about how many of those usages we want to upstream, and might need to iterate on this implementation if we find memory access patterns that we can't safely wrap.

I also think we should generate noalias annotations for those NonNull pointers, but that's too tricky for this PR.

It's also inconvenient that we have to error for the args are not a tuple literal, but stored in a variable. I think oli had a prototype that allowed type-checking macro args, so we might be able to use that in the future.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit fd0ae52 has been approved by ZuseZ4

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: github outage

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #164383 (handle higher-ranked preds in imperfect derives diagnostic)
 - #164620 (Wrap expected_ty for cfi-{diag,recover} in with_no_trimmed_paths)
 - #164684 (Remove redundant `PartialOrd` chaining methods)
 - #158076 (Offload safe mutable args with `Region` and `PartitioningStrategy`)
 - #164680 (Add regression test for async fn declared with #[eii])
 - #164696 (Add `#[default]` for `newtype_index!`)
@rust-bors
rust-bors Bot merged commit 53d4374 into rust-lang:main Oct 21, 2026
13 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup merge of #158076 - Sa4dUs:offload-region, r=ZuseZ4

Offload safe mutable args with `Region` and `PartitioningStrategy`

Now `Region` are lang items and mapped as slices.
~needs #156620 to work~

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

Labels

A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants