CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
dataInterface.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <vector>
38
39#include "../../config.h"
40#include "../../misc/macros.hpp"
41#include "../misc/tapeValues.hpp"
42#include "chunk.hpp"
43#include "position.hpp"
44
46namespace codi {
47
148 template<typename T_NestedData = void, typename T_InternalPosHandle = size_t>
150 public:
151
152 using NestedData = T_NestedData;
153 using InternalPosHandle = CODI_DD(T_InternalPosHandle, size_t);
154
156
157#if CODI_IDE
159 DataInterface(size_t chunkSize) {
160 CODI_UNUSED(chunkSize);
161 }
162#endif
163
164 /*******************************************************************************/
166
175 CODI_INLINE void addDataSize(size_t const& size);
176
211 template<typename... Data>
212 CODI_INLINE void getDataPointers(Data*&... pointers);
213
229 template<typename... Data>
230 CODI_INLINE void pushData(Data const&... data);
231
239
240 /*******************************************************************************/
242
243 void resize(size_t const& totalSize);
245 void reset();
246 void resetHard();
248 void resetTo(Position const& pos);
253 void erase(Position const& start, Position const& end, bool recursive = true);
254
255 /*******************************************************************************/
257
258 CODI_INLINE size_t getDataSize() const;
267 /*******************************************************************************/
269
274 void addToTapeValues(TapeValues& values) const;
275
283 template<typename TargetPosition>
284 CODI_INLINE TargetPosition extractPosition(Position const& pos) const;
285
288 void swap(DataInterface& other);
290 /*******************************************************************************/
292
325 template<int selectedDepth = -1, typename FunctionObject, typename... Args>
326 CODI_INLINE void evaluateForward(Position const& start, Position const& end, FunctionObject function,
327 Args&&... args);
328
346 template<int selectedDepth = -1, typename FunctionObject, typename... Args>
347 CODI_INLINE void evaluateReverse(Position const& start, Position const& end, FunctionObject function,
348 Args&&... args);
349
367 template<typename FunctionObject, typename... Args>
368 CODI_INLINE void forEachChunk(FunctionObject& function, bool recursive, Args&&... args);
369
388 template<typename FunctionObject, typename... Args>
389 CODI_INLINE void forEachForward(Position const& start, Position const& end, FunctionObject function,
390 Args&&... args);
391
407 template<typename FunctionObject, typename... Args>
408 CODI_INLINE void forEachReverse(Position const& start, Position const& end, FunctionObject function,
409 Args&&... args);
410 };
411}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
void erase(Position const &start, Position const &end, bool recursive=true)
void addDataSize(size_t const &size)
Add this many items to the data stream, after the data has been manipulated via pointers obtained fro...
size_t getPushedDataCount(InternalPosHandle const &startPos)
Position getZeroPosition() const
void getDataPointers(Data *&... pointers)
Get pointers to the data from the storage implementation. The method can only be called after a call ...
void resetTo(Position const &pos)
void setNested(NestedData *v)
InternalPosHandle reserveItems(size_t const &items)
Reserve this many items on the data stream. See pushData for details.
void pushData(Data const &... data)
Add data to the storage allocated by the implementation. The method can only be called after a call t...
void swap(DataInterface &other)
void forEachForward(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Calls the function object for each item in the data stream. This call is not recursive.
void evaluateReverse(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Evaluates the function object with segments of continuous and valid data for all nested DataInterface...
void evaluateForward(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Evaluates the function object with segments of continuous and valid data for all nested DataInterface...
TargetPosition extractPosition(Position const &pos) const
Extract the position of a nested DataInterface from the global position object provide by this interf...
void forEachChunk(FunctionObject &function, bool recursive, Args &&... args)
Calls the function object for each continuous segment of data.
void resize(size_t const &totalSize)
T_InternalPosHandle InternalPosHandle
See DataInterface.
Definition dataInterface.hpp:153
Position getPosition() const
void forEachReverse(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Calls the function object for each item in the data stream. This call is not recursive.
void addToTapeValues(TapeValues &values) const
Add amount of stored data to the TapeValues object. Not called on the nested vector.
size_t getDataSize() const
T_NestedData NestedData
See DataInterface.
Definition dataInterface.hpp:152
Empty Position with no nested data.
Definition position.hpp:47
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73