Skip to content

Fixed Bug with assume_aligned not being made for device - #13

Merged
AlyanSal merged 2 commits into
mainfrom
alyan/bugs_cleanup
Sep 30, 2026
Merged

AlyanSal merged 2 commits into
mainfrom
alyan/bugs_cleanup

Conversation

@AlyanSal

Copy link
Copy Markdown
Contributor

Summary

Restore the xpu::assume_aligned<T>(ptr) wrapper. It preserves the type based interface used by buffer and soa, and applies an alignment assumption only when the type’s storage is padded.

Why

Replacing the wrapper with using xstd::assume_aligned broke CUDA builds: cuda::std::assume_aligned expects an alignment value as its first template argument, while existing callers pass a type.

Validation

The failure was reproduced with ./scripts/test.sh --cu --clean. Run the same command after applying the fix to confirm the build and tests pass.

Comment thread xpu/memory.hpp Outdated
Comment on lines 98 to 104
template <typename T> [[nodiscard]] XPU_CUDA_CALLABLE
constexpr auto assume_aligned(T* ptr) noexcept -> T* {
if constexpr (is_padded<T>) {
return std::assume_aligned<default_align<T>>(ptr);
return xstd::assume_aligned<default_align<T>>(ptr);
} else {
return ptr;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This entire block isn't very necessary anymore. Can we just create a wrapper for assume_aligned? The no-op shouldn't be there anyway

@karl-kes karl-kes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good change for the miscompile - just a comment

@karl-kes karl-kes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@AlyanSal
AlyanSal merged commit b2a6936 into main Sep 30, 2026
2 checks passed
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.

2 participants