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

removed code fragments for precompiled template code

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: 3340
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f6868d6f
......@@ -46,6 +46,7 @@
# and f2c (not yet with gfortran)
# 17/08/2010 V1.6 prepare for new environment settings
# 18/09/2010 V1.7 TF_WWWBASEDIR and TF_REMCMMNT must be used
# 10/11/2010 V1.8 removed fragments for binarry
#
# ============================================================================
#
......@@ -132,10 +133,6 @@ CXXFLAGS+=-Wall $(FLAGS) -O3
LDFLAGS+=-L$(LOCLIBDIR)
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS)
# the following definition is needed to make the dependency command pass
# binarray.cc
TMPPARDEF=-D BIN_TYPE -D BIN_N -D BIN_REPR -D BIN_SUBS
#======================================================================
# targets
# -------
......@@ -168,69 +165,6 @@ clean: ;
# library part
# ============
#
# These are code fragments from libcontxx. They are the framework for
# generating a binary library with preinstantiated template code.
# Until we make full use of this feature, the fragments are just waiting here.
#
# basic set of patterns - containing all dimensionalities
LIBPATBASIC=_TYPE_1_REPR_SUBS_ \
_TYPE_2_REPR_SUBS_ \
_TYPE_3_REPR_SUBS_ \
_TYPE_4_REPR_SUBS_ \
_TYPE_5_REPR_SUBS_
#
# all element type
LIBPATTYPE=$(patsubst _TYPE_%,_float_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_double_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_int_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_zdouble_%,$(LIBPATBASIC)) \
$(patsubst _TYPE_%,_cfloat_%,$(LIBPATBASIC))
#
# add const element types
LIBPATCTYPE=$(LIBPATTYPE) $(patsubst _%,_C%,$(LIBPATTYPE))
#
# add representations
LIBPATREPR=$(patsubst %_REPR_SUBS_,%_sheap_SUBS_,$(LIBPATCTYPE))
#
# add shapes
LIBPATSUBS=$(patsubst %_SUBS_,%_srep,$(LIBPATREPR)) \
$(patsubst %_SUBS_,%_dsrep,$(LIBPATREPR))
#
# create object file patterns
LIBPATFILES=$(addprefix binarray,$(LIBPATSUBS))
ALLOBS=$(addsuffix .o,$(LIBPATFILES))
# macro definitions
macro_float.xxx: ; echo "-D BIN_TYPE=float" > $@
macro_double.xxx: ; echo "-D BIN_TYPE=double" > $@
macro_int.xxx: ; echo "-D BIN_TYPE=int" > $@
macro_zdouble.xxx: ; echo "-D BIN_TYPE=\"std::complex<double>\"" > $@
macro_cfloat.xxx: ; echo "-D BIN_TYPE=\"std::complex<float>\"" > $@
macro_Cfloat.xxx: ; echo "-D BIN_TYPE=\"const float\"" > $@
macro_Cdouble.xxx: ; echo "-D BIN_TYPE=\"const double\"" > $@
macro_Cint.xxx: ; echo "-D BIN_TYPE=\"const int\"" > $@
macro_Czdouble.xxx: ; echo "-D BIN_TYPE=\"const std::complex<double>\"" > $@
macro_Ccfloat.xxx: ; echo "-D BIN_TYPE=\"const std::complex<float>\"" > $@
macro_%_1.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=1" >> $@
macro_%_2.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=2" >> $@
macro_%_3.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=3" >> $@
macro_%_4.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=4" >> $@
macro_%_5.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=5" >> $@
macro_%_sheap.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_REPR=contxx::prebuilt::representation::SharedHeap" >> $@
macro_%_srep.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::StridedRepresentation" >> $@
macro_%_dsrep.xxx: macro_%.xxx
cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::DenseStridedRepresentation" >> $@
binarray%.o: binarray.cc macro%.xxx
/bin/cat $(word 2,$^)
$(CXX) -o $@ -c $< $(CPPFLAGS) $(CXXFLAGS) $(shell /bin/cat $(word 2,$^))
#----------------------------------------------------------------------
# create the binary library
# -------------------------
LIBOBS=$(ALLOBS) $(patsubst %.cc,%.o,$(SRC))
......@@ -239,7 +173,7 @@ LIBOBS=$(patsubst %.cc,%.o,$(SRC))
libaff.a: $(INSTHEADER) $(LIBOBS)
ar rcv $@ $(LIBOBS)
ranlib $@
cp -vpf $@ $(LIBINSTALLPATH)
/bin/mv -vf $@ $(LIBINSTALLPATH)
#======================================================================
# dependencies
......@@ -253,9 +187,6 @@ libaff.a: $(INSTHEADER) $(LIBOBS)
> $@; \
[ -s $@ ] || rm -f $@'
binarray_%.d: binarray.cc
echo $(patsubst %.d,%.o,$@) $@: $< > $@
-include $(patsubst %.cc,%.d,$(SRC))
# this include will be used once we initiate the precompiled library version
......
......@@ -47,6 +47,9 @@
* - added section about decision against interface
* base classes
* (\ref sec_design_interface_nobaseclass)
* - 10/11/2010 V1.6 (thof)
* - code fragments for precompiled templates are
* removed from the library (\ref sec_design_binary)
*
* ============================================================================
*/
......@@ -57,8 +60,6 @@
(see \ref sec_main_modules).
Here you should find all components, the user needs to work with this
library.
When working with the binary version of the library, you have to use
aff::prebuilt in place of aff (see \ref sec_design_binary).
*/
namespace aff {
} // namespace aff
......@@ -108,8 +109,7 @@ $Id$
The main module is the array class aff::Array. It provides basic
functionality through its interface. See the explanation there.
It is presented in aff/array.h and aff/binarray.h (see also
\ref sec_design_binary).
It is presented in aff/array.h
The object code is placed in libaff.a.
\subsection sec_main_modules_basic Basic array modules
......@@ -167,9 +167,6 @@ $Id$
debugging your code. See also \ref group_helpers.
In the \ref sec_design_binary "binary version" some of the modules
(aff::Array and aff::SharedHeap) are presented in namespace aff::prebuilt.
\sa \ref sec_design_namespaces
\sa \ref sec_naming_files
......@@ -632,36 +629,10 @@ See also \ref sec_design_multidimensional.
<HR>
\section sec_design_binary Binary library
We provide a binary version of the library. It contains a set of prebuilt
class objects. Using this version and linking against the binary library
libaff.a should reduce compilation times in comparison to complete
template evaluation.
This will become more significant the more code is factored out to separate
definition headers.
This approach offers no improvement with inlined code (which we use
extensively in array access functions).
To use the binary version you should include binarry.h in place of array.h
You will find modules aff::Array and aff::SharedHeap
in aff::prebuilt that are in aff in the full-template version.
\sa tests/binarraytest.cc
\sa binarray.h
The inclusion of header files is controlled by a set of preprocessor macros.
\sa AFF_PREBUILT
\sa AFF_INDEXCHECK
\sa AFF_NO_DEFINITIONS
\sa AFF_COMPILING_LIBRARY
\sa DOXYGEN_MUST_SKIP_THIS
\note
Since we reduced the number of template parameters significantly in this
approach, many parts of code have already been factored out to separate files
that are compiled into the binary libaff.a. The approach of explicitly
instantiated class templates is not supported so far. It is, however, prepared
in the structure of header files and may be activated in the future.
\date 20/12/2002
The option to provide precompiled templates is finally removed from the
library.
\date 10/11/2010
<HR>
\section sec_design_multidimensional Multidimensional arrays
......
......@@ -27,6 +27,10 @@
Major changes in the interface of the library are marked by \b !!.
- 10/11/2010 (thof)
- removed code fragments for precompiled templates
- joined array_dec.h and array_def.h in array.h
- \b 11/12/2007 (thof)
- the library compiles well on a 64bit system (Fenoglio)
- test programs (including g77 and f2c version of f77test) compile well
......@@ -278,19 +282,9 @@
<TR><TD>libaff/array.h</TD>
<TD>8/12/02</TD><TD>20/12/02</TD><TD>19/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/array_dec.h</TD>
<TD>19/12/2002</TD><TD>28/12/2002</TD><TD>19/12/2002</TD>
<TD> </TD>
</TR>
<TR><TD>libaff/array_def.h</TD>
<TD>19/12/2002</TD><TD>20/12/2002</TD><TD>19/12/2002</TD><TD> </TD>
</TR>
<TR><TD>libaff/arrayoperators.h</TD>
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/binarray.h</TD>
<TD>8/12/02</TD><TD>20/12/2002</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/dump.cc</TD>
<TD>18/12/2002</TD><TD>20/12/2002</TD><TD>18/12/2002</TD><TD> </TD>
</TR>
......@@ -442,10 +436,6 @@
<TD>19/12/2002</TD><TD> </TD><TD>19/12/2002</TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/binarraytest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/functionstest.cc</TD>
<TD>21/04/2005 </TD><TD>21/04/2005 </TD><TD>21/04/2005 </TD>
<TD>complete as soon as other functions are provided </TD>
......
This diff is collapsed.
/*! \file array_dec.h
* \brief array class declarations (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \since 08/12/2002
*
* array class declarations (prototypes)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
* \note
* This should never be included directly. Use array.h or binarray.h instead.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
* - 16/12/2002 V1.1 (thof)
* - introduced new concept of const-correctness;
* this should work for passing arrays as intrinsic
* references for const element type
* - 17/12/2002 V1.2 (thof)
* - introduced access declarations
* - 19/12/2002 V1.3 (thof)
* - provide read access to base classes
* and read/write access to representation of
* non-const array
* - replaced four size-argument constructors by one
* constructor with default arguments
* - distinguish between mutable and non-mutable
* representation
* - 20/12/2002 V1.4 (thof)
* - Access declarations are nor useable with functions
* that return a reference to *this. They must be
* reimplemented.
* - 23/12/2002 V1.5 (thof)
* - copyin() and copyout() work
* - 28/12/2002 V1.6 (thof)
* - changed base class from specialization to
* independent class template
* - 29/12/2002 V1.7 (thof)
* - ConstArray now inherits from ConstSharedHeap
* (see "\ref sec_design_replicated")
* - use "using" syntax for access declarations
* - arrays do no longer derive from shared heap
* classes
* - reworked shared heap access concept fundamentally;
* code looks much simpler now
* - member template must be defined here
* - factored out copyin code
* - 31/12/2002 V1.8 (thof)
* - Removed non-initializing constructors in
* ConstArray (except default constructor, which is
* needed, when object is a container element) as
* suggested by Wolfgang.
* - 02/01/2003 V1.9 (thof)
* - type TIndexVec was not declared
* - 03/01/2003 V1.10 (thof)
* - copyout function now returns an aff::Array rather
* than an aff::ConstArray
* - aff::Array inherits copyout from aff::ConstArray
* - deepcopy is now in namespace aff
* - 04/07/2005 V1.11 (thof)
* - provide data modification through const Array
* - 05/07/2005 V1.12 (thof)
* - expose const representation too if declared const
* - 19/06/2006 V1.13 (thof)
* - offer Tvalue and friends as non-const types
*
* ============================================================================
*/
// include guard
#ifndef AFF_ARRAY_DEC_H_VERSION
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.13"
#define AFF_ARRAY_DEC_H_CVSID \
"$Id$"
#include <aff/lib/sharedheap.h>
#include <aff/lib/strided.h>
#include <aff/lib/stridedstepper.h>
#include <aff/lib/deepcopy.h>
namespace aff {
#ifdef AFF_PREBUILT
namespace prebuilt {
#endif
// forward declaration
template<class T> class Array;
/*! \brief Array base class
*
* This is a multidimensional (array) container that uses a strided memory
* layout (Fortran shape) and counted references to data in global memory.
* For examples see the various test programs.
*
* \sa \ref sec_design_multidimensional
* \sa \ref sec_design_interface
* \sa \ref sec_design_const
* \sa \ref page_representation
* \sa \ref sec_design_replicated
* \sa aff::Strided
* \sa aff::SharedHeap
* \sa tests/arraytest.cc
* \sa tests/f77test.cc
* \sa tests/helpertest.cc
*/
template<class T>
class ConstArray:
private aff::Strided
{
public:
/*! \name Various types
*
* In particular due to our concept of const-correctness we need
* several typedefs to declare types derived from the element type of
* the array.
*
* This is in particular usefull for function templates that may take
* any container class as argument (e.g. aff::subarray) or for other
* classes dealing with any container (e.g. aff::Iterator).
* By means of these typedefs they may retrieve appropriate types they
* have to deal with.
*
* \sa \ref sec_design_interface_typedef
* \sa \ref sec_design_const
*/
//@{
//! Type of representation
typedef aff::ConstSharedHeap<T> Trepresentation;
//! Type of shape
typedef aff::Strided Tshape;
//! Type of shape stepper
typedef Tshape::Tstepper Tstepper;
//! we use this for one of the access operators
typedef Tshape::TIndexVec TIndexVec;
//! Element type
typedef T Tvalue;
//! Type of pointer to element
typedef T* Tpointer;
//! Type of reference to element
typedef T& Treference;
//! const element type
typedef const T Tconst_value;
//! Type of pointer to const element
typedef const T* Tconst_pointer;
//! Type of reference to const element
typedef const T& Tconst_reference;
//! Type of this array
typedef ConstArray<T> Tcontainer;
//! Type of the array of const values
typedef Tcontainer Tcontainer_of_const;
//! Short for Tcontainer_of_const
typedef Tcontainer Tcoc;
//@}
/*-----------------------------------------------------------------*/
/*! \name Constructors
*
* \note
* We use the default copy constructor, which automatically invokes
* the copy constructors of the base classes aff::Strided and
* aff::SharedHeap<T>. This essentially is a shallow copy of the
* array, i.e. the copy will reference to the same elements in memory.
* See aff::Array<T>::copyin() and aff::Array<T>::copyout() for deep
* copy operations.
*/
//@{
//! construct from nothing (empty)
ConstArray() { }
//! construct from shape and representation
ConstArray(const Tshape& shape,
const Trepresentation& representation):
Tshape(shape), Mrepresentation(representation)
{ check_consistency(); }
//@}
/*-----------------------------------------------------------------*/
/*! \name Const access operators
*
* Although we generally distinguish between the constness of the
* container and the constness of the contained data (see
* \ref sec_design_const), we provide const element access operators
* the prohibit element modification. We assume that a const version
* of the array is usually meant to be used only for reading.
*/
//@{
//! full dimensionality access
const T& operator()(const TIndexVec& index) const
{ return(Mrepresentation[offset(index)]); }
//! access from 1 index value
const T& operator()(const Tsubscript& i0) const
{ return(Mrepresentation[offset(i0)]); }
//! access from 2 index values
const T& operator()(const Tsubscript& i0,
const Tsubscript& i1) const
{ return(Mrepresentation[offset(i0, i1)]); }
//! access from 3 index values
const T& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
{ return(Mrepresentation[offset(i0, i1, i2)]); }
//! access from 4 index values
const T& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
{ return(Mrepresentation[offset(i0, i1, i2, i3)]); }
//@}
/*-----------------------------------------------------------------*/
/*! \name Shape access
*/
//@{
//! 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)); }
//@}
/*! \brief create an identical copy (deep copy) of this array
*
* This is mainly used to create a copy of a truely identical array
* (i.e. array with same element type or at least const version of
* same element type). Use this function in conjunction with the
* assignment operator. E.g.:
* \code
* aff::Array<int> A(3,4);
* A=5.;
* aff::Array<int> B, C;
* B=A.copyout();
* C=A;
* \endcode
* Here arrays \c A and \c B have exactly the same contents but use
* different memory. While changes to elements of \c C will also
* affect elements of \c A, this not the case for changes applied to
* \c B.
*/
Array<T> copyout() const;
//! \name access declarations
//@{
//! access to base class function
using Tshape::first;
using Tshape::last;
using Tshape::size;
//@}
//! provide access to const shape
const Tshape& shape() const { return(*this); }
//! provide restricted access representation
const Trepresentation& representation() const
{ return (Mrepresentation); }
protected:
//! provide access to shape offset functions for derived class
using Tshape::offset;
private:
//! check consitency between representation and shape
void check_consistency() const;
//! representation member
Trepresentation Mrepresentation;
}; // class ConstArray
/*======================================================================*/
/*! \brief Full multi-dimensional array functionality.
*
* This is the full array class template. It adds no additional
* functionality to its base class aff::ConstArray. But it provied acess to
* all member functions of the base, also to functions that allow data
* modification.
*
* \sa aff::ConstArray
* \sa \ref sec_design_const
* \sa \ref sec_design_replicated
*/
template<class T>
class Array:
public ConstArray<T>
{
public:
/*! \name Various types
*
* In particular due to our concept of const-correctness we need
* several typedefs to declare types derived from the element type of
* the array.
*
* \sa \ref sec_design_interface_typedef
* \sa \ref sec_design_const
*/
//@{
//! Type of this array
typedef Array<T> Tcontainer;
//! base is container of const (see specialization below)
typedef aff::ConstArray<T> Tbase;
//! Type of the array of const values
typedef Tbase Tcontainer_of_const;
/*! \brief short for Tcontainer_of_const
*
* We generally distinguish between constness of the array and
* constness of the contained data (see \ref sec_design_const).
* There will be situations, when you want to promise that a function
* will not change the contents of an array. In this case you may use
* a declaration (prototype) like
* \code
* typedef aff::Array<int> Tmyarray;
* void myfunction(const Tmyarray::Tcoc& array);
* \endcode
* and you may use this function like
* \code
* Tmyarray A(6,7);
* A=4;
* myfunction(A);
* \endcode
*
* \sa \ref sec_design_const
*/
typedef Tbase Tcoc;
//! Type of representation
typedef aff::SharedHeap<T> Trepresentation;
//! Type of subscriptor
typedef aff::Strided Tshape;
//! we use this for one of the access operators
typedef Tshape::TIndexVec TIndexVec;
//! Element type
typedef T Tvalue;
//! Type of pointer to element
typedef T* Tpointer;
//! Type of reference to element
typedef T& Treference;
//! const element type
typedef const T Tconst_value;
//! Type of pointer to const element
typedef const T* Tconst_pointer;
//! Type of reference to const element
typedef const T& Tconst_reference;
//@}
/*-----------------------------------------------------------------*/
/*! \name Constructors
*
* \note
* We use the default copy constructor, which automatically invokes
* the copy constructors of the base classes aff::Strided and
* aff::SharedHeap<T>. This essentially is a shallow copy of the
* array, i.e. the copy will reference to the same elements in memory.
* See aff::Array<T>::copyin() and aff::Array<T>::copyout() for deep
* copy operations.
*/
//@{
//! construct from nothing (empty)
Array() { }
//! construct from shape and representation
Array(const Tshape& shape,
const Trepresentation& representation):
Tbase(shape, representation),
Mrepresentation(representation) { }
//! construct from shape (defines size and layout)
explicit Array(const Tshape& shape)
{
Tshape newshape(shape.first(), shape.last());
Mrepresentation=Trepresentation(newshape.memory_size());
this->Tbase::operator=(Tbase(newshape, Mrepresentation));
}
//! construct from dimension sizes
explicit Array(const Tsize& s0, const Tsize& s1=1,
const Tsize& s2=1, const Tsize& s3=1)
{
Tshape newshape(s0, s1, s2, s3);
Mrepresentation=Trepresentation(newshape.memory_size());
this->Tbase::operator=(Tbase(newshape, Mrepresentation));
}
//@}
/*---------------