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

fix 'pure virtual method called' error #774

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

chongchonghe
Copy link
Contributor

@chongchonghe chongchonghe commented Oct 13, 2024

Description

Move DeviceVector inside setInitialConditionsOnGrid to avoid the pure virtual method called error, first seen in #761 .

This branch is based on dependabot/submodules/extern/amrex-6d9c25b .

Related issues

Fix issues in PR #761

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues see (see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • I have tested this PR on my local computer and all tests pass.
  • I have manually triggered the GPU tests with the magic comment /azp run.
  • I have requested a reviewer for this PR.

dependabot bot and others added 3 commits October 1, 2024 02:28
Bumps [extern/amrex](https://github.com/AMReX-Codes/amrex) from `74127d6` to `6d9c25b`.
- [Release notes](https://github.com/AMReX-Codes/amrex/releases)
- [Commits](AMReX-Codes/amrex@74127d6...6d9c25b)

---
updated-dependencies:
- dependency-name: extern/amrex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Oct 13, 2024
@chongchonghe
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe chongchonghe changed the title Chong/fix pure virtual method called error fix 'pure virtual method called' error Oct 13, 2024
@chongchonghe
Copy link
Contributor Author

@BenWibking This solves the problem, although I don't understand exactly why. It seems like the cause of the error is because amrex::Gpu::DeviceVector is declared globally and accessed inside the CPU function preCalculateInitialCondition. I moved everything in preCalculateInitialCondition to setInitialConditionsOnGrid and the issue is gone.

BenWibking
BenWibking previously approved these changes Oct 13, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 13, 2024
@BenWibking BenWibking dismissed their stale review October 13, 2024 15:51

Missed important issue

@BenWibking
Copy link
Collaborator

BenWibking commented Oct 13, 2024

@BenWibking This solves the problem, although I don't understand exactly why. It seems like the cause of the error is because amrex::Gpu::DeviceVector is declared globally and accessed inside the CPU function preCalculateInitialCondition. I moved everything in preCalculateInitialCondition to setInitialConditionsOnGrid and the issue is gone.

Ok, that makes sense. The issue is that global objects are destroyed after main() ends, so it tries to deallocate the device memory (or maybe perform other operations) after amrex::Finalize() has been called. However, the GPU is not accessible after calling amrex::Finalize(). I'm not actually sure how it worked before.

We don't want to re-read the file for each grid, though, so we still need to do this inside preCalculateInitialConditions. You can move the DeviceVectors to SimulationData<TubeProblem> instead of global variables.

@BenWibking
Copy link
Collaborator

You can move the variables into SimulationData in the same way you did so here:

template <> struct SimulationData<DustProblem> {

The only difference is that you need a DeviceVector instead of a std::vector.

@BenWibking BenWibking removed the lgtm This PR has been approved by a maintainer label Oct 13, 2024
@chongchonghe
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

sonarcloud bot commented Oct 13, 2024

@chongchonghe
Copy link
Contributor Author

@BenWibking @markkrumholz Should be ready to merge.

@chongchonghe chongchonghe added this pull request to the merge queue Oct 14, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 14, 2024
Merged via the queue into development with commit 30bc694 Oct 14, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants