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

Compute-Intensive Kernel Hits NaN #71

Open
frobnitzem opened this issue Dec 22, 2020 · 3 comments
Open

Compute-Intensive Kernel Hits NaN #71

frobnitzem opened this issue Dec 22, 2020 · 3 comments

Comments

@frobnitzem
Copy link

This kernel:

A[i] = _mm256_fmadd_pd(A[i], A[i], A[i]);

repeatedly applies
A = A*A + A (i.e. fmadd(A, A, A))
which quickly escalates to A=NaN.

To avoid this, the kernel can be changed to
A = -A*A + A (i.e. fnmsub(A, A, A)).

This makes the iteration equivalent to the Logistic map with r=1.
Adjusting the initial condition to A = 0.7 (or anything between 0 and 1) makes the iterations converge slowly to 0 over time.

@hyviquel
Copy link

hyviquel commented Jan 5, 2021

@elliottslaughter Do you think this problem can be linked to #69 ?

@elliottslaughter
Copy link
Contributor

@hyviquel It shouldn't have anything to do with that issue since the results of the compute bound kernel are thrown away, and the "result" that is actually written into the output region is instead a tuple containing the timestep and point (column) of the task.

@frobnitzem Thanks for pointing this out. Overall this looks good to me. I don't think it will change the practical results on any platforms we tested (since we already verified that we hit peak FLOPS), but it is true that a future system might hypothetically add an early-out for NaNs (which would then cause Task Bench to over-report its achieved FLOPS).

I'm happy to take a PR on this or may get back to it myself in a week or so. (Currently digging myself out of things that have been piling up since the break.)

@frobnitzem
Copy link
Author

frobnitzem commented Jan 8, 2021 via email

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