# Slow data transfer in precice setup

**URL:** <https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677>\
**Category:** Using preCICE\
**Tags:** mpi, data-mapping, volume-coupling, performance\
**Created:** [December 1, 2025, 12:17pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677 "2025-12-01T12:17:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![alebherz](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alebherz/32/2986_2.png) [@alebherz](https://precice.discourse.group/u/alebherz)\
**Post date:** [December 1, 2025, 12:17pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/1 "2025-12-01T12:17:03Z")

</div>

Hello preCICE-community!

I am working on coupling our inhouse particle solver (XPS) with OpenFOAM using volumetric coupling. I use the OpenFOAM adapter with openmpi (4 ranks) and domain decomposition on the fluid side - and a single CPU thread + CUDA kernels on the DEM side. I am currently facing a situation that I don’t know how to handle - therefore coming to you to ask for advice.

My config currently (momentum coupling) looks something like this

 ![config](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/8/8555a250647a5a6626f212976ef4f13025d32662.png)  
[precice-config.xml](https://precice.discourse.group/uploads/short-url/83eUUlcWhfKhcID6pTq9Z7opQ0c.xml) (4.3 KB)

As you can see, the number of variables I send are limited and the case I am currently working on is also not large. I am using the same mesh dimensions on both sides (174.000 3D-cells). A DEM timestep is 1e-05s, the fluid-timestep a couplingStep are both 1e-3s. I exchange the following quantities

```xml
  <data:vector name="Velocity" />
  <data:vector name="PressureGradient" />
  <data:vector name="ViscousForce" />
  <data:scalar name="FluidDensity" />
  <data:scalar name="FluidViscosity" />

  <data:vector name="MomentumSource" />
  <data:vector name="ParticleVelocity" />
  <data:scalar name="VoidFraction" />

```

making 5 vectors and 3 scalars. Per coupling timestep that is

```
174.000cells * 8Byte = 1.32MB per scalar
174.000cells * 8Byte * 3 = 3.98MB per vector

```

making in total less than 24MB per coupling-timestep.

According to my trace (that i recorded using the precice-tool) the reading of a single scalar (on 174.000 cells) takes ~33ms, a single vector (on 174.000 cells) takes ~35ms.

 ![grafik](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/6/640dd2c28fbfa9a9008556291561b4e566c884ca.png)

Nearest neighour mapping should be trivial but takes also 33-39ms depending on constraint and data-type (scalar or vector).

 ![grafik](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/f/fdf64751062d5fe225f1cfe0b369292a499086d9.png)

The marked area in the perfetto plot corresponds to about 1 coupling interval. Top solver is the DEM solver with 100 timesteps and bottom is the MPI FluidSolver with 1 timestep.

 ![grafik](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/e/ed9bf9d812bd55de4d00542a8b83ea8c445a4931.png)

This test was run on a workstation using a AMD Ryzen 9 7900X 12-Core Processor and Nvidia 4060TI GPU.

This times seem a little our of place and would correspond to ~40MB/s. I am asking you what I am doing wrong to receive such a performance. Are these times for reading/writing/mapping somewhat realistic, given the amount of data I am using.

In case this turns out to be the case, I will need to think about improving performance of my setup (introducing mpi to the DEM solver, tuning cell-sizes, data frequency,…).

Thank you very much in advance for reading through my post and helping out.

Best regards, Andreas

---

<div class="post-metadata">

**Author:** ![alebherz](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alebherz/32/2986_2.png) [@alebherz](https://precice.discourse.group/u/alebherz)\
**Post date:** [December 2, 2025, 8:39am UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/2 "2025-12-02T08:39:46Z")

</div>

After reading through this paper: [10.12688/openreseurope.14445.2](https://doi.org/10.12688/openreseurope.14445.2) it seem like the big bottleneck I am facing is the single threaded DEM solver. In this paper you describe the time for nearest-neighbor mapping negligible (Figure 9) and the time for the initial setup inexpensive (\<100ms).

The hardware setup used in this paper consists of “two 3.1GHz Intel Xeon Platinum 8174 (SkyLake) processors with a total of 48 cores and 96GB of system memory per node” and 48 and 96 MPI ranks - so a little bit above my specs 😅

Using 4 MPI ranks for reading consistent data on the FluidSolver already reduces memory access time for my setup by a factor of about 4: ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/4/45afe849c009ebd7e92aaceb571f7fbe1f7b98c8.png)

I will probably continue to implement some memory pipeline for concurrent memory access and transfer and can share my results in this thread if wanted 🙂

If anyone has experience with single-threaded memory access in preCICE or used a similar setup - please feel free to contact me or answer below this post.

Thanks in advance and best regards,  
Andreas

---

<div class="post-metadata">

**Author:** ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)\
**Post date:** [December 2, 2025, 12:21pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/3 "2025-12-02T12:21:44Z")

</div>

Hi, nice to hear from you after the Workshop!

Let’s start with the fundamentals: Which preCICE version are you using are how did you build it?

> [@alebherz](#):
>
> I am using the same mesh dimensions on both sides (174.000 3D-cells).

Are you exchanging data on the cell centers or the cell vertices? How many vertices do you define in preCICE using `setMeshVertices()`?

> [@alebherz](#):
>
> Nearest neighour mapping should be trivial but takes also 33-39ms depending on constraint and data-type (scalar or vector).

Mapping data is essentially sequential write on one block of data and random read on another block of data. This is generally so fast that we consider it to be not worth looking into.  
I once had the idea to add a contiguous mapping, which copies whole blocks, but we didn’t see the need to advance this further as the direct mesh access can be heavily leveraged for this. [Add Contiguous Mapping · Issue #489 · precice/precice · GitHub](https://github.com/precice/precice/issues/489)

That said, I am currently comparing NP performance across versions and tweaked the develop version. I can do the same for NN.

> [@alebherz](#):
>
> The marked area in the perfetto plot corresponds to about 1 coupling interval. Top solver is the DEM solver with 100 timesteps and bottom is the MPI FluidSolver with 1 timestep.

This highlighted section looks very suspicious. It looks like the solver performs very fast time steps followed by a long time step in the end. Here the read and write-data functions blow up the runtime.  
Are you reading and writing data in all time steps of the solver?

 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/f/ff68d63db5f6be3c630ff81537771cf40b88229f.png)

Also note that using `synchronize="True"` in the profiling generally blows up overall time as it introduces many synchronization points/barriers. This is useful to profile runtime inside a singe parallel solver.

> [@alebherz](#):
>
> Are these times for reading/writing/mapping somewhat realistic, given the amount of data I am using.

Reading will not interpolate in your scenario, so it should take as long as writing data.

> [@alebherz](#):
>
> After reading through this paper: [10.12688/openreseurope.14445.2](https://doi.org/10.12688/openreseurope.14445.2) it seem like the big bottleneck I am facing is the single threaded DEM solver. In this paper you describe the time for nearest-neighbor mapping negligible (Figure 9) and the time for the initial setup inexpensive (\<100ms).

The reference paper is getting a bit outdated now. The most up-to-date publication regarding mapping performance is from @DavidSCN[https://epubs.siam.org/doi/pdf/10.1137/24M1663843](https://epubs.siam.org/doi/pdf/10.1137/24M1663843).  
Section 4 contains the experiments with the meshes on page 13 and the runtime comparison in fig 16 on page 21.

> [@alebherz](#):
>
> If anyone has experience with single-threaded memory access in preCICE or used a similar setup - please feel free to contact me or answer below this post.

Do you mean using preCICE in a multithreaded environment?  
preCICE is not thread-safe, if you want to perform thread-local reads and writes to/from preCICE, you need to lock the participant object in some way.  
Thread-safe data access could be an interesting feature, but we haven’t investigated this so far.

Opened [Thread-safe Participant · Issue #2407 · precice/precice · GitHub](https://github.com/precice/precice/issues/2407) regarding this.

Hope that helps!  
Best regards  
Frédéric

---

<div class="post-metadata">

**Author:** ![alebherz](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alebherz/32/2986_2.png) [@alebherz](https://precice.discourse.group/u/alebherz)\
**Post date:** [December 2, 2025, 1:32pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/4 "2025-12-02T13:32:47Z")

</div>

Hi, I was just a little busy but am now full on developing our application using the preCICE-library. And reading the forum-guidelines before making a post could’ve also been nice - Sorry for that! 🙈

> [@fsimonis](#):
>
> Which preCICE version are you using are how did you build it?

I am currently using `origin/release-v3.2.0` that i built from source.

> [@fsimonis](#):
>
> Are you exchanging data on the cell centers or the cell vertices? How many vertices do you define in preCICE using `setMeshVertices()`?

Both (OpenFOAM and DEM side) write data on cell-centers. On the DEM-side we call `participant->setMeshVertices()` two times (extensive, intensive grid) with a `precice::span<precice::VertexID>` that contains 174000 vertices.

> [@fsimonis](#):
>
> I am currently comparing NP performance across versions and tweaked the develop version. I can do the same for NN.

Using NP would probably also be fine for us since adding mesh connectivity would not be a big deal on our side. I can run a benchmark using this mapping scheme instead and post the results here.

> [@fsimonis](#):
>
> Are you reading and writing data in all time steps of the solver?

In the posted test we exchange data once every 100 DEM timesteps. Our DEM and MomentumSolver runs parallel on the GPU and updating all particles takes ~800us per timestep in that case. The last/first timestep is where we read/write data to the FluidSolver via preCICE and for this we need to copy data from VRAM-\>RAM (those should be the small sections between the “readData” and “writeData” blocks.  
DEM has 1e-5s timestep and coupling-TS is 1e-3 in that case.

> [@fsimonis](#):
>
> Reading will not interpolate in your scenario, so it should take as long as writing data.

I am currently not using any interpolation scheme, just nearest neighbor mapping, so yes. I think adding an interpolation scheme will increase mapping-time drastically though.

> [@fsimonis](#):
>
> The reference paper is getting a bit outdated now. The most up-to-date publication regarding mapping performance is from @DavidSCN [https://epubs.siam.org/doi/pdf/10.1137/24M1663843](https://epubs.siam.org/doi/pdf/10.1137/24M1663843).  
> Section 4 contains the experiments with the meshes on page 13 and the runtime comparison in fig 16 on page 21.

Thanks for the paper - I’ll definitely give it a read!

> [@fsimonis](#):
>
> Do you mean using preCICE in a multithreaded environment?

I had some thoughts about this and will try to integrate MPI into our solver to utilize m2n mapping of preCICE. We realized that reading on the Fluid-side with 4 MPI ranks already gives a good boost in performance (basically devides time required for a single readData by MPI\_SIZE). For this we need to develop a memory pipeline, where multiple MPI threads write on the same GPU-buffer on the DEM side.

Using regular threads for this could also be interesting because the problem with MPI will probably be the following for us: When utilizing MPI-threads **only** for read/write and copy between CPU ↔ GPU, all except 1 MPI-thread will be idle for the whole time we “just” calculate DEM-timesteps without exchanging data. I need to mention that I have no prior experience using MPI so this might be not a problem at all.

Thanks for your insights and best regards,  
Andreas

---

<div class="post-metadata">

**Author:** ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)\
**Post date:** [December 2, 2025, 2:30pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/5 "2025-12-02T14:30:16Z")

</div>

> [@alebherz](#):
>
> I am currently using `origin/release-v3.2.0` that i built from source.

In this case, I recommend using a production build using the production preset:

```
cmake --preset=production -DBUILD_TESTING=OFF && make -j 24 -C build

```

The `production-audit` preset enables debug messages and assertions which can be practical when developing.

> [@alebherz](#):
>
> On the DEM-side we call `participant->setMeshVertices()` two times (extensive, intensive grid) with a `precice::span<precice::VertexID>` that contains 174000 vertices.

I would a NN mapping of scalar data to be around 10us for this input size.

> [@alebherz](#):
>
> I had some thoughts about this and will try to integrate MPI into our solver to utilize m2n mapping of preCICE.

Depending on your cluster and amount of work you are willing to invest, a hybrid scheme could also make sense. One MPI process per node and then use multi-threading on it. AFAIK one MPI process per GPU is also a common strategy.  
Note however, that preCICE is single-threaded by design.

---

<div class="post-metadata">

**Author:** ![alebherz](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alebherz/32/2986_2.png) [@alebherz](https://precice.discourse.group/u/alebherz)\
**Post date:** [December 2, 2025, 2:51pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/6 "2025-12-02T14:51:02Z")

</div>

> [@fsimonis](#):
>
> The `production-audit` preset enables debug messages and assertions which can be practical when developing.

Oh thanks, I didn’t know that!

> [@fsimonis](#):
>
> I would a NN mapping of scalar data to be around 10us for this input size.

But then how do you explain the avg. mapping-time of 36ms I get per readData() call such as `map.nn.mapData.FromFluidMeshToDEMGrid_Intensive`? I guess if the actual mapping is not taking long then something must be blocking the thread I am running my DEM solver on.

Because something seems to be seriously off here:  
The average mapping job takes ~268ms for DEM-\>CFD

 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/d/d52f189ae3c23d9f6bd78febe9a394648bcee816.png)

And ~388ms for CFD-\>DEM

 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/d/d603fbd9c835555b211c61dbd57ce4b3e3ae5869.png)

---

<div class="post-metadata">

**Author:** ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)\
**Post date:** [December 2, 2025, 3:12pm UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/7 "2025-12-02T15:12:00Z")

</div>

> [@fsimonis](#):
>
> I would a NN mapping of scalar data to be around 10us for this input size.

I tried your input size, and I am getting around 0.42 ms (median of 44 samples) for mapping a scalar data of size 173889. I’m using GCC 15.2.0 and mold 2.37.1.  
Not as fast as I expected, but dramatically more than in your case.

Furthermore, your CPU runs 4.7GHz base and boosts up to 5.6GHz. My cores are fixed to 4GHz, so your timings should be significantly lower.

> [@alebherz](#):
>
> But then how do you explain the avg. mapping-time of 36ms I get per readData() call such as `map.nn.mapData.FromFluidMeshToDEMGrid_Intensive`?

Can you double-check that preCICE is build in Release mode, ideally with interprocedural optimization/LTO? The production preset enables this.  
Also, what compiler are you using at which version?

---

<div class="post-metadata">

**Author:** ![alebherz](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alebherz/32/2986_2.png) [@alebherz](https://precice.discourse.group/u/alebherz)\
**Post date:** [December 3, 2025, 7:46am UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/8 "2025-12-03T07:46:21Z")

</div>

> [@fsimonis](#):
>
> I tried your input size, and I am getting around 0.42 ms

Thank you for taking the time to benchmark the mapping configuration I am using!

I did now use the `cmake --preset=production` build and this improved the performance of mapping, reading and writing by a factor of ~100. So thank you very much for suggesting that - I was not aware that I was using a debug build until now.

I see now that the [using-presets](https://precice.org/installation-source-configuration.html#using-presets) section in your documentation clearly states to use the production build but I must have overread that when first installing preCICE.

### Benchmarks

| Operation | Scalar | Vector |
| --- | --- | --- |
| **NN Mapping** | ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/b/be55f1532aed290909126ffae1cfdde7484a52be.png) | ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/a/ab14835e562089ab66005296b5323e3477b92576.png) |
| **Reading** | ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/8/810c5f6ed845d2a582770303decf9d0008b502ad.png) | ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/5/546737eda851c4c3e074527d2711849d287a496a.png) |

This breaks down to the following average times:

| operation\_type | avg\_duration\_ms | block\_count |
| --- | --- | --- |
| Mapping | 0.27324313077939233 | 30280 |
| Reading | 0.1969488341968912 | 18528 |
| Writing (Extensive) | 0.507905 | 1000 |
| Writing (Intensive) | 0.34469 | 3000 |

Thank you again very much for taking the time to analyze the problem - I appreciate it very much.

Best regards,  
Andreas

---

<div class="post-metadata">

**Author:** ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)\
**Post date:** [December 3, 2025, 8:24am UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/9 "2025-12-03T08:24:11Z")

</div>

Happy to help!

These times look way more reasonable.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [December 6, 2025, 8:25am UTC](https://precice.discourse.group/t/slow-data-transfer-in-precice-setup/2677/10 "2025-12-06T08:25:08Z")

</div>

Closed on December 6, 2025, 8:25am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
