Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79907 - sandbox/numeric_bindings/libs/numeric/bindings/tools
From: rutger_at_[hidden]
Date: 2012-08-07 09:39:14


Author: rutger
Date: 2012-08-07 09:39:13 EDT (Tue, 07 Aug 2012)
New Revision: 79907
URL: http://svn.boost.org/trac/boost/changeset/79907

Log:
Added support for removal of unused parameters in BLAS bindings

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/README.txt | 12 ++++++++----
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 27 ++++++++++++++++++++++++---
   sandbox/numeric_bindings/libs/numeric/bindings/tools/cublas.py | 5 +++++
   3 files changed, 37 insertions(+), 7 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/README.txt
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/README.txt (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/README.txt 2012-08-07 09:39:13 EDT (Tue, 07 Aug 2012)
@@ -1,19 +1,23 @@
 
 Using the Python Generator
 ----
-To test the python generator, you will need the lapack sources. Make sure the path to your lapack sources is also set in the lapack_parser.py file; look for the variable lapack_src_path.
+To test the python generator, you will need the lapack sources. Make sure the path to your
+lapack sources is also set in the lapack_parser.py file; look for the variable lapack_src_path.
+In addition, check the same variable (lapack_src_path) in the blas_generator.py file.
 
 On a debian-based system, acquiring the sources of BLAS and LAPACK may be achieved by
 
 $ cd tools
 $ apt-get source blas lapack
+$ apt-get install nvidia-cuda-dev
 
 this will give you a subdirectory called 'blas-X.X' and 'lapack-X.X.X'. Running the generator may be done by
 
-$ ./lapack_generator
-$ ./blas_generator
+$ ./lapack_generator > output_lapack.txt
+$ ./blas_generator > output_blas.txt
 
-from within the tools directory.
+from within the tools directory. The generators are quite verbose, it is recommended to put their output
+in a file.
 
 To use the compile_test, you need cmake. Please do a
 

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 2012-08-07 09:39:13 EDT (Tue, 07 Aug 2012)
@@ -117,11 +117,22 @@
         cblas_arg_list = []
         cublas_arg_list = []
         level0_static_asserts = []
+ check_for_unused = []
 
         for arg in info_map[ subroutine ][ 'arguments' ]:
             print "Subroutine ", subroutine, " arg ", arg
             arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0' ] ]
             blas_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_blas_header' ] ]
+
+ #
+ # Find potential arguments that may cause warnings because they are not used, and
+ # store these in check_for_unused
+ #
+ if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0' ] != None and \
+ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] != None:
+ keyword = info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0' ].split( ' ')[-1]
+ check_for_unused += [ keyword ]
+
             if 'call_cblas_header' in info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ]:
                 cblas_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_cblas_header' ] ]
             else:
@@ -131,6 +142,7 @@
                 typename_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] ]
 
         if "has_cblas_order_arg" in info_map[ subroutine ]:
+ check_for_unused.append( 'order' )
             if info_map[ subroutine ][ "has_cblas_order_arg" ] == True:
                 arg_list.insert( 0, "const Order order" )
                 cblas_arg_list.insert( 0, "cblas_option< Order >::value" )
@@ -168,6 +180,15 @@
         else:
             cublas_routine = '// NOT FOUND'
 
+ #
+ # Count potentially unused arguments. If the count is 1; it is only present in the
+ # parameter list. In that case, the argument may be removed from the code
+ #
+ print "Check for unused:" , check_for_unused
+ for parameter in check_for_unused:
+ if sub_template.count( parameter ) == 1:
+ sub_template = sub_template.replace( ' ' + parameter, '' )
+
         sub_template = sub_template.replace( "$CALL_CUBLAS_HEADER", ", ".join( cublas_arg_list ) )
         sub_template = sub_template.replace( "$CUBLAS_ROUTINE", cublas_routine )
 
@@ -523,9 +544,9 @@
     result[ split_templates[ index*2 ] ] = split_templates[ index*2 + 1 ]
   return result
 
-lapack_src_path = './blas-1.2/src'
-cblas_h_path = './blas-1.2/cblas/src/cblas.h'
-cublas_h_path = './cublas.h'
+lapack_src_path = './blas-1.2.20110419/src'
+cblas_h_path = './blas-1.2.20110419/cblas/src/cblas.h'
+cublas_h_path = '/usr/include/cublas.h'
 template_src_path = './templates'
 bindings_impl_target_path = '../../../../boost/numeric/bindings/blas/'
 test_target_path = '../test/blas/'

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/cublas.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/cublas.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/cublas.py 2012-08-07 09:39:13 EDT (Tue, 07 Aug 2012)
@@ -59,6 +59,8 @@
                 # E.g., BLAS DPARAM equals CUBLAS SPARAM
                 elif 'S' + arg[1:] in arguments and arg == 'DPARAM':
                         cublas_arg = 'S' + arg[1:]
+ elif 'C' + arg in arguments:
+ cublas_arg = 'C' + arg
                 elif arg in alias_map:
                     if alias_map[ arg ] in arguments:
                         cublas_arg = alias_map[ arg ]
@@ -78,6 +80,9 @@
                     info_map[ blas_routine ][ "argument_map" ][ arg ][ "code" ][ "call_cublas_header" ] = call_cublas_header
 
                 else:
+ print "Could not match cublas argument '" + cublas_arg + "' to known arguments."
+ print arg, arguments
+
                     exit(0)
 
 


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