Skip to content

[XLS JIT] Copy counted_for loop state with memcpy. - #5547

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1016419102
Draft

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1016419102

Conversation

@copybara-service

Copy link
Copy Markdown

[XLS JIT] Copy counted_for loop state with memcpy.

The JIT copied counted_for loop state into its buffer (and the next state
back into it on every iteration) with first-class LLVM loads and stores of the
whole state type. LLVM lowers aggregate loads/stores element by element, so for
array or tuple loop states compile time and memory grew super-linearly with the
state size: AOT compiling a 15-iteration loop that updates a tuple of two
10240-element arrays took ~66s and ~13.5GB, and a loop writing a 20480-element
array needed ~27GB. Use memcpy, as the other array/tuple handlers already do;
both cases now compile in about 0.1s.

Adds FunctionJitTest.CountedForCopiesLargeLoopStateWithMemcpy, which checks
that the generated LLVM IR contains no aggregate load as large as a loop-state
array and that the loop computes the right result.

The JIT copied `counted_for` loop state into its buffer (and the next state
back into it on every iteration) with first-class LLVM loads and stores of the
whole state type. LLVM lowers aggregate loads/stores element by element, so for
array or tuple loop states compile time and memory grew super-linearly with the
state size: AOT compiling a 15-iteration loop that updates a tuple of two
10240-element arrays took ~66s and ~13.5GB, and a loop writing a 20480-element
array needed ~27GB. Use memcpy, as the other array/tuple handlers already do;
both cases now compile in about 0.1s.

Adds FunctionJitTest.CountedForCopiesLargeLoopStateWithMemcpy, which checks
that the generated LLVM IR contains no aggregate load as large as a loop-state
array and that the loop computes the right result.

PiperOrigin-RevId: 1016419102

This branch has not been deployed

No deployments
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.

1 participant