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

SoA of item variables or view of item variable with a memory area #291

Open
DavidDureau opened this issue Jul 27, 2022 · 2 comments
Open
Labels
arcane Arcane Component enhancement New feature or request

Comments

@DavidDureau
Copy link
Collaborator

Goal: to have or to "manipulate" a dynamic number of item variables

Choice 1: Array of MeshVariableArrayRefT< ItemTypeT, DataTypeT>

We could have a N-dimensional array of MeshVariableArrayRefT<>

Here, an example with a two-dimensional array.

// Pseudo-code
"UniqueArray2< VariableCellArrayReal >" m_aof_arr;

Integer dim1 = 8;
Integer dim2 = 100;

m_aof_arr.resize(dim1, dim2, VariableBuildInfo(mesh(), "MyCellArray"));
// m_aof_arr is a two-dimensional array of VariableCellArrayReal 
//                             named String::format("MyCellArray_{0}_{1}", i1, i2)


for(Integer i1=0 ; i1<dim1 ; ++i1) {
  for(Integer i2=0 ; i2<dim2 ; ++i2) {
    ENUMERATE_CELL(icell, allCells()) {
      m_aof_arr[i1][i2][icell] = ... ;
    }
  }
}

// We could synchronize just one Cell variable array
m_aof_arr[1][2].synchronize();

Choice 2: a view MeshVariableArrayViewT< ItemTypeT, DataTypeT>

Thanks to a memory area, we could create a kind of view on a Cell variable array.

Here an example, I don't know if we could use NumArray to pre-allocate data.

// Psuedo-code
Integer dim1 = 8;
Integer dim2 = 100;
NumArray<Real, 3> num_arr(dim1, dim2, allCells().size());


for(Integer i1=0 ; i1<dim1 ; ++i1) {
  for(Integer i2=0 ; i2<dim2 ; ++i2) {

    MeshVariableArrayViewT<Cell, Real> arr_i1_i2(num_arr(i1,i2).data(), mesh());

    ENUMERATE_CELL(icell, allCells()) {
      arr_i1_i2[icell] = ... ;
    }
  }
}

MeshVariableArrayViewT<Cell, Real> arr_1_2(num_arr(1,2).data(), mesh());
arr_1_2.synchronize();
@DavidDureau DavidDureau added enhancement New feature or request arcane Arcane Component labels Jul 27, 2022
@grospelliergilles
Copy link
Member

Thanks for the issue.
I'm gonna think about it.
I have several questions:

  • What kind of operation do you need ? Is synchronize() the only needed operation ?
  • Are the number dim1 and dim2 allowed to change during the simulation ?

@DavidDureau
Copy link
Collaborator Author

I think we could consider dim1 and dim2 are not allowed to change during the simulation.
Note: the number of dimensions is not limited to 2, we could have 2 or more dimensions (dim3, dim4 and so on).

I don't know if synchronize would be the only needed operation.
Of course, we need to read and/or write at item in a loop ...

Maybe, we need to dump/restore the array so, at the end, the only right choice could be "choice 1" ("choice 2" is only a temporary view so we couldn't dump/restore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arcane Arcane Component enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants