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

Unexpected behavior introduced in v1.08 #24

Open
tq-z opened this issue Jul 18, 2022 · 4 comments
Open

Unexpected behavior introduced in v1.08 #24

tq-z opened this issue Jul 18, 2022 · 4 comments

Comments

@tq-z
Copy link

tq-z commented Jul 18, 2022

Hi,

I noticed the v1.08 unrolls the comparison loops manually here:

tn93/src/tn93_shared.cc

Lines 584 to 605 in 55565df

for (; p + 2 <= span_start; p+=2) {
unsigned c1 = s1[p], c2 = s2[p];
unsigned c3 = s1[p+1], c4 = s2[p+1];
if (__builtin_expect(c1 < 4 && c2 < 4, 1)) {
integer_counts [c1][c2] ++;
} else { // not both resolved
if (c1 == GAP || c2 == GAP) {
continue;
}
ambiguityHandler (c1,c2);
}
if (__builtin_expect(c3 < 4 && c4 < 4, 1)) {
integer_counts2 [c3][c4] ++;
} else { // not both resolved
if (c3 == GAP || c4 == GAP) {
continue;
}
ambiguityHandler (c3,c4);
}
}
. The continue at line 592 may make the comparison at line 597-604 skipped. Is it a new feature or bug?

Thanks,
Tianqi

@spond
Copy link
Member

spond commented Jul 18, 2022

Dear @tq-z,

Well-spotted. This is a bug. I'll fix ASAP and release a new version (@stevenweaver -- please update our dependancies).

Best,
Sergei

@niemasd
Copy link
Contributor

niemasd commented Jul 19, 2022

Thank you for fixing this so quickly, @spond and @stevenweaver!

@spond
Copy link
Member

spond commented Jul 19, 2022

Dear @niemasd,

My pleasure. I am glad @tq-z found the issue. The manual unrolling was actually to allow some degree of CPU parallelism in this "chokepoint" loop with unavoidable data dependencies. In my hands, achieves 20-40% speedups.

Best,
Sergei

@niemasd
Copy link
Contributor

niemasd commented Jul 20, 2022

Wow, 20-40% speedup is exciting! I look forward to trying it out!

Thanks,
-Niema

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

No branches or pull requests

3 participants