#! /usr/bin/env python3 # def nas ( ): #*****************************************************************************80 # ## nas() is the NASA kernel benchmark. # # Discussion: # # This is a version of the NAS kernel benchmark program, # whose original version was created by David Bailey, # dated 17 December 1984. # # Each of the tests begins by filling arrays with pseudorandom values # generated by the recursion: # x(n+1) = 5^7 * x(n) (mod 2^30) # This recursion will generate 2^28 (approx. 268 million) numbers # before repeating. For this scheme to work properly, the hardware # multiply operation must be correct to 47 bits of precision. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 05 July 2015 # # Author: # # Original FORTRAN77 version by David Bailey. # Python version by John Burkardt # import platform from btrix import btrix_test from cfft2d import cfft2d_test from cholsky import cholsky_test from emit import emit_test from gmtry import gmtry_test from mxm import mxm_test from vpenta import vpenta_test print ( '' ) print ( 'nas():' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' The NAS kernel benchmark program.' ) print ( '' ) print ( ' Program Error FP Ops Seconds MFLOPS' ) print ( '' ) te = 0.0 tf = 0.0 tt = 0.0 # # BTRIX # er, fp, tm, rt = btrix_test ( ) print ( ' btrix %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # CFFT2D # er, fp, tm, rt = cfft2d_test ( ) print ( ' cfft2d %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # CHOLSKY # er, fp, tm, rt = cholsky_test ( ) print ( ' cholsky %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # EMIT # er, fp, tm, rt = emit_test ( ) print ( ' emit %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # GMTRY # er, fp, tm, rt = gmtry_test ( ) print ( ' gmtry %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # MXM # er, fp, tm, rt = mxm_test ( ) print ( ' mxm %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # VPENTA # er, fp, tm, rt = vpenta_test ( ) print ( ' vpenta %13.4e %13.4e %10.4f %10.2f' % ( er, fp, tm, rt ) ) te = te + er tf = tf + fp tt = tt + tm # # TOTAL # rt = 1.0E-06 * tf / tt print ( ' total %13.4e %13.4e %10.4f %10.2f' % ( te, tf, tt, rt ) ) # Terminate. # print ( '' ) print ( 'nas():' ) print ( ' Normal end of execution.' ) if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) nas ( ) timestamp ( )