-
Notifications
You must be signed in to change notification settings - Fork 94
Description
This issue is used for discussing and creation of an FCP as discussed in FMI Design meeting in June2025 (see https://github.com/modelica/fmi-design/blob/master/Meetings/2025/2025-06-02-04-FMI-F2F-Berlin/20250603_FMI_Communication_Performance.pdf).
The idea is to avoid calling fmi3GetXXX() and fmi3SetXXX() functions whenever possible for large structures and read/write them with a single memory copy call, or not copying them at all. This will save either many calls with a single valueReference, or in case of a single call with a list of valueReferences it will save the required loops on both ends to write/read the values.
We need to make the FMU declare which memory areas are such structures and how they are structured.
Sketch of the approach:
- Enable FMU to describe the memory layout for structured variables:
- Terminals would list a number of variables in order of the memory layout
- The referenced variables are known in their size (now we define bitness for integer and float) etc.
- The terminal would receive an attribute to signal what kind of memory access is possible:
- memory is internal to the FMU (requiring at least single copy)
- memory is external to the FMU - the simulator must point the FMU to the memory area to be used for that struct/terminal (potential 0-copy)
- The standard needs to add pointer handling fmi3GetPtr (if memory remains in FMU), fmi3SetPtr (if memory can be outside FMU)
- We need to define synchronisation/access guaranties for ME/CS/SE:
- e.g. for FMU internal memory, the FMU must guarantee that it accesses this memory only during fmi3DoStep (or maybe during fmi3GetXXX ?)
- For FMU external memory...
- We need to define the "serialization" of the memory layout, order being trivial, arrays like in array access serialization, (preferrably) 0 padding, integer and float now having defined number of bytes, mentioning arrays with variable dimensions...
The advantages of this approach:
- If an importer does not support these structs, element-wise fmi3Get/Set is still available
- Element access is available for debugging also
- Incompatible structures can be mapped by the importer with element-to-element copy
- Compatibility of structures is relatively easy to define and check