Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58527 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates
From: rutger_at_[hidden]
Date: 2009-12-25 06:41:53


Author: rutger
Date: 2009-12-25 06:41:52 EST (Fri, 25 Dec 2009)
New Revision: 58527
URL: http://svn.boost.org/trac/boost/changeset/58527

Log:
Misc. lapack_generator updates

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 4 +-
   sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py | 32 ++++++++++++++++++++++++++++--
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 16 +++++++++++---
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp | 14 ++++++------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp | 41 +++++++++++++++++++++++++++++++++++----
   5 files changed, 86 insertions(+), 21 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-25 06:41:52 EST (Fri, 25 Dec 2009)
@@ -191,7 +191,8 @@
 
       #
       # Are we dealing with a transpose option here?
- # If so, we need to inject an order_type typedef.
+ # Because CBLAS allows to pass the order of the matrices, here we
+ # inject code that determines the default data order.
       #
       if 'matrix' in info_map[ subroutine ][ 'grouped_arguments' ][ 'by_type' ]:
         has_trans = False
@@ -227,7 +228,6 @@
                 ' >::type order;' )
               includes += [ '#include <boost/numeric/bindings/data_order.hpp>' ]
 
-
       #
       # Add an include in case of the uplo or diag options
       #

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py 2009-12-25 06:41:52 EST (Fri, 25 Dec 2009)
@@ -61,9 +61,11 @@
       '#include <boost/numeric/bindings/begin.hpp>',
       '#include <boost/numeric/bindings/size.hpp>',
       '#include <boost/numeric/bindings/stride.hpp>',
+ '#include <boost/numeric/bindings/is_mutable.hpp>',
       #'#include <boost/numeric/bindings/traits/traits.hpp>',
       #'#include <boost/numeric/bindings/traits/type_traits.hpp>',
       '#include <boost/numeric/bindings/lapack/detail/lapack.h>',
+ '#include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>',
       #'#include <boost/mpl/bool.hpp>',
       '#include <boost/type_traits/is_same.hpp>',
       '#include <boost/type_traits/remove_const.hpp>',
@@ -81,11 +83,18 @@
       # add the argument list here
       arg_list = []
       lapack_arg_list = []
+ typename_list = []
+
       for arg in info_map[ subroutine ][ 'arguments' ]:
         arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0' ] ]
- lapack_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_blas_header' ] ]
+ lapack_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_lapack_header' ] ]
+ if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] != None:
+ typename_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] ]
+
+ sub_template = sub_template.replace( "$TYPES", ", ".join( typename_list ) )
+ sub_template = sub_template.replace( "template< >\n", "" )
       sub_template = sub_template.replace( "$LEVEL0", ", ".join( arg_list ) )
- sub_template = sub_template.replace( "$CALL_BLAS_HEADER", ", ".join( lapack_arg_list ) )
+ sub_template = sub_template.replace( "$CALL_LAPACK_HEADER", ", ".join( lapack_arg_list ) )
       sub_template = sub_template.replace( "$SUBROUTINE", subroutine )
       sub_template = sub_template.replace( '$groupname', group_name.lower() )
       sub_template = sub_template.replace( "$SPECIALIZATION", documentation.routine_value_type[ subroutine[0] ] )
@@ -169,6 +178,17 @@
       user_defined_arg_list = []
       user_defined_opt_arg_list = []
       keyword_type_list = []
+ typedef_list = []
+
+ #
+ # Add an include in case of the uplo or diag options
+ #
+ if 'UPLO' in info_map[ subroutine ][ 'arguments' ]:
+ includes += [ '#include <boost/numeric/bindings/data_side.hpp>' ]
+ if 'DIAG' in info_map[ subroutine ][ 'arguments' ]:
+ includes += [ '#include <boost/numeric/bindings/diag_tag.hpp>' ]
+ if 'TRANS' in info_map[ subroutine ][ 'arguments' ]:
+ includes += [ '#include <boost/numeric/bindings/trans_tag.hpp>' ]
 
       #
       # Create static assertions, first by value type
@@ -213,6 +233,8 @@
           call_level1_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_level_1' ] ]
         if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'opt_workspace_query' ] != None:
           workspace_query_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'opt_workspace_query' ] ]
+ if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'typedef' ] != None:
+ typedef_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'typedef' ] ]
         if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'keyword_type' ] != None:
           keyword_type_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'keyword_type' ] ]
 
@@ -229,6 +251,7 @@
             user_defined_opt_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'user_defined_init' ] ]
 
       # Level 1 replacements
+ level1_template = level1_template.replace( "$TYPEDEFS", "\n ".join( typedef_list ) )
       level1_template = level1_template.replace( "$CALL_LEVEL0", ", ".join( level0_arg_list ) )
       level1_template = level1_template.replace( "$CALL_LEVEL1", ", ".join( call_level1_arg_list ) )
       level1_template = level1_template.replace( "$LEVEL1", ", ".join( level1_arg_list ) )
@@ -274,7 +297,7 @@
       if info_map[ subroutine ][ 'grouped_arguments' ][ 'by_io' ].has_key( 'workspace' ):
         # Add an include for the workspace stuff
         includes += [ '#include <boost/numeric/bindings/lapack/workspace.hpp>' ]
- includes += [ '#include <boost/numeric/bindings/traits/detail/array.hpp>' ]
+ includes += [ '#include <boost/numeric/bindings/detail/array.hpp>' ]
 
         # Continue
         workspace_size = len( info_map[ subroutine ][ 'grouped_arguments' ][ 'by_io' ][ 'workspace' ] )
@@ -422,6 +445,9 @@
     result = result.replace( '$DIRNAME', base_dir.split("/")[-1].upper() )
     result = result.replace( '$dirname', base_dir.split("/")[-1].lower() )
     result = result.replace( '$INTEGER_TYPE', netlib.fortran_integer_type )
+ result = result.replace( '\n\n\n', '\n\n' )
+ result = result.replace( "\n \n", "\n" )
+ result = result.replace( "\n \n", "\n" )
 
     # replace the global variables as last (this is convenient)
     #result = result.replace( '$INDENT', ' ' )

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-25 06:41:52 EST (Fri, 25 Dec 2009)
@@ -121,6 +121,13 @@
             result = '&blas_option< ' + level0_types[ name ] + ' >::value'
     return result
 
+def call_lapack_header( name, properties ):
+ result = call_c_type( name, properties )
+ if 'trait_type' in properties:
+ if properties[ 'trait_type' ] in [ 'trans', 'uplo', 'diag' ]:
+ result = '&lapack_option< ' + level0_types[ name ] + ' >::value'
+ return result
+
 def call_c_type( name, properties ):
   result = ''
   if properties[ 'type' ] == 'vector' or properties[ 'type' ] == 'matrix':
@@ -478,7 +485,7 @@
       min_workspace_call = min_workspace_call_type( name, properties, arg_map )
       if min_workspace_call == None:
         min_workspace_call = '$CALL_MIN_SIZE'
- result = 'traits::detail::array< ' + workspace_type( name, properties ) + ' >' + \
+ result = 'bindings::detail::array< ' + workspace_type( name, properties ) + ' >' + \
                ' tmp_' + name.lower() + '( min_size_' + name.lower() + '( ' + min_workspace_call + ' ) );'
   return result
 
@@ -488,10 +495,10 @@
   if 'workspace' in properties[ 'io' ]:
     if properties.has_key( 'workspace_query_by' ):
       if properties['value_type'] == 'INTEGER':
- result = 'traits::detail::array< ' + workspace_type( name, properties ) + ' >' + \
+ result = 'bindings::detail::array< ' + workspace_type( name, properties ) + ' >' + \
                ' tmp_' + name.lower() + '( opt_size_' + name.lower() + ' );'
       else:
- result = 'traits::detail::array< ' + workspace_type( name, properties ) + ' >' + \
+ result = 'bindings::detail::array< ' + workspace_type( name, properties ) + ' >' + \
                ' tmp_' + name.lower() + '( traits::detail::to_int( opt_size_' + name.lower() + ' ) );'
   return result
 
@@ -1058,7 +1065,7 @@
       referring_argument_name = argument_properties[ 'leading_dimension' ]
       if argument_map.has_key( referring_argument_name ):
         argument_map[ referring_argument_name ][ 'trait_type' ] = 'lda'
- argument_map[ referring_argument_name ][ 'trait_of' ] = argument_name
+ argument_map[ referring_argument_name ][ 'trait_of' ] = [ argument_name ]
 
   # Extend convenience lookups by io, recently acquired when processing the comment
   # fields. We have to be sure arguments are processed in the right order.
@@ -1386,6 +1393,7 @@
     argument_properties[ 'code' ] = {}
     argument_properties[ 'code' ][ 'lapack_h' ] = c_type( argument_name, argument_properties )
     argument_properties[ 'code' ][ 'call_blas_header' ] = call_blas_header( argument_name, argument_properties )
+ argument_properties[ 'code' ][ 'call_lapack_header' ] = call_lapack_header( argument_name, argument_properties )
     argument_properties[ 'code' ][ 'level_0' ] = level0_type( argument_name, argument_properties )
     argument_properties[ 'code' ][ 'level_0_typename' ] = level0_typename( argument_name, argument_properties )
     argument_properties[ 'code' ][ 'call_level_0' ] = call_level0_type( argument_name, argument_properties, argument_map )

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-25 06:41:52 EST (Fri, 25 Dec 2009)
@@ -77,8 +77,8 @@
 $TEMPLATE[blas_overloads]
 //
 // Overloaded function for dispatching to
-// * netlib-compatible BLAS backend (the default)
-// * $SPECIALIZATION value-type
+// * netlib-compatible BLAS backend (the default), and
+// * $SPECIALIZATION value-type.
 //
 template< $TYPES >
 inline $RETURN_TYPE $groupname( $LEVEL0 ) {
@@ -89,8 +89,8 @@
 $TEMPLATE[cblas_overloads]
 //
 // Overloaded function for dispatching to
-// * CBLAS backend
-// * $SPECIALIZATION value-type
+// * CBLAS backend, and
+// * $SPECIALIZATION value-type.
 //
 template< $TYPES >
 inline $RETURN_TYPE $groupname( $LEVEL0 ) {
@@ -100,8 +100,8 @@
 $TEMPLATE[cublas_overloads]
 //
 // Overloaded function for dispatching to
-// * CUBLAS backend
-// * $SPECIALIZATION value-type
+// * CUBLAS backend, and
+// * $SPECIALIZATION value-type.
 //
 template< $TYPES >
 inline $RETURN_TYPE $groupname( $LEVEL0 ) {
@@ -129,9 +129,9 @@
     //
     template< $TYPES >
     static return_type invoke( $LEVEL1 ) {
+ $TYPEDEFS
         $STATIC_ASSERTS
         $ASSERTS
- $TYPEDEFS
         $RETURN_STATEMENTdetail::$groupname( $CALL_LEVEL0 );
     }
 };

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp 2009-12-25 06:41:52 EST (Fri, 25 Dec 2009)
@@ -31,6 +31,16 @@
 $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
+// addition, if applicable, they are overloaded for user-defined workspaces.
+// Calls to these functions are passed to the $groupname_impl classes. In the
+// documentation, most overloads are collapsed to avoid a large number of
+// prototypes which are very similar.
+//
+
 $LEVEL2
 } // namespace lapack
 } // namespace bindings
@@ -40,10 +50,11 @@
 #endif
 $TEMPLATE[lapack_overloads]
 //
-// Overloaded function for the $SPECIALIZATION value-type.
+// Overloaded function for dispatching to $SPECIALIZATION value-type.
 //
+template< $TYPES >
 inline void $groupname( $LEVEL0 ) {
- LAPACK_$SUBROUTINE( $CALL_BLAS_HEADER );
+ LAPACK_$SUBROUTINE( $CALL_LAPACK_HEADER );
 }
 
 $TEMPLATE[lapack_include_hierarchy]
@@ -91,28 +102,46 @@
 $TEMPLATE[level1_workspace]
     typedef Value value_type;
     typedef typename remove_imaginary< Value >::type real_type;
+ typedef tag::column_major order;
 
 $INCLUDE_TEMPLATES
- // user-defined workspace specialization
+ //
+ // Static member function for user-defined workspaces, that
+ // * Deduces the required arguments for dispatching to LAPACK, and
+ // * Asserts that most arguments make sense.
+ //
     template< $TYPES, $WORKSPACE_TYPENAMES >
     static void invoke( $LEVEL1, detail::workspace$WORKSPACE_SIZE< $WORKSPACE_TYPES > work ) {
+ $TYPEDEFS
         $STATIC_ASSERTS
         $INIT_USER_DEFINED_VARIABLES
         $ASSERTS
         detail::$groupname( $CALL_LEVEL0 );
     }
 
- // minimal workspace specialization
+ //
+ // Static member function that
+ // * Figures out the minimal workspace requirements, and passes
+ // the results to the user-defined workspace overload of the
+ // invoke static member
+ //
     template< $TYPES >
     static void invoke( $LEVEL1, minimal_workspace work ) {
+ $TYPEDEFS
         $INIT_USER_DEFINED_VARIABLES
 $SETUP_MIN_WORKARRAYS_POST
         invoke( $CALL_LEVEL1, workspace( $TMP_WORKARRAYS ) );
     }
 
- // optimal workspace specialization
+ //
+ // Static member function that
+ // * Figures out the optimal workspace requirements, and passes
+ // the results to the user-defined workspace overload of the
+ // invoke static member
+ //
     template< $TYPES >
     static void invoke( $LEVEL1, optimal_workspace work ) {
+ $TYPEDEFS
 $OPT_WORKSPACE_FUNC
     }
 
@@ -161,11 +190,13 @@
 $TEMPLATE[level1_noworkspace]
     typedef Value value_type;
     typedef typename remove_imaginary< Value >::type real_type;
+ typedef tag::colum_major order;
 
 $INCLUDE_TEMPLATES
     // templated specialization
     template< $TYPES >
     static void invoke( $LEVEL1 ) {
+ $TYPEDEFS
         $STATIC_ASSERTS
         $ASSERTS
         detail::$groupname( $CALL_LEVEL0 );


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