Skip to content

From quadratic to linear complexity. - #225

Closed
lordnn wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
lordnn:main
Closed

From quadratic to linear complexity.#225
lordnn wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
lordnn:main

Conversation

@lordnn

@lordnn lordnn commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

I've lose my fight vs git and have opened new PR.

lordnn added 2 commits July 15, 2026 00:35
Signed-off-by: lordnn <lordnn@yahoo.com>
Signed-off-by: lordnn <lordnn@yahoo.com>
@lordnn

lordnn commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Multithreading may be difficult, Let's try once again:
For example - 3 threads (A, B, C).

Thread A: finding loop 0 (NOT_ENCODED) -> process tile 0
Thread C: finding loop 0 (ON_ENCODING), 1 (NOT_ENCODED) -> process tile 1
Thread B: finding loop 0 (ON_ENCODING), 1 (ON_ENCODING), 2 (NOT_ENCODED) -> process tile 2
// here it doesn't matter what thread will finish first, because next NOT_ENCODED tile has index 3. Let it be C.
Thread C: finding loop 0 (ON_ENCODING), 1 (ENCODED), 2 (ON_ENCODING), 3 (NOT_ENCODED) -> process tile 3

And so on. Tiles processing start in monotonic order. So ctx->tile_idx is an index of the next NOT_ENCODED tile.

Regarding new variable to ctx - you don't need at all oapve_tile_t.stat variable.
So you may save sizeof(s32) * OAPV_MAX_TILES number of bytes, at least for encoder case.

P.S. SATD calculation has constant time (not a funtion of number of tiles). Quadratic will alway beat constant, you only need to increase number of tiles. And finding loop leads to CPU-cache pollution.

@kpchoi

kpchoi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Adopted in #247 with the original commit authorship preserved. volatile and the critical section around the completion status updates are kept. Closing in favor of #247.

@kpchoi kpchoi closed this Aug 7, 2026
@lordnn

lordnn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

oapvd_tile->bs_beg used in absolutely the same manner as oapvd_tile->stat - update in one thread and catch updated value in another. But no volatile for bs_beg.

Because volatile IS NOT ABOUT MULTITHREADS SYNCHRONIZATION!!!

volatile is about MMIO-registers in device driver development.

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