Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59052 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates
From: rutger_at_[hidden]
Date: 2010-01-15 11:13:37


Author: rutger
Date: 2010-01-15 11:13:36 EST (Fri, 15 Jan 2010)
New Revision: 59052
URL: http://svn.boost.org/trac/boost/changeset/59052

Log:
More advanced grouping of subroutines (applied in blas generator, lapack to be done)

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py | 23 +++++++++++++++++++++++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 27 ++++++++++++++-------------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 17 +++++++++++++++--
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas_grouping.hpp | 8 ++++++++
   4 files changed, 60 insertions(+), 15 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py 2010-01-15 11:13:36 EST (Fri, 15 Jan 2010)
@@ -27,6 +27,29 @@
 
 
 #
+# a < b?
+# should replace the function "routine_cmp"
+#
+def subroutine_less( a, b, global_info_map ):
+
+ if global_info_map[ a ][ 'value_type' ] < \
+ global_info_map[ b ][ 'value_type' ]:
+ return True
+ if global_info_map[ a ][ 'value_type' ] > \
+ global_info_map[ b ][ 'value_type' ]:
+ return False
+
+ if global_info_map[ a ][ 'precision' ] < \
+ global_info_map[ b ][ 'precision' ]:
+ return True
+ if global_info_map[ a ][ 'precision' ] > \
+ global_info_map[ b ][ 'precision' ]:
+ return False
+
+ return False
+
+
+#
 # This routine actually does what it's named after :-).
 # Changes:
 # * used regex matching on delimiter instead of .find

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 2010-01-15 11:13:36 EST (Fri, 15 Jan 2010)
@@ -16,26 +16,27 @@
 # for debugging purposes
 import pprint
 
-
 #
-# Group subroutines on their name, with the first character removed. This will
-# group them in the same .hpp file as well. Sort these subroutines based on
-# routine_cmp above.
+# Group subroutines on their value and precision types.
+# Sort these subroutines based on
+# subroutine_less in the bindings file.
 #
 def group_by_value_type( global_info_map, template_map ):
   group_map = {}
   for subroutine_name in global_info_map.keys():
- subroutine_group_key = 'blas.group.' + subroutine_name
- subroutine_group_name = None
- if subroutine_group_key in template_map:
- subroutine_group_name = template_map[ subroutine_group_key ].strip()
- else:
- subroutine_group_name = subroutine_name[ 1: ]
+ subroutine_group_name = global_info_map[ subroutine_name ][ 'group_name' ]
     if not group_map.has_key( subroutine_group_name ):
       group_map[ subroutine_group_name ] = []
- group_map[ subroutine_group_name ] += [ subroutine_name ]
- for value in group_map.values():
- value.sort( bindings.routine_cmp )
+ group_map[ subroutine_group_name ].append( subroutine_name )
+ else:
+ insert_at = 0
+ for i in range( 0, len(group_map[ subroutine_group_name ]) ):
+ if bindings.subroutine_less( subroutine_name,
+ group_map[ subroutine_group_name ][ i ],
+ global_info_map ):
+ insert_at = i+1
+ group_map[ subroutine_group_name ].insert( insert_at, subroutine_name )
+
   return group_map
  
 #

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 2010-01-15 11:13:36 EST (Fri, 15 Jan 2010)
@@ -895,6 +895,9 @@
   subroutine_found = False
   subroutine_name = ''
   subroutine_arguments = []
+ subroutine_group_name = None
+ subroutine_value_type = None
+ subroutine_precision = None
   subroutine_return_type = None
 
   code_line_nr = 0
@@ -925,14 +928,12 @@
   # Do some further analysis as to what kind of routine this is
   #
   subroutine_group_key = parser_mode.lower() + '.group.' + subroutine_name
- subroutine_group_name = None
   if subroutine_group_key in template_map:
     subroutine_group_name = template_map[ subroutine_group_key ].strip()
   else:
     subroutine_group_name = subroutine_name[ 1: ]
 
   subroutine_value_key = parser_mode.lower() + '.value.' + subroutine_name
- subroutine_value_type = None
   if my_has_key( subroutine_value_key, template_map ):
     subroutine_value_type = template_map[ my_has_key( subroutine_value_key, template_map ) ].strip()
   elif subroutine_name[0] == 'C' or subroutine_name[0] == 'Z':
@@ -940,10 +941,19 @@
   elif subroutine_name[0] == 'S' or subroutine_name[0] == 'D':
     subroutine_value_type = 'real'
 
+ subroutine_precision_key = parser_mode.lower() + '.precision.' + subroutine_name
+ if my_has_key( subroutine_precision_key, template_map ):
+ subroutine_precision = template_map[ my_has_key( subroutine_precision_key, template_map ) ].strip()
+ elif subroutine_name[0] == 'S' or subroutine_name[0] == 'C':
+ subroutine_precision = 'single'
+ elif subroutine_name[0] == 'D' or subroutine_name[0] == 'Z':
+ subroutine_precision = 'double'
+
   print "Subroutine: ", subroutine_name
   print "Arguments: ", len(subroutine_arguments),":",subroutine_arguments
   print "Group name: ", subroutine_group_name
   print "Variant: ", subroutine_value_type
+ print "Precision: ", subroutine_precision
   print "Return: ", subroutine_return_type
 
   # Now we have the names of the arguments. The code following the subroutine statement are
@@ -1607,7 +1617,10 @@
   info_map = {}
   info_map[ 'arguments' ] = subroutine_arguments
   info_map[ 'purpose' ] = subroutine_purpose
+ info_map[ 'value_type' ] = subroutine_value_type
+ info_map[ 'group_name' ] = subroutine_group_name
   info_map[ 'return_type' ] = subroutine_return_type
+ info_map[ 'precision' ] = subroutine_precision
   info_map[ 'argument_map' ] = argument_map
   info_map[ 'grouped_arguments' ] = grouped_arguments
   if subroutine_return_type != None:

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas_grouping.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas_grouping.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas_grouping.hpp 2010-01-15 11:13:36 EST (Fri, 15 Jan 2010)
@@ -2,16 +2,24 @@
 ASUM
 $TEMPLATE[blas.value.DZASUM]
 complex
+$TEMPLATE[blas.precision.DZASUM]
+double
 $TEMPLATE[blas.group.SCASUM]
 ASUM
 $TEMPLATE[blas.value.SCASUM]
 complex
+$TEMPLATE[blas.precision.SCASUM]
+single
 $TEMPLATE[blas.group.DZNRM2]
 NRM2
 $TEMPLATE[blas.value.DZNRM2]
 complex
+$TEMPLATE[blas.precision.DZNRM2]
+double
 $TEMPLATE[blas.group.SCNRM2]
 NRM2
 $TEMPLATE[blas.value.SCNRM2]
 complex
+$TEMPLATE[blas.precision.SCNRM2]
+single
 $TEMPLATE[end]


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