-
Notifications
You must be signed in to change notification settings - Fork 10
Refactoring & test FsGrid #33
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
base: master
Are you sure you want to change the base?
Conversation
Removed unnecessary inheritance of the pointless struct
…hpp; Add unit tests for tools
…sts to unit tests
…function; Add test for comparing fsgrid display string to a reference string; Add testdata directory that's symlinked to build dir during build
… done now in one place
…other updateGhostCells that takes in FsData
… body. Avoids having to call fsgird.* functions from the lambda, whcih breaks in some cases.
|
Turns out that trying to call fsgrid member functions from the lambda's loop bodies in the way I was attempting that was breaking things badly in some cases. So I now resolved my conundrum from 2 months ago – how to obtain i,j,k / global i,j,k / cellid / physical coordinates inside the loop body – by providing it to the loop body from various fsgrid.parallel_for_* versions. This leads to some code duplication but in many cases we don't need any of these, or only a subset, so to avoid recomputing and passing them all the time I went for this way of doing. Feel free to point me to more elegant ways of handling these cases now. |
Refactor FsGrid
FsGrid is now a "singleton" in the sense that vlasiator uses only a single instance of it. It's a structure that has the coordinates for different spaces (global, rank local, physical), maps ranks to a 3D neighbourhood and stores
MPI_Datatypeinformation (offsets to arrays etc.) per neighbour.Data storage is now handled by a separate structure,
FsData. It owns the data, storing the allocated pointer in astd::unique_ptr. Currently it only allocates memory for the CPU (usingstd::malloc), but it can be easily extended to allocate memory using Cuda, Hip, Sycl or any other API.Data is accessed with the help of
FsStencilthat computes 1D indices from 3D indices.FsGrid has a
parallel_formethod, which can be used to run some code (defined by a lambda) for each local cell of the fsgrid. Currently it's only implemented for the CPU.There are over 50 tests for FsGrid and related structs that assert the correct behaviour.
Other changes:
fsgrid.hppat root tosrc/grid.hpp, whilefsgrid.hppstill exists for single file include purpose