Commit 5c7792ea authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

reprtest works

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1196
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent c3fd4713
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.3 2002-12-15 20:48:01 forbrig Exp $
* $Id: dump.h,v 1.4 2002-12-16 18:02:00 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
......@@ -29,7 +29,7 @@
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.1"
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.3 2002-12-15 20:48:01 forbrig Exp $"
"$Id: dump.h,v 1.4 2002-12-16 18:02:00 forbrig Exp $"
#include<iostream>
......@@ -46,18 +46,18 @@ using std::endl;
*
* \ingroup group_helpers
*/
template<class T>
void dump(const typename aff::SharedHeap<T>::Tcoc& sharedheap,
template<typename T>
void dump(const aff::SharedHeap<T>& sharedheap,
std::ostream& os=std::cout)
{
os << "dump of a SharedHeap object:" << endl;
os << " size: " << sharedheap.size() << endl;
os << " elements:" << endl;
int i=0;
for (int k=0; k<sharedheap.size(); k++)
for (aff::Tsize k=0; k<sharedheap.size(); k++)
{
if (!i) { os << " "; }
os.width(9);
os.width(8);
os << sharedheap[k] << " ";
if (++i>7) { i=0; os << endl; }
}
......@@ -74,7 +74,7 @@ template<class T, int N>
void dump(const SimpleRigidArray<T,N>& array, std::ostream& os=std::cout)
{
int i=0;
for (int k=0; k<int(N); k++)
for (aff::Tsize k=0; k<N; k++)
{
if (!i) { os << " "; }
os.width(9);
......@@ -117,7 +117,7 @@ void dump_map(const Strided& shape, std::ostream& os=std::cout);
*
* \ingroup group_helpers
*/
#define DUMP( A ) std::cout << #A << ":" << endl; aff::dump(A)
#define DUMP( A ) std::cout << "object \"" << #A << "\":" << endl; aff::dump(A)
#endif // AFF_DUMP_H_VERSION (includeguard)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap.h,v 1.7 2002-12-13 23:48:29 forbrig Exp $
* $Id: sharedheap.h,v 1.8 2002-12-16 18:02:01 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -26,7 +26,7 @@
#define AFF_SHAREDHEAP_H_VERSION \
"AFF_SHAREDHEAP_H V1.2 "
#define AFF_SHAREDHEAP_H_CVSID \
"$Id: sharedheap.h,v 1.7 2002-12-13 23:48:29 forbrig Exp $"
"$Id: sharedheap.h,v 1.8 2002-12-16 18:02:01 forbrig Exp $"
#include<new>
#include<aff/lib/error.h>
......@@ -199,7 +199,23 @@ namespace prebuilt {
return(Mheapstruct->Mheap[i]);
}
//! conversion operator
/*! conversion operator
*
* \note
* This conversion operation does not work when passing a reference to
* a function! Declaring a function
* \code
* void func(const aff::SharedHeap<T>::Tcoc& sh);
* \endcode
* is useless. It will not implicitely convert a \c aff::SharedHeap<T>
* to a \c aff::SharedHeap<T>::Tcoc, because they are indipendent
* types which means a temporary object of type
* aff::SharedHeap<T>::Tcoc must be created. This only works with
* \code
* void func(aff::SharedHeap<T>::Tcoc sh);
* \endcode
* which is passing by value.
*/
operator Tcontainer_of_const() const
{
Tcontainer_of_const retval(Mheapstruct);
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: reprtest.cc,v 1.2 2002-12-15 20:57:19 forbrig Exp $
* $Id: reprtest.cc,v 1.3 2002-12-16 18:02:02 forbrig Exp $
* \author Thomas Forbriger
* \date 10/05/2002
*
......@@ -19,7 +19,7 @@
#define AFF_REPRTEST_CC_VERSION \
"AFF_REPRTEST_CC V1.0 "
#define AFF_REPRTEST_CC_CVSID \
"$Id: reprtest.cc,v 1.2 2002-12-15 20:57:19 forbrig Exp $"
"$Id: reprtest.cc,v 1.3 2002-12-16 18:02:02 forbrig Exp $"
#include<aff/array.h>
#include <aff/lib/sharedheap.h>
......@@ -28,47 +28,73 @@
using std::cout;
using std::endl;
//! echo
#define CODE( C ) cout << #C << endl; C
//! print headline
void section(const char* s)
{
cout << endl
<< s << endl;
const char* p=s;
while (*p) {
cout << "-";
++p;
}
cout << endl;
}
//! testing SharedHeap
int main()
{
cout << AFF_REPRTEST_CC_VERSION << endl;
cout << AFF_REPRTEST_CC_CVSID << endl;
const int N=10;
const int N2=23;
aff::SharedHeap<int> A(N);
aff::SharedHeap<int> B(N2);
aff::SharedHeap<const int> C(N2);
C=B;
aff::SharedHeap<float> D(N2);
section("array dimensions");
CODE( const int N=10; )
CODE( const int N2=23; )
for (int i=0; i<N; i++) { A[i]=(i+1)*10; }
for (int i=0; i<N2; i++) { B[i]=(i+4)*3; }
for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; }
section("instantiate arrays");
CODE( aff::SharedHeap<int> A(N); )
CODE( aff::SharedHeap<int> B(N2); )
CODE( aff::SharedHeap<const int> C(N2); )
CODE( aff::SharedHeap<float> D(N2); )
aff::SharedHeap<float>::Tcoc E(D);
section("create a const reference to D");
CODE( aff::SharedHeap<float>::Tcoc E(D); )
section("const int array should share memory with int array");
CODE( C=B; )
section("fill arrays");
CODE( for (int i=0; i<N; i++) { A[i]=(i+1)*10; } )
CODE( for (int i=0; i<N2; i++) { B[i]=(i+4)*3; } )
CODE( for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; } )
section("dump contents - C is filled through B and E is filled through D");
DUMP( aff::SharedHeap<int>::Tcontainer_of_const(A) );
DUMP( B );
DUMP( C );
DUMP( E );
section("modify C through B");
CODE( B[8]=632; )
DUMP( C );
DUMP(A)
DUMP(B)
DUMP(C)
DUMP(E)
// modify C through B
B[8]=632;
DUMP(C)
// modify C directly - is illegal
#ifdef ILLEGAL1
// you may activate this section by passing -DILLEGAL1 to the compiler
section("modify C directly - is illegal");
C[9]=354;
DUMP(C)
DUMP( C );
#endif
// make B a reference to A
B=A;
// modification should be visible through B
A[5]=453;
DUMP(B)
// test another type
DUMP(D)
cout << endl;
section("make B a reference to A");
CODE( B=A; )
section("modification should be visible through B");
CODE( A[5]=453; )
DUMP( B );
section("but C holds the original values");
DUMP( C );
}
/* ----- END OF reprtest.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: simplearraytest.cc,v 1.3 2002-12-15 20:48:02 forbrig Exp $
* $Id: simplearraytest.cc,v 1.4 2002-12-16 18:02:02 forbrig Exp $
* \author Thomas Forbriger
* \date 25/05/2002
*
......@@ -22,7 +22,7 @@
#define AFF_SIMPLEARRAYTEST_CC_VERSION \
"AFF_SIMPLEARRAYTEST_CC V1.3"
#define AFF_SIMPLEARRAYTEST_CC_CVSID \
"$Id: simplearraytest.cc,v 1.3 2002-12-15 20:48:02 forbrig Exp $"
"$Id: simplearraytest.cc,v 1.4 2002-12-16 18:02:02 forbrig Exp $"
/*! \example tests/simplearraytest.cc
*
......@@ -145,7 +145,7 @@ int main()
SimpleRigidArray<int, 4> B;
cout << "SimpleRigidArray<int, 4> B;" << endl;
SimpleRigidArray<float, 4> C;
cout << "SimpleRigidArray<cloat, 4> C;" << endl;
cout << "SimpleRigidArray<float, 4> C;" << endl;
CODE( A[0]=2; A[1]=3; A[2]=4; A[3]=5; )
CODE( B[0]=1; B[1]=3; B[2]=5; B[3]=7; )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment