Skip to content

test(codegen): add AS3 aggregate device-call round-trip coverage #866

Closed

Description

@uurl

Summary

Add explicit regression coverage for shared-memory address-space (addrspace(3)) pointers crossing internal device-call boundaries inside aggregate values.

The existing addressof_sharedarray example already covers shared pointers stored in enum payloads, including nested structs and bounded arrays. What is currently missing is an explicit end-to-end test that passes aggregates containing shared pointers through a non-inlined device function and returns them back to the caller before using the recovered pointer as shared memory.

Motivation

A shared pointer embedded in an aggregate exercises several lowering boundaries:

  1. construct an aggregate containing an AS3 pointer,
  2. pass the aggregate through a device-call ABI boundary,
  3. reconstruct/use the value in the callee,
  4. return the aggregate,
  5. project the pointer from the returned aggregate,
  6. use the pointer again as shared memory.

This should be covered explicitly for the main aggregate shapes supported by the current lowering.

Proposed coverage

Extend:

crates/rustc-codegen-cuda/examples/addressof_sharedarray/src/main.rs

with #[inline(never)] #[device] round-trip helpers for:

  • struct
  • tuple
  • array
  • enum

Each returned aggregate should be validated by actually dereferencing or storing through the recovered shared pointer, rather than checking only its integer address.

Using #[inline(never)] ensures the device-call ABI boundary remains observable.

Acceptance criteria

  • Struct containing an AS3 pointer survives device call + return.
  • Tuple containing an AS3 pointer survives device call + return.
  • Array containing AS3 pointers survives device call + return.
  • Enum containing a nested AS3 pointer survives device call + return.
  • Returned pointers are used through shared-memory accesses.
  • Existing addressof_sharedarray coverage continues to pass.
  • Test passes with normal optimization.
  • Test passes with CUDA_OXIDE_NO_OPT=1.

Validation

cargo fmt --check

cargo clippy \
  -p dialect-mir \
  -p mir-importer \
  -p mir-lower \
  --all-targets -- -D warnings

cargo oxide run addressof_sharedarray

CUDA_OXIDE_NO_OPT=1 cargo oxide run addressof_sharedarray

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions