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

Changed the form of the field allocators #24

Merged
merged 3 commits into from
May 6, 2024
Merged

Changed the form of the field allocators #24

merged 3 commits into from
May 6, 2024

Conversation

johnmauff
Copy link
Collaborator

This PR applies some performance changes in the OpenACC code and changes the form of the allocators in the swm_cartesian.py code. These changes while ugly significantly improve the performance of the code. Strangely, when using the gt4py.next allocator, which has an asnumpy() method, the performance of the following backends gt:gpu, numpy, and gt:cpu_ifirst is rather disappointing. So I changed the storage types to use the gt4py.storage class. While this improves the performance for all the backends significantly, this new storage class does not support the use of the asnumpy() method. So an ugly solution is to only use the gt4py.next storage class when generating output. We need to fix this but for now, this solution gives both good performance and the ability to verify correctness.

@havogt
Copy link
Collaborator

havogt commented Apr 11, 2024

Hi John, I'll properly review soon. Just a quick comment regarding asnumpy. The gt4py.cartesian storages are numpy or cupy arrays respectively (not wrapped like in gt4py.next). Therefore you can directly use them for comparison in the cpu/numpy case, while in the gpu/cupy case you can use cupy.asnumpy, with something like cupy.asnumpy(arr) if isinstance(arr, cupy.ndarray) else arr. Or use this utility function https://github.com/GridTools/gt4py/blob/705530ce245f368aaf695d278f310aea63a57851/src/gt4py/storage/cartesian/utils.py#L182.

I'll have to look closer to understand performance differences with next storages.

@havogt
Copy link
Collaborator

havogt commented May 6, 2024

I opened a PR into this one which removes all usage of gt4py.next. #25

Remove gt4py.next from swm_cartesian
@johnmauff johnmauff merged commit 9489a5b into main May 6, 2024
1 check passed
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