Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58239 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates templates/level3
From: rutger_at_[hidden]
Date: 2009-12-08 14:34:17


Author: rutger
Date: 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
New Revision: 58239
URL: http://svn.boost.org/trac/boost/changeset/58239

Log:
Sync of work on numeric_bindings

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 18 +++++++++----
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 50 +++++++++++++++++++++++++++------------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp | 31 +++++++++++++++++++-----
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level3/gemm.hpp | 4 +++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_blas.hpp | 1
   5 files changed, 74 insertions(+), 30 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
@@ -49,15 +49,20 @@
 
     filename = group_name.lower() + '.hpp'
     includes = [
- '#include <boost/numeric/bindings/traits/traits.hpp>',
- '#include <boost/numeric/bindings/traits/type_traits.hpp>',
+ #'#include <boost/numeric/bindings/detail/void_ptr.hpp>',
+ #'#include <boost/numeric/bindings/traits/traits.hpp>',
+ #'#include <boost/numeric/bindings/traits/type_traits.hpp>',
       '#include <boost/numeric/bindings/remove_imaginary.hpp>',
       '#include <boost/numeric/bindings/is_mutable.hpp>',
       '#include <boost/numeric/bindings/value.hpp>',
- '#include <boost/mpl/bool.hpp>',
+ '#include <boost/numeric/bindings/stride.hpp>',
+ '#include <boost/numeric/bindings/size.hpp>',
+ #'#include <boost/mpl/bool.hpp>',
       '#include <boost/type_traits/is_same.hpp>',
       '#include <boost/type_traits/remove_const.hpp>',
- '#include <boost/static_assert.hpp>' ]
+ '#include <boost/static_assert.hpp>',
+ '#include <boost/assert.hpp>',
+ ]
       
     if template_map.has_key( group_name.lower() + '.includes' ):
       includes += template_map[ group_name.lower() + '.includes' ].splitlines()
@@ -87,6 +92,7 @@
       sub_template = sub_template.replace( "$CALL_BLAS_HEADER", ", ".join( lapack_arg_list ) )
       sub_template = sub_template.replace( "$CALL_CBLAS_HEADER", ", ".join( cblas_arg_list ) )
       sub_template = sub_template.replace( "$SUBROUTINE", subroutine )
+ sub_template = sub_template.replace( "$SPECIALIZATION", documentation.routine_value_type[ subroutine[0] ] )
 
       # CBLAS stuff
       if 'cblas_routine' in info_map[ subroutine ]:
@@ -220,7 +226,7 @@
       for level2_idx in range( 0, len( level2_arg_lists ) ):
         level2_function = level2_template.replace( "$LEVEL2", \
                 ", ".join( level2_arg_lists[ level2_idx ] ) )
- if len( level2_static_asserts ) > 0:
+ if len( "".join(level2_static_asserts[ level2_idx ] ) ) > 0:
           level2_function = level2_function.replace( "$STATIC_ASSERTS", \
                 "\n ".join( level2_static_asserts[ level2_idx ] ) )
         level2_functions.append( level2_function )
@@ -240,7 +246,7 @@
       level2_template = level2_template.replace( "$CALL_LEVEL1", ", ".join( call_level1_arg_list ) )
       level2_template = level2_template.replace( "$TYPES", ", ".join( level1_type_arg_list ) )
       level2_template = level2_template.replace( '$RETURN_STATEMENT', info_map[ subroutine ][ 'return_statement' ] )
- level2_template = level2_template.replace( '\n $STATIC_ASSERTS', '' )
+ level2_template = level2_template.replace( ' $STATIC_ASSERTS\n', '' )
 
       level1_map[ value_type ] = bindings.proper_indent( level1_template )
       level2_map[ value_type ] = bindings.proper_indent( level2_template )

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
@@ -14,11 +14,18 @@
 # for debugging purposes
 import pprint
 
+fortran_integer_type = 'std::ptrdiff_t'
+
+complex_float_type = 'std::complex<float>'
+complex_double_type = 'std::complex<double>'
+
+fortran_complex_float_ptr = 'void' # was fcomplex_t
+fortran_complex_double_ptr = 'void' # was dcomplex_t
 
 global_type_map = {
   'CHARACTER': 'char',
   'LOGICAL': 'logical_t',
- 'INTEGER': 'integer_t',
+ 'INTEGER': fortran_integer_type,
   'REAL': 'float',
   'DOUBLE PRECISION': 'double' }
 
@@ -37,16 +44,16 @@
 
 def value_type( fortran_type ):
   m_type_map = global_type_map
- m_type_map[ 'COMPLEX' ] = 'fcomplex_t'
- m_type_map[ 'COMPLEX*16' ] = 'dcomplex_t'
- m_type_map[ 'DOUBLE COMPLEX' ] = 'dcomplex_t'
+ m_type_map[ 'COMPLEX' ] = fortran_complex_float_ptr
+ m_type_map[ 'COMPLEX*16' ] = fortran_complex_double_ptr
+ m_type_map[ 'DOUBLE COMPLEX' ] = fortran_complex_double_ptr
   return m_type_map[ fortran_type ]
   
 def c_type( name, properties ):
   m_type_map = global_type_map
- m_type_map[ 'COMPLEX' ] = 'fcomplex_t'
- m_type_map[ 'COMPLEX*16' ] = 'dcomplex_t'
- m_type_map[ 'DOUBLE COMPLEX' ] = 'dcomplex_t'
+ m_type_map[ 'COMPLEX' ] = fortran_complex_float_ptr
+ m_type_map[ 'COMPLEX*16' ] = fortran_complex_double_ptr
+ m_type_map[ 'DOUBLE COMPLEX' ] = fortran_complex_double_ptr
 
   result = m_type_map[ properties[ 'value_type' ] ];
   if properties[ 'io' ] == [ 'input' ]:
@@ -59,9 +66,10 @@
   
 def cpp_type( name, properties ):
   m_type_map = global_type_map
- m_type_map[ 'COMPLEX' ] = 'traits::complex_f'
- m_type_map[ 'COMPLEX*16' ] = 'traits::complex_d'
- m_type_map[ 'DOUBLE COMPLEX' ] = 'traits::complex_d'
+
+ m_type_map[ 'COMPLEX' ] = complex_float_type
+ m_type_map[ 'COMPLEX*16' ] = complex_double_type
+ m_type_map[ 'DOUBLE COMPLEX' ] = complex_double_type
   
   result = m_type_map[ properties[ 'value_type' ] ]
   
@@ -87,13 +95,17 @@
   if properties[ 'type' ] == 'vector' or properties[ 'type' ] == 'matrix':
     if properties[ 'value_type' ][ 0:7] == 'COMPLEX' or \
        properties[ 'value_type' ] == 'DOUBLE COMPLEX':
- result = 'detail::complex_ptr(' + name.lower() + ')'
+ #result = 'detail::complex_ptr(' + name.lower() + ')'
+ #result = 'bindings::detail::void_ptr(' + name.lower() + ')'
+ result = '' + name.lower() + ''
     else:
       result = name.lower()
   elif properties[ 'type' ] == 'scalar':
     if properties[ 'value_type' ][ 0:7] == 'COMPLEX' or \
        properties[ 'value_type' ] == 'DOUBLE COMPLEX':
- result = 'detail::complex_ptr(&' + name.lower() + ')'
+ #result = 'detail::complex_ptr(&' + name.lower() + ')'
+ result = '&' + name.lower() + ''
+ #result = 'bindings::detail::void_ptr(&' + name.lower() + ')'
     else:
       result = '&' + name.lower()
   
@@ -161,8 +173,8 @@
         result = result.replace( "double", "real_type" )
       if properties[ 'value_type' ][ 0:7] == 'COMPLEX' or \
         properties[ 'value_type' ] == 'DOUBLE COMPLEX':
- result = result.replace( "traits::complex_d", "value_type" )
- result = result.replace( "traits::complex_f", "value_type" )
+ result = result.replace( complex_float_type, "value_type" )
+ result = result.replace( complex_double_type, "value_type" )
 
   return result
 
@@ -366,7 +378,7 @@
   result = None
   if 'workspace' in properties[ 'io' ]:
     if properties[ 'value_type' ] == 'INTEGER':
- result = 'integer_t'
+ result = fortran_integer_type
     elif properties[ 'value_type' ] == 'LOGICAL':
       result = 'bool'
     elif properties[ 'value_type' ] == 'REAL' or properties[ 'value_type' ] == 'DOUBLE PRECISION':
@@ -1140,10 +1152,10 @@
       # Uplo character detection
       if argument_name == 'UPLO':
         # see if the traits are overruled through the template system
+ # the trait_of key will be added below
         traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + argument_name + '.trait_of'
         if my_has_key( traits_key, template_map ):
           argument_properties[ 'trait_type' ] = 'uplo'
- argument_properties[ 'trait_of' ] = template_map[ my_has_key( traits_key, template_map ) ].strip()
         
         else:
           match_uplo = re.compile( '([Uu]pper|[Ll]ower)(or|triangular|triangle|triangles|part|of|the|band|hermitian|symmetric|input|matrix|\s)+([A-Z]+)', re.M ).findall( comment_block )
@@ -1164,6 +1176,12 @@
         argument_properties[ 'trait_type' ] = 'trans'
         argument_properties[ 'trait_of' ] = 'A'
 
+ # check for existance of trait_of definition in template file(s)
+ traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + argument_name + '.trait_of'
+ if my_has_key( traits_key, template_map ):
+ argument_properties[ 'trait_of' ] = template_map[ my_has_key( traits_key, template_map ) ].strip()
+
+
     #
     # Minimal workspace dimension recognition
     #

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
@@ -31,15 +31,24 @@
 namespace bindings {
 namespace blas {
 
-// The detail namespace is used for overloads on value type,
-// and to dispatch to the right routine
-
+//
+// The detail namespace contains value-type-overloaded functions that
+// dispatch to the appropriate back-end BLAS routine.
+//
 namespace detail {
 
 $OVERLOADS
 } // namespace detail
 
 $LEVEL1
+
+//
+// Functions for direct use. These functions are overloaded for temporaries,
+// so that wrapped types can still be passed and used for write-access.
+// In the documentation the const-overloads are collapsed. Consult the
+// static assert lists (if available) to check what kind of overload it is.
+//
+
 $LEVEL2
 } // namespace blas
 } // namespace bindings
@@ -48,6 +57,9 @@
 
 #endif
 $TEMPLATE[blas_overloads]
+//
+// Overloaded function for the $SPECIALIZATION value type.
+//
 inline $RETURN_TYPE $groupname( $LEVEL0 ) {
 #if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS
     $RETURN_STATEMENT$CBLAS_ROUTINE( $CALL_CBLAS_HEADER );
@@ -60,7 +72,8 @@
 
 $TEMPLATE[blas_level1]
 //
-// Value-type based template class
+// Value-type based template class. Use this class if you need a type
+// for dispatching to $groupname.
 //
 template< typename Value >
 struct $groupname_impl {
@@ -70,7 +83,11 @@
     typedef $RETURN_TYPE return_type;
 
 $INCLUDE_TEMPLATES
- // static template member function
+ //
+ // Static member function that
+ // 1) Deduces the required arguments for dispatching to BLAS, and
+ // 2) Asserts that most arguments make sense.
+ //
     template< $TYPES >
     static return_type invoke( $LEVEL1 ) {
         $STATIC_ASSERTS
@@ -80,8 +97,8 @@
 };
 $TEMPLATE[blas_level2]
 //
-// Generic template function to call $groupname
-//
+// Overloaded function for $groupname
+//
 template< $TYPES >
 inline typename $groupname_impl< typename value< $FIRST_TYPENAME >::type >::return_type
 $groupname( $LEVEL2 ) {

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level3/gemm.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level3/gemm.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level3/gemm.hpp 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
@@ -1,3 +1,7 @@
 $TEMPLATE[gemm.all.M.trait]
 num_rows,C
+$TEMPLATE[gemm.all.TRANSA.trait_of]
+A
+$TEMPLATE[gemm.all.TRANSB.trait_of]
+B
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_blas.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_blas.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_blas.hpp 2009-12-08 14:34:16 EST (Tue, 08 Dec 2009)
@@ -15,7 +15,6 @@
 #ifndef BOOST_NUMERIC_BINDINGS_BLAS_DETAIL_BLAS_H
 #define BOOST_NUMERIC_BINDINGS_BLAS_DETAIL_BLAS_H
 
-#include <boost/numeric/bindings/traits/type.h>
 #include <boost/numeric/bindings/blas/detail/blas_names.h>
 
 extern "C" {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk