Skip to content
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

Use aligned_alloc() as default allocator for HalideBuffer.h on most platforms #7190

Merged
merged 13 commits into from
Dec 7, 2022

Conversation

steven-johnson
Copy link
Contributor

No description provided.

@steven-johnson steven-johnson changed the title aligned_alloc buildbot test, ignore for now Use aligned_alloc() as default allocator for HalideBuffer.h() on most platforms Dec 1, 2022
…latforms

(See also #7189)

Modify H::R::Buffer to default to using `aligned_alloc()` instead of `malloc()`, except:
- If user code passes a non-null `allocate_fn` or `deallocate_fn`, we always use those (and/or malloc/free)
- If the code is compiling under MSVC, never use `aligned_alloc` (Windows doesn't support it)
- If HALIDE_RUNTIME_BUFFER_USE_ALIGNED_ALLOC is defined to be 0, never use `aligned_alloc` (this is to allow for usage on e.g. older Android and OSX versions which don't provide `aligned_alloc()` in the stdlib, regardless of C++ versions.)

Also, as with #7189, this ensures that the allocated space has the start of the host data as 128-aligned, and also now ensures that the size allocated 128-aligned (rounding up as needed).
@steven-johnson steven-johnson changed the title Use aligned_alloc() as default allocator for HalideBuffer.h() on most platforms Use aligned_alloc() as default allocator for HalideBuffer.h on most platforms Dec 1, 2022
@steven-johnson steven-johnson marked this pull request as ready for review December 1, 2022 18:20
@steven-johnson steven-johnson added the release_notes For changes that may warrant a note in README for official releases. label Dec 2, 2022
@steven-johnson
Copy link
Contributor Author

Added HALIDE_RUNTIME_BUFFER_ALLOCATION_ALIGNMENT to allow the default alignment of 128 to be configurable at compile time. I think this is probably ready to land (pending green); it doesn't need to land in tandem with #7189.

@steven-johnson steven-johnson merged commit a7fa32e into main Dec 7, 2022
@steven-johnson steven-johnson deleted the srj/aligned-buffer branch December 7, 2022 17:31
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
…latforms (halide#7190)

Use aligned_alloc() as default allocator for HalideBuffer.h on most platforms

(See also halide#7189)

Modify H::R::Buffer to default to using `aligned_alloc()` instead of `malloc()`, except:
- If user code passes a non-null `allocate_fn` or `deallocate_fn`, we always use those (and/or malloc/free)
- If the code is compiling under MSVC, never use `aligned_alloc` (Windows doesn't support it)
- If HALIDE_RUNTIME_BUFFER_USE_ALIGNED_ALLOC is defined to be 0, never use `aligned_alloc` (this is to allow for usage on e.g. older Android and OSX versions which don't provide `aligned_alloc()` in the stdlib, regardless of C++ versions.)

Also, as with halide#7189, this ensures that the allocated space has the start of the host data as 128-aligned, and also now ensures that the size allocated 128-aligned (rounding up as needed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_notes For changes that may warrant a note in README for official releases.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants