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

Helpers: to_numpy/cupy #88

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Oct 21, 2022

  • Array4
  • PODVector_real/int (aka RealVector/IntVector)
  • SoA
  • AoS
  • ParticleTile
  • ParticleContainer (list of non-owning objects)
  • MultiFab (list of non-owning objects)

Close #55

@ax3l ax3l added the enhancement New feature or request label Oct 21, 2022
@ax3l ax3l force-pushed the topic-helpers-np-cupy branch 5 times, most recently from 1d3fad4 to 3b0c2ab Compare August 7, 2023 18:37
@ax3l ax3l mentioned this pull request Aug 7, 2023
@ax3l ax3l force-pushed the topic-helpers-np-cupy branch 6 times, most recently from 5cd8a6d to 6758c74 Compare August 10, 2023 00:02
@ax3l ax3l force-pushed the topic-helpers-np-cupy branch 6 times, most recently from d8da7df to e83ea3c Compare September 13, 2023 15:46

SoA_cp = namedtuple(type(self).__name__ + "_cp", ["real", "int"])

soa_view = SoA_cp([], [])

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable soa_view is not used.
@ax3l ax3l force-pushed the topic-helpers-np-cupy branch 2 times, most recently from 5d1c35b to 4b4d780 Compare September 13, 2023 21:48
@ax3l ax3l changed the title [WIP] Helpers: to_numpy/cupy Helpers: to_numpy/cupy Sep 21, 2023
src/Base/PODVector.cpp Fixed Show fixed Hide fixed
src/Particle/ArrayOfStructs.cpp Fixed Show fixed Hide fixed
Comment on lines +37 to +38
if order == "F":
return np.array(self, copy=copy).T
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: support AMReX-side device-to-host copies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added directly to MultiFab in #192

@ax3l ax3l merged commit 596f0e7 into AMReX-Codes:development Sep 21, 2023
@ax3l ax3l deleted the topic-helpers-np-cupy branch September 21, 2023 18:08
This was referenced Sep 22, 2023
@ax3l ax3l added the backend: cuda Specific to CUDA execution (GPUs) label Oct 3, 2023
Comment on lines +37 to +41
for idx_real in range(self.NumRealComps()):
soa_view.real.append(self.GetRealData(idx_real).to_numpy(copy=copy))

for idx_int in range(self.NumIntComps()):
soa_view.int.append(self.GetIntData(idx_int).to_numpy(copy=copy))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check if runtime attributes are part of this:
#220 (comment)

Comment on lines +77 to +81
for idx_real in range(self.NumRealComps()):
soa_view.real.append(self.GetRealData(idx_real).to_cupy(copy=copy))

for idx_int in range(self.NumIntComps()):
soa_view.int.append(self.GetIntData(idx_int).to_cupy(copy=copy))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above: Double check if runtime attributes are part of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: cuda Specific to CUDA execution (GPUs) enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.to_numpy(), .to_cupy(), etc.
1 participant