Conversation
This comment has been minimized.
This comment has been minimized.
c075a56 to
2a627bf
Compare
This comment has been minimized.
This comment has been minimized.
Region and PartitioningStrategy
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6a662ec to
400b615
Compare
This comment has been minimized.
This comment has been minimized.
|
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 |
400b615 to
3b4f613
Compare
|
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. |
There was a problem hiding this comment.
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?
| //@ edition: 2024 | ||
|
|
||
| #![feature(gpu_offload)] | ||
| #![feature(offload)] |
There was a problem hiding this comment.
Is there a reason why you added another feature instead of reusing the existing one?
|
|
||
| /// no-op launch check for kernel arguments that are not [`Region`]s. | ||
| #[doc(hidden)] | ||
| #[unstable(feature = "offload", issue = "131513")] |
There was a problem hiding this comment.
same here, can you reuse gpu_offload as fueatre?
| /// Checks that a kernel using this strategy can be launched with `len` | ||
| /// elements on a `grid` by `block` launch configuration. | ||
| /// | ||
| /// This is called automatically before the kernel is launched. |
There was a problem hiding this comment.
Can you make it more explicit (here and in the trait safety note) that this is also soundness-critical?
In summary, this is only allowed to unconditionally return Ok iff. the given strategy can run with arbitrary len+grid+block values. If there are any combinations where an impl would return incorrect results or cause UB, then check_launch must return a LaunchError. We can later ask Ralf or someone unbiased to check that our description is unambiguous.
| } | ||
|
|
||
| fn contains_nested_offload_region<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ||
| ty.walk().skip(1).any(|arg| arg.as_type().is_some_and(|ty| is_region_ty(tcx, ty))) |
There was a problem hiding this comment.
Ty::walk skips a few relevant cases:
2 /// Iterator that walks `self` and any types reachable from
1 /// `self`, in depth-first order. Note that just walks the types
2175 /// that appear in `self`, it does not descend into the fields of
1 /// structs or variants. For example:
E.g.
struct Wrapper<'a> {
region: Region<'a, f32, Dummy>,
scalar: f32,
}| $crate::offload!(@device $device), | ||
| ($({ | ||
| let __offload_arg = $arg; | ||
| (&__offload_arg).__offload_check_launch(__offload_grid, __offload_block); |
There was a problem hiding this comment.
It seems like I can skip this this test safely by just replacing
offload! {... args = (foo,bar), }with
let t = (foo,bar);
offload! { ... args = t, }Just to get started, you can just reject the second case and leave a fixme note in a test and macro for now, we can do something smarter later.
Now
Regionare lang items and mapped as slices.needs #156620 to workr? @ZuseZ4