Skip to content

From quadratic to linear complexity.#202

Open
lordnn wants to merge 5 commits into
AcademySoftwareFoundation:mainfrom
lordnn:main
Open

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

Conversation

@lordnn

@lordnn lordnn commented Apr 19, 2026

Copy link
Copy Markdown

Because tidx is a monotonic sequence.

Signed-off-by: lordnn <lordnn@yahoo.com>
Signed-off-by: lordnn <lordnn@yahoo.com>
@kpchoi

kpchoi commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

It is difficult to understand why this loop index changes can lead to reduce complexity

@lordnn

lordnn commented Jun 28, 2026

Copy link
Copy Markdown
Author

It is difficult to understand why this loop index changes can lead to reduce complexity

while (1) is a cycle from 1 to num_tiles plus for cycle inside it (from 1 to num_tiles) - totally gives quadratic complexity
Inner loop iterations:
0
0 1
0 1 2
0 1 2 3
...
0 1 2 3 ... num_tiles - 1
QUADRATIC
After index was changed inner loop has only one iteration totally from 1 to 'num_tiles' during all outer loop iterations.
New inner loop iterations:
0
1
2
3
...
num_tiles - 1

@lordnn

lordnn commented Jun 29, 2026

Copy link
Copy Markdown
Author

I think It can be easily understand if you imaging only one thread execution (no thread in a thread_pool).
But in last commit I have completely removed inner loop.

Signed-off-by: lordnn <lordnn@yahoo.com>
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