source: trunk/ADOL-C/src/buffer_temp.h @ 600

Last change on this file since 600 was 600, checked in by kulshres, 5 years ago

Merge branch 'master' of 'gitclone' into svn

The following commits have been merged:

commit 8d787974fa72e789c4d478a8ec949fcf49949928
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 20:20:51 2015 +0100

we have res in the counter, so use res as the index too!!!

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 47fb5bb3416a4ba87f856a615dc015927c39b1d3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 16:41:59 2015 +0100

implement reverse mode for ext_diff_fct_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 693d456e0104684c03378d691e536c7f46aebee7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 16:41:34 2015 +0100

deallocate memory

since we're allocating it before.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b8761a69fde8f4884ffae190f9c34fd66cb5b8e4
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 23:40:11 2015 +0100

implement forward mode of ext_diff_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit a7b0357c37c6af72e6ed5e1f01216664a00c79b3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 20:35:50 2015 +0100

Use the integer parameters in the implementation

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e73d6ddc43945465b6b98a9b8e3083ea43bcde6e
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 20:32:00 2015 +0100

add handling of integer parameters by default

if the user has no interger parameters they can pass
iArrLen = 0 and iArr= NULL to call_ext_fct, and we take
care of it in the implementation, but the signatures all
have them in it.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 903ebee5f44066169d8a37f37a93100ceeea9696
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 19:57:31 2015 +0100

implement call_ext_fct for ext_diff_fct_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b7af35c5ad4851c52475282fc48cbed8c18e1cc9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:19:04 2015 +0100

fix typo in filename

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ed5959bf299b75638ba860490aaecf8ca8f59d08
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:18:04 2015 +0100

add a dummy pointer in CpInfos?

otherwise the buffer_temp complains.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit eaee23bf630f9f9c58fb03941d330938ede262ac
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:14:44 2015 +0100

add guards for c++

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6f53952b6d7b00e2f7e83de2e43000f84e2f738b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:13:04 2015 +0100

Add a stub function to make everything compile

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ec4232d70e86891fb8a2423dcd5382d7b84a6bbe
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:50:54 2015 +0100

initial implemenatation for ext_diff_fct_v2

registration and memory allocation done.

remaining: call_ext_fct and forward/reverse implementation

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 1183a77c1cf44c8282632dc329cc6f857963a674
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:47:12 2015 +0100

add a null-pointer initialization in buffer_temp.h

because this is checked in edf_zero

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6849df4942652d2f7b37b6dfcf1c4aac7d9a9099
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:43:32 2015 +0100

make populate_dpp() non static, add zeroing of memory

also correct check in edf_zero

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e10962716558f04f69f0653b183903dadb26ddb9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:41:28 2015 +0100

correct dimension information

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d92f00358f4edc2d0914d88af6e07e59223bd740
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 21:48:05 2015 +0100

add header file for the more generic external functions interface

This interface will exist parallel to the previous interface
and might even use some of the existing code.
The main reason for designing this is to lift the limitation
of one contigously allocated adouble input array and one
similar output array. Here we can use several arrays for input
and output.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 10b1e386bb8e561fefb9e1654bf929c42dc107a4
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 21:32:28 2015 +0100

relocate comment about memory in ext_diff_fct

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 97ffe06d9a1f60a54ed9e6188c2d73a74a4f9adf
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 20:20:08 2015 +0100

Fix ext_diff_fct so that users don't do memory allocation

the memory depends on the size of input and output. so it
can change depending on how many of those there are.
make it dependent on max_m, max_n and do deallocation
and allocation within call_ext_fct

if the maximal size is allocated then smaller sizes will
work automatically.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9b501e135cc324d93cd6489bedd4adcc572cde8f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 17:41:03 2015 +0100

use the double *dp_x, *dp_y inside edfct during call_ext_fct()

this removes the need for the user to allocate two more arrays,
which can be avoided, because edfct structures contain lots of memory
anyway

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     struct_buf.h
4 Revision: $Id: buffer_temp.h 600 2015-03-12 21:28:32Z kulshres $
5 Contents: - template class for linked list of Type buffers with constant length
6             per buffer
7           - intended to be used with structs
8 
9 Copyright (c) Andreas Kowarz, Kshitij Kulshreshtha, Jean Utke
10 
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduction, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14   
15----------------------------------------------------------------------------*/
16
17#if !defined(ADOLC_STRUCT_BUF_H)
18#define ADOLC_STRUCT_BUF_H 1
19
20#include <adolc/internal/common.h>
21#include "taping_p.h"
22
23#if defined(__cplusplus)
24/****************************************************************************/
25/*                                                          This is all C++ */
26
27#include <cstdlib>
28
29#define BUFFER Buffer<SubBufferElement, _subBufferSize>
30#define BUFFER_TEMPLATE template<class SubBufferElement, IndexType _subBufferSize>
31
32typedef locint IndexType;
33
34BUFFER_TEMPLATE class Buffer {
35
36    typedef void (*InitFunctionPointer) (SubBufferElement *subBufferElement);
37
38    static void zeroAll(SubBufferElement* subBufferElement);
39
40    typedef struct SubBuffer {
41        SubBufferElement elements[_subBufferSize];
42        struct SubBuffer *nextSubBuffer;
43    }
44    SubBuffer;
45
46public:
47    inline Buffer() {
48        firstSubBuffer = NULL;
49        numEntries = 0;
50        subBufferSize = _subBufferSize;
51        initFunction = zeroAll;
52    }
53    inline Buffer(InitFunctionPointer _initFunction) {
54        firstSubBuffer = NULL;
55        numEntries = 0;
56        subBufferSize = _subBufferSize;
57        initFunction = _initFunction;
58    }
59    inline ~Buffer();
60
61    inline void init(InitFunctionPointer _initFunction) {
62        initFunction = _initFunction;
63    }
64    SubBufferElement *append();
65    SubBufferElement *getElement(IndexType index);
66
67private:
68    SubBuffer *firstSubBuffer;
69    InitFunctionPointer initFunction;
70    IndexType subBufferSize;
71    IndexType numEntries;
72};
73
74BUFFER_TEMPLATE
75void BUFFER::zeroAll(SubBufferElement* subBufferElement) {
76    memset(subBufferElement,0,sizeof(*subBufferElement));
77}
78
79BUFFER_TEMPLATE
80BUFFER::~Buffer() {
81    SubBuffer *tmpSubBuffer = NULL;
82
83    while (firstSubBuffer != NULL) {
84        tmpSubBuffer = firstSubBuffer;
85        firstSubBuffer = firstSubBuffer->nextSubBuffer;
86        delete tmpSubBuffer;
87    }
88}
89
90BUFFER_TEMPLATE
91SubBufferElement *BUFFER::append() {
92    SubBuffer *currentSubBuffer=firstSubBuffer, *previousSubBuffer=NULL;
93    IndexType index, tmp=numEntries;
94
95    while (tmp>=subBufferSize) {
96        previousSubBuffer=currentSubBuffer;
97        currentSubBuffer=currentSubBuffer->nextSubBuffer;
98        tmp-=subBufferSize;
99    }
100    if (currentSubBuffer==NULL) {
101        currentSubBuffer=new SubBuffer;
102        if (firstSubBuffer==NULL) firstSubBuffer=currentSubBuffer;
103        else previousSubBuffer->nextSubBuffer=currentSubBuffer;
104        currentSubBuffer->nextSubBuffer=NULL;
105    }
106    index=tmp;
107
108    currentSubBuffer->elements[index].allmem=NULL;
109    if (initFunction!=NULL)
110        initFunction(&(currentSubBuffer->elements[index]));
111
112    currentSubBuffer->elements[index].index=numEntries;
113    ++numEntries;
114
115    return &currentSubBuffer->elements[index];
116}
117
118BUFFER_TEMPLATE
119SubBufferElement *BUFFER::getElement(IndexType index) {
120    SubBuffer *currentSubBuffer=firstSubBuffer;
121
122    if (index>=numEntries) fail(ADOLC_BUFFER_INDEX_TO_LARGE);
123    while (index>=subBufferSize) {
124        currentSubBuffer=currentSubBuffer->nextSubBuffer;
125        index-=subBufferSize;
126    }
127    return &currentSubBuffer->elements[index];
128}
129
130#endif /* __cplusplus */
131
132#endif /* ADOLC_STRUCT_BUF_H */
133
Note: See TracBrowser for help on using the repository browser.