Skip to content

Commit 75f4a24

Browse files
tpadioleauPaulGannayEmilyBourne
authored
Apply suggestions from code review
Co-authored-by: PaulGannay <paul.gannay@cea.fr> Co-authored-by: Emily Bourne <louise.bourne@gmail.com>
1 parent 19f426f commit 75f4a24

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int main()
6464
for (ddc::DiscreteElement<Dim1> const idx1 : dom1) {
6565
ddc::ChunkSpan<int, ddc::DiscreteDomain<Dim2>> const slice = my_array[idx1];
6666

67-
// The following would NOT compile if sum_over_dim2 si called
67+
// The following would NOT compile if sum_over_dim2 is called
6868
// with a `DiscreteDomain<Dim1>`, ensuring type safety.
6969
std::cout << sum_over_dim2(slice) << '\n';
7070
}

paper/paper.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ The Discrete Domain Computation (DDC) library is a C++ library designed to provi
4747

4848
## Statement of need
4949

50-
The use of multidimensional arrays is widespread across various fields, particularly in scientific computing, where they serve as fundamental data containers. A primary motivation for their use is their potential to improve computational performance by leveraging problem-specific structure. For instance, when solving a partial differential equation that results in a stencil problem, computations typically achieve higher efficiency on a structured mesh compared to an unstructured mesh. This advantage primarily stems from a better usage of memory like predictable memory accesses and better cache utilization.
50+
The use of multidimensional arrays is widespread across various fields, particularly in scientific computing, where they serve as fundamental data containers. A primary motivation for their use is their potential to improve computational performance by leveraging problem-specific structures. For instance, when solving a partial differential equation that results in a stencil problem, computations typically achieve higher efficiency on a structured mesh compared to an unstructured mesh. This advantage primarily stems from a better usage of memory, for example predictable memory accesses and better cache utilization.
5151

5252
Many programming languages commonly used in scientific computing support multidimensional arrays in different ways. Fortran, a longstanding choice in the field, and Julia, a more recent language, both natively support these data structures. In contrast, the Python ecosystem relies on the popular NumPy library’s `numpy.Array` [@harris2020array]. Meanwhile, C++23 introduced `std::mdspan` to the standard library. This container was inspired by `Kokkos::View` from the Kokkos library which also serves as the foundation of DDC.
5353

5454
Despite their importance, multidimensional arrays introduce several practical challenges. In a sense, they encourage the usage of implicits in the source code. A frequent source of errors is the inadvertent swapping of indices when accessing elements. Such errors can be difficult to detect, especially given the common convention of using single-letter variable names like `i` and `j` for indexing. Another challenge in medium to large codebases is the lack of semantic clarity in function signatures when using raw multidimensional arrays. When array dimensions carry specific meanings, this information is not explicitly represented in the source code, leaving it up to the user to ensure that dimensions are ordered correctly according to implicit expectations. For example it is quite usual to use the same index for multiple interpretations: looping over mesh cells identified by `i` and interpreting `i+1` as the face to the right. Another example is slicing that removes dimensions, this operation may change the relative ordering of dimensions.
5555

56-
Solutions have been proposed in Python and Julia to address these issues. In Python, the Xarray [@hoyer2017xarray] and Pandas [@reback2020pandas] libraries allow users to label dimensions that can then be used to perform computation. Following a similar approach, the "Discrete Domain Computation" (DDC) library aims to bring equivalent functionality to the C++ ecosystem. It uses a zero overhead abstraction approach, i.e. with labels fixed at compile-time, on top of different performant portable libraries, such as: Kokkos [@9485033], Kokkos Kernels (TODO: add a citation), Kokkos-fft (TODO: add a citation) and Ginkgo [@GinkgoJoss2020].
56+
Solutions have been proposed in Python and Julia to address these issues. In Python, the Xarray [@hoyer2017xarray] and Pandas [@reback2020pandas] libraries allow users to label dimensions that can then be used to perform computations. Following a similar approach, the "Discrete Domain Computation" (DDC) library aims to bring equivalent functionality to the C++ ecosystem. It uses a zero overhead abstraction approach, i.e. with labels fixed at compile-time, on top of different performant portable libraries, such as: Kokkos [@9485033], Kokkos Kernels (TODO: add a citation), Kokkos-fft (TODO: add a citation) and Ginkgo [@GinkgoJoss2020].
5757

5858
The library is actively used to modernize the Fortran-based Gysela plasma simulation code (TODO: add a citation). This simulation code relies heavily on high-dimensional arrays that span multiple representations, including Fourier, spline, Cartesian, and various curvilinear meshes. In the legacy Fortran implementation, these arrays were manipulated using implicit conventions, making it difficult to enforce correctness at the API level. DDC enables a more explicit, strongly-typed representation of these arrays, ensuring at compile-time that function calls respect the expected dimensions. This reduces indexing errors and improves code maintainability, particularly in large-scale scientific software.
5959

@@ -66,7 +66,7 @@ The DDC library is a C++ library designed for expressive and safe handling of mu
6666
DDC offers two multidimensional containers designed over the C++ 23 multidimensional array `std::mdspan`:
6767

6868
- `Chunk` an owning container, i.e. it manages the lifetime of the underlying memory allocation,
69-
- `ChunkSpan` is a non-owning container view over existing memory allocation.
69+
- `ChunkSpan` is a non-owning container view on an existing memory allocation.
7070

7171
### Strongly-typed labelled indices
7272

@@ -85,15 +85,15 @@ Unlike `DiscreteVector` indices, users cannot directly interpret the internal re
8585

8686
### Sets of `DiscreteElement`
8787

88-
The semantics of DDC containers is to associate data to a set of `DiscreteElement` indices. Let us note that the set of all possible `DiscreteElement` has a total order that is typically established once and for all at program initialisation. Thus to be able to construct a DDC container one must provide a multidimensional set of `DiscreteElement` indices, only these indices can be later used to access the container’s data.
88+
The semantics of DDC containers associates data to a set of `DiscreteElement` indices. Let us note that the set of all possible `DiscreteElement` has a total order that is typically established once and for all at program initialization. Thus to be able to construct a DDC container one must provide a multidimensional set of `DiscreteElement` indices, only these indices can be later used to access the container’s data.
8989

9090
The set of `DiscreteElement` is a customization point of the library. It takes the form of a Cartesian product of the different dimensions. DDC predefines the following sets:
9191

9292
- `DiscreteDomain`, a Cartesian product of intervals of `DiscreteElement` in each dimension,
9393
- `StridedDiscreteDomain`, a Cartesian product of sets of `DiscreteElement` with a fixed step/stride in each dimension,
9494
- `SparseDiscreteDomain`, a Cartesian product of explicitly ordered lists of `DiscreteElement` in each dimension.
9595

96-
The performance of the container's data access depends on the properties of the set considered. Indeed the set is used to retrieve the position of a given multi-index relatively to the front multi-index. Thus the performance of this operation depends on the information available in the set.
96+
The performance of the container's data access depends on the properties of the set considered. Indeed the set is used to retrieve the position of a given multi-index relative to the front multi-index. Thus the performance of this operation depends on the information available in the set.
9797

9898
### Slicing
9999

0 commit comments

Comments
 (0)