Commit 56296e94 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding

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: 1189
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 7235169b
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2002-12-10 19:30:06 forbrig Exp $
# $Id: Makefile,v 1.5 2002-12-12 22:08:19 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -51,7 +51,7 @@ HEADERS=$(shell find . -name \*.h)
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=lib/error.cc
SRC=lib/error.cc dump.cc
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $
* $Id: array_dec.h,v 1.4 2002-12-12 22:08:19 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -29,7 +29,7 @@
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.0 "
#define AFF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $"
"$Id: array_dec.h,v 1.4 2002-12-12 22:08:19 forbrig Exp $"
#include <aff/sharedheap.h>
#include <aff/strided.h>
......@@ -41,18 +41,6 @@ namespace aff {
namespace prebuilt {
#endif
#ifdef CONTXX_PREBUILT
using namespace aff::prebuilt::util;
using namespace aff::prebuilt::shape;
using aff::prebuilt::representation::SharedHeap;
using aff::prebuilt::subscriptor::StridedRepresentation;
#else
using namespace aff::util;
using namespace aff::shape;
using aff::representation::SharedHeap;
using aff::subscriptor::StridedRepresentation;
#endif
/*! \brief Full multi-dimensional array functionality.
*
* The array class highly depends on base classes from which inherts most of
......@@ -112,6 +100,8 @@ namespace prebuilt {
typedef Array<T> Tcontainer;
//! Type of the array of const values
typedef Array<Tconst_value> Tcontainer_of_const;
//! short for container of const
typedef Array<Tconst_value> Tcoc;
//! construct from nothing (empty)
Array() { }
......@@ -120,6 +110,69 @@ namespace prebuilt {
const Trepresentation& representation);
//! construct from shape (defines size and layout)
explicit Array(const Tshape& shape);
//! construct from index range limit
explicit Array(const Tsize& s0);
//! construct from index range limits
Array(const Tsize& s0, const Tsize& s1);
//! construct from index range limits
Array(const Tsize& s0, const Tsize& s1, const Tsize& s2);
//! construct from index range limits
Array(const Tsize& s0, const Tsize& s1,
const Tsize& s2, const Tsize& s3);
//! full dimensionality access
Tvalue& operator()(const TIndexVec& index)
{ return(this->Trepresentation::operator[](
this->Tshape::offset(index))); }
//! access from 1 index value
Tvalue& operator()(const Tsubscript& i0)
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0))); }
//! access from 2 index values
Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1)
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1))); }
//! access from 3 index values
Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2)
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1, i2))); }
//! access from 4 index values
Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3)
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1, i2, i3))); }
//! full dimensionality access
const Tvalue& operator()(const TIndexVec& index) const
{ return(this->Trepresentation::operator[](
this->Tshape::offset(index))); }
//! access from 1 index value
const Tvalue& operator()(const Tsubscript& i0) const
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0))); }
//! access from 2 index values
const Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1) const
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1))); }
//! access from 3 index values
const Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1, i2))); }
//! access from 4 index values
const Tvalue& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
{ return(this->Trepresentation::operator[](
this->Tshape::offset(i0, i1, i2, i3))); }
//! conversion to container of const values
operator Tcontainer_of_const() const
......@@ -128,6 +181,13 @@ namespace prebuilt {
return(retval);
}
//! return first index of dimension i
const Tsubscript& f(const Tsubscript& i) const
{ return(this->Tshape::first(i)); }
//! return last index of dimension i
const Tsubscript& l(const Tsubscript& i) const
{ return(this->Tshape::last(i)); }
//! by size we mean the size defined by the shape
Tsize size(const Tsubscript& i) const
{ return(this->Tshape::size(i)); }
......
/*! \file dump.cc
* \brief debug helpers (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: dump.cc,v 1.1 2002-12-12 22:08:20 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
* debug helpers (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 12/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define AFF_DUMP_CC_VERSION \
"AFF_DUMP_CC V1.0 "
#define TF_DUMP_CC_CVSID \
"$Id: dump.cc,v 1.1 2002-12-12 22:08:20 forbrig Exp $"
#include <aff/dump.h>
namespace aff {
#ifdef AFF_PREBUILT
namespace prebuilt {
#endif
#ifdef AFF_PREBUILT
} // namespace prebuilt
#endif
} // namespace aff
/* ----- END OF dump.cc ----- */
/*! \file dump.h
* \brief debug helpers (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.1 2002-12-12 22:08:20 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
* debug helpers (prototypes)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 12/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_DUMP_H_VERSION
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.0 "
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.1 2002-12-12 22:08:20 forbrig Exp $"
#include<iostream>
namespace aff {
#ifdef AFF_PREBUILT
namespace prebuilt {
#endif
/*! \defgroup group_helpers Debug functions
*/
/*! \brief Dump heap contents
*
* \ingroup group_helpers
*/
template<class T>
void dump(const SharedHeap<T>::Tcoc& sharedheap, std::ostream& os=std::cout);
/*! \brief Dump array values
*
* \ingroup group_helpers
*/
template<class T>
void dump(const Array<T>::Tcoc& array, std::ostream& os=std::cout);
/*! \brief Dump array shape information
*
* \ingroup group_helpers
*/
void dump(const Strided& shape, std::ostream& os=std::cout);
/*! \brief Dump array shape mapping
*
* \ingroup group_helpers
*/
void dump_map(const Strided& shape, std::ostream& os=std::cout);
#ifdef AFF_PREBUILT
} // namespace prebuilt
#endif
} // namespace aff
#endif // AFF_DUMP_H_VERSION (includeguard)
/* ----- END OF dump.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap.h,v 1.4 2002-12-10 19:56:02 forbrig Exp $
* $Id: sharedheap.h,v 1.5 2002-12-12 22:08:20 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.4 2002-12-10 19:56:02 forbrig Exp $"
"$Id: sharedheap.h,v 1.5 2002-12-12 22:08:20 forbrig Exp $"
#include<new>
#include<aff/lib/error.h>
......@@ -130,6 +130,8 @@ namespace prebuilt {
typedef typename Qualified<T>::Tconst_value Tconst_value;
//! Type of const version of SharedHeap
typedef SharedHeap<Tconst_value> Tcontainer_of_const;
//! short for container of const
typedef SharedHeap<Tconst_value> Tcoc;
private:
//! Type of SHeap struct to be used in any case
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.h,v 1.4 2002-12-11 20:58:11 forbrig Exp $
* $Id: strided.h,v 1.5 2002-12-12 22:08:20 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -27,6 +27,9 @@
* - does not need to know anything about stepper
* - introduced Mbase (is necessary for new concept of
* multidemensional arrays proposed by wolle)
* - 12/12/2002 V1.2 (thof)
* - basic functionality is complete
* - documentation is still missing
*
* ============================================================================
*/
......@@ -35,9 +38,9 @@
#ifndef AFF_STRIDED_H_VERSION
#define AFF_STRIDED_H_VERSION \
"AFF_STRIDED_H V1.1 "
"AFF_STRIDED_H V1.2"
#define AFF_STRIDED_H_CVSID \
"$Id: strided.h,v 1.4 2002-12-11 20:58:11 forbrig Exp $"
"$Id: strided.h,v 1.5 2002-12-12 22:08:20 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/simplearray.h>
......@@ -107,19 +110,11 @@ namespace prebuilt {
*/
Strided(const TIndexVec& first, const TIndexVec& last,
const Tsubscript& shift=0);
/*! \brief construct do given strides, first index, and size
*
* The parameters set the shape vectors directly. This constructor is
* used mainly together with shapers, slicers and projectors...
/*! \name Access to shape
*
* \param strides vector of strides for each dimension
* \param first vector of first index value in each dimension
* \param size vector of index range size for each dimension
* \param offset defines memory offset value
*/
Strided(const TSizeVec& strides, const TIndexVec& first,
const TSizeVec& size, const Tsubscript& offset);
//@{
//! total size of mapped memory range
Tsize memory_size() const
{ return (offset(Mlast)-offset(Mfirst)+1); }
......@@ -138,34 +133,53 @@ namespace prebuilt {
//! stride of dimension \par i
const Tsize& stride(const Tsubscript& i) const
{ return Mstride[i]; }
//@}
/*! \name Map index values to linear representation range
*
*/
//@{
//! full dimensionality access
inline
Tsubscript offset()(const TIndexVec& index) const
{ return(inner_product(index,Mstride)+Moffset); }
Tsubscript offset()(const TIndexVec& index) const
{ return(inner_product(index,Mstride)+Moffset); }
//! offset from 1 index value
inline
Tsubscript offset()(const Tsubscript& i0) const
{ return(i0*Mstride[0]+Mbase[0]); }
Tsubscript offset()(const Tsubscript& i0) const
{ return(i0*Mstride[0]+Mbase[0]); }
//! offset from 2 index values
inline
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1) const
{ return(i0*Mstride[0]+i1*Mstride[1]+Mbase[1]); }
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1) const
{ return(i0*Mstride[0]+i1*Mstride[1]+Mbase[1]); }
//! offset from 3 index values
inline
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+Mbase[2]); }
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+Mbase[2]); }
//! offset from 4 index values
inline
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+
i3*Mstride[3]+Mbase[3]); }
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+
i3*Mstride[3]+Mbase[3]); }
//@}
/*! \name Support for slices and subarrays
*
*/
//@{
//! subarrays
void shrink(const TIndexVec& last);
//! subarrays
void shrink(const TIndexVec& first, const TIndexVec& last);
//! subarrays
void shrink(const Tdim& i,
const Tsubscript& first, const Tsubscript& last);
//! subarrays
void shrink(const Tdim& i,
const Tsubscript& last);
//! slice
void collapse(const Tdim& i, const Tsubscript& index);
//@}
private:
void calculate_base() const;
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided_def.h,v 1.3 2002-12-11 20:58:11 forbrig Exp $
* $Id: strided_def.h,v 1.4 2002-12-12 22:08:20 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -22,6 +22,8 @@
* - removed template parameter
* - calculates base for index operator of
* each dimensionality
* - 12/12/2002 V1.2 (thof)
* - added shrink and collapse
*
* ============================================================================
*/
......@@ -34,9 +36,11 @@
#ifndef AFF_STRIDED_DEF_H_VERSION
#define AFF_STRIDED_DEF_H_VERSION \
"AFF_STRIDED_DEF_H V1.1 "
"AFF_STRIDED_DEF_H V1.1"
#define AFF_STRIDED_DEF_H_CVSID \
"$Id: strided_def.h,v 1.3 2002-12-11 20:58:11 forbrig Exp $"
"$Id: strided_def.h,v 1.4 2002-12-12 22:08:20 forbrig Exp $"
#include<aff/lib/error.h>
namespace aff {
......@@ -50,9 +54,13 @@ namespace prebuilt {
#endif
#endif
/*----------------------------------------------------------------------*/
//! instantiate static member (otherwise the linker won't find it)
const Tdim Strided::Mmax_dimen;
/*----------------------------------------------------------------------*/
//! construct do given size and first index
Strided::Strided(const TSizeVec& sizes, const Tsubscript& shift)
{
......@@ -64,6 +72,8 @@ namespace prebuilt {
calculate_base();
}
/*----------------------------------------------------------------------*/
//! construct do given first and last index
Strided::Strided(const TIndexVec& first, const TIndexVec& last,
const Tsubscript& shift)
......@@ -81,13 +91,7 @@ namespace prebuilt {
calculate_base();
}
//! construct from full layout information
Strided::Strided(const TSizeVec& strides, const TIndexVec& first,
const TSizeVec& size, const Tsubscript& offset):
Mstrides(strides), Mfirst(first), Msize(size), Mbase(0), Moffset(offset)
{
calculate_base();
}
/*----------------------------------------------------------------------*/
//! construct do given first and last index
void Strided::calculate_base() const
......@@ -99,6 +103,59 @@ namespace prebuilt {
}
}
/*----------------------------------------------------------------------*/
//! subarrays
void Strided::shrink(const TIndexVec& last)
{ this->shrink(Mfirst, last); }
/*----------------------------------------------------------------------*/
//! subarrays
void Strided::shrink(const TIndexVec& first, const TIndexVec& last)
{
for (Tdim i=0; i<Mmax_dimen; i++)
{
this->shrink(i, first[i], last[i]);
}
}
/*----------------------------------------------------------------------*/
//! subarrays
void Strided::shrink(const Tdim& i,
const Tsubscript& first, const Tsubscript& last)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
"ERROR (shrink shape): illegal dimension");
AFF_assert(((Mfirst[i]<=first)&&(first<=last)&&(last<=Mlast[i])),
"ERROR (shrink shape): index range erres");
AFF_abort("not yet implemented");
}
/*----------------------------------------------------------------------*/
//! subarrays
void Strided::shrink(const Tdim& i,
const Tsubscript& last)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
"ERROR (shrink shape): illegal dimension");
this->shrink(i,Mfirst[i],last);
}
/*----------------------------------------------------------------------*/
//! slice
void Strided::collapse(const Tdim& i, const Tsubscript& index)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
"ERROR (collapse shape): illegal dimension");
AFF_assert(((Mfirst[i]<=index)&&(index<=Mlast[i])),
"ERROR (collapse shape): index range erres");
AFF_abort("not yet implemented");
}
#ifdef AFF_PREBUILT
} // namespace prebuilt
#endif
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: shaper.h,v 1.3 2002-12-11 20:57:54 forbrig Exp $
* $Id: shaper.h,v 1.4 2002-12-12 22:08:20 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -15,6 +15,9 @@
* - 08/12/2002 V1.0 copied from libcontxx
* - 11/12/2002 V1.1 rework class (thof)
* - remove template parameters
* - 12/12/2002 V1.2 (thof)
* - has now full functionality
* - documentation ist still missing
*
* ============================================================================
*/
......@@ -23,9 +26,9 @@
#ifndef AFF_SHAPER_H_VERSION
#define AFF_SHAPER_H_VERSION \
"AFF_SHAPER_H V1.1 "
"AFF_SHAPER_H V1.2 "
#define AFF_SHAPER_H_CVSID \
"$Id: shaper.h,v 1.3 2002-12-11 20:57:54 forbrig Exp $"
"$Id: shaper.h,v 1.4 2002-12-12 22:08:20 forbrig Exp $"
#include<aff/lib/strided.h>
#include<aff/lib/error.h>
......@@ -64,26 +67,32 @@ class Shaper
typedef Strided Tshape;
//! First dimension is defined by constructor
Shaper(const Tsubscript& last):
Mfirst(1), Mlast(1), Minterval(1), Mdim(1)
Mfirst(1), Mlast(1), Mmaxlast(1), Mdim(1)
{
AFF_assert((last>=1), "ERROR (shaper): invalid limit");
Mfirst[0]=1;
Mlast[0]=last;
Mmaxlast[0]=last;
}
//! First dimension is defined by constructor
Shaper(const Tsubscript& first, const Tsubscript& last)
Mfirst(1), Mlast(1), Mmaxlast(1), Mdim(1)
{
AFF_assert((last>=first), "ERROR (shaper): invalid index range");
Mfirst[0]=first;
Mlast[0]=last;
Mmaxlast[0]=last;
}
//! First dimension is defined by constructor
Shaper(const Tsubscript& first, const Tsubscript& last,
const Tsize& interval=1):
Mfirst(1), Mlast(1), Minterval(1), Mdim(1)
const Tsubscript& maxlast):
Mfirst(1), Mlast(1), Mmaxlast(1), Mdim(1)
{
This must not compile!
Of what use is the interval?
Is this helpful in constructing layout of external Fortram
arrays?
AFF_assert((last>=first), "ERROR (shaper): invalid index range");
AFF_assert((interval>0), "ERROR (shaper): invalid index interval");
AFF_assert((maxlast>=last), "ERROR (shaper): invalid alloc size");
Mfirst[0]=first;
Mlast[0]=last;
Minterval[0]=interval;
Mmaxlast[0]=maxlast;
}
//! Other dimensions are defined by bracket operator
Shaper& operator() (const Tsubscript& last)
......@@ -99,10 +108,22 @@ class Shaper
Shaper& operator() (const Tsubscript& first, const Tsubscript& last)
{
AFF_assert((last>=first), "ERROR (shaper): invalid index range");
AFF_assert((interval>0), "ERROR (shaper): invalid index interval");
Mfirst[Mdim]=first;
Mlast[Mdim]=last;
Minterval[Mdim]=interval;
Mmaxlast[Mdim]=last;
// foolproof
if (Mdim<(Tshape::Mmax_dimen-1)) Mdim++;