blas.Blas Class Reference
+ Inheritance diagram for blas.Blas:

Public Member Functions

def __init__ (self)
 
def check_blas (self)
 
def down_install_blas (self)
 
- Public Member Functions inherited from framework.Frame
def __init__ (self, argv)
 
def usage (self)
 
def parse_args (self, argv)
 
def look_for_mpibinaries (self)
 
def look_for_mpih (self)
 
def check_mpicc (self)
 
def check_mpif77 (self)
 
def set_mangling (self)
 
def check_linking (self)
 
def set_download (self)
 
def set_ranlib (self)
 
def detect_compilers (self)
 
def fc_is_intel (self)
 
def fc_is_gnu (self)
 
def fc_is_pgi (self)
 
def cc_is_intel (self)
 
def cc_is_gnu (self)
 
def cc_is_pgi (self)
 
def resume (self)
 
def cleanup (self)
 

Public Attributes

 blaslib
 

Additional Inherited Members

- Static Public Attributes inherited from framework.Frame
string prefix = ''
 
 ccflags
 
 fcflags
 
 noopt
 
string mpibindir = ''
 
string mpiincdir = ''
 
 mpicc
 
 mpif77
 
string make = 'make'
 
string plat = 'LINUX'
 
string mangling = ''
 
string blaslib = ''
 
string blacslib = ''
 
string blacsClib = ''
 
string blacsF77lib = ''
 
string lapacklib = ''
 
string scalapacklib = ''
 
int proxy = 0
 
int downblas = 0
 
int downblacs = 1
 
int downlapack = 0
 
string ldflags_c = ''
 
string ldflags_f77 = ''
 
int testing = 1
 
string downcmd = ''
 
string blasurl = 'http://netlib.org/blas/blas.tgz'
 
string lapackurl = 'http://netlib.org/lapack/lapack.tgz'
 
string blacsurl = 'http://netlib.org/blacs/mpiblacs.tgz'
 
string scalapackurl = 'http://netlib.org/scalapack/scalapack-1.8.0.tgz'
 
string ranlib = ''
 
int clean = 0
 

Detailed Description

 This class takes care of the BLACS installation. 

Constructor & Destructor Documentation

◆ __init__()

def blas.Blas.__init__ (   self)
17  def __init__(self):
18  print('\n','='*40)
19  print(' BLAS installation/verification')
20  print('='*40)
21 
22  if(self.blaslib != ''):
23  self.check_blas()
24  else:
25  if (self.downblas):
26  self.down_install_blas()
27  else:
28  print("Need BLAS")
29  sys.exit()
30 
31 
32 
33 
34 
if(UPLO(*uplo)==INVALID) info
Definition: level3_impl.h:428
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166

References blas.Blas.blaslib, framework.Frame.blaslib, blas.Blas.check_blas(), blas.Blas.down_install_blas(), framework.Frame.downblas, if(), and Eigen::internal.print().

Member Function Documentation

◆ check_blas()

def blas.Blas.check_blas (   self)
35  def check_blas(self):
36 
37  print('Checking if provided BLAS works...', end=' ')
38  # This function simply generates a FORTRAN program
39  # that contains few calls to BLAS routine and then
40  # checks if compilation, linking and execution are succesful
41 
42  sys.stdout.flush()
43  writefile('tmpf.f',"""
44  program ftest
45  double precision da, dx(1)
46  dx(1)=1
47  da = 2
48  call dscal(1,da,dx,1)
49  stop
50  end\n""")
51 
52  fcomm = self.mpif77+' -o tmpf '+'tmpf.f '+self.blaslib+' '+self.ldflags_f77
53  (output, error, retz) = runShellCommand(fcomm)
54 
55  if(retz != 0):
56  print('\n\nBLAS: provided BLAS cannot be used! aborting...')
57  print('error is:\n','*'*40,'\n',error,'\n','*'*40)
58  sys.exit()
59 
60  comm = './tmpf'
61  (output, error, retz) = runShellCommand(comm)
62  if(retz != 0):
63  print('\n\nBLAS: provided BLAS cannot be used! aborting...')
64  print('error is:\n','*'*40,'\n',error,'\n','*'*40)
65  sys.exit()
66 
67  killfiles(['tmpf.f','tmpf'])
68  print('yes')
69 
70  return 0;
71 
72 
def runShellCommand(command)
Definition: utils.py:87
def killfiles(lst)
Definition: utils.py:23
def writefile(fname, fill)
Definition: utils.py:17

References blas.Blas.blaslib, framework.Frame.blaslib, if(), utils.killfiles(), framework.Frame.ldflags_f77, framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().

Referenced by blas.Blas.__init__().

◆ down_install_blas()

def blas.Blas.down_install_blas (   self)
73  def down_install_blas(self):
74 
75  print("""
76 The reference BLAS library is being installed.
77 Don't expect high performance from this reference library!
78 If you want performance, you need to use an optimized BLAS library and,
79 to avoid unnecessary complications, if you need to compile this optimized BLAS
80 library, use the same compiler you're using here.""")
81  sys.stdout.flush()
82 
83  savecwd = os.getcwd()
84 
85  # creating the build,lib and log dirs if don't exist
86  if(not os.path.isdir(os.path.join(os.getcwd(),'build'))):
87  os.mkdir(os.path.join(os.getcwd(),'build'))
88 
89  if(not os.path.isdir(os.path.join(os.getcwd(),'lib'))):
90  os.mkdir(os.path.join(os.getcwd(),'lib'))
91 
92  if(not os.path.isdir(os.path.join(os.getcwd(),'log'))):
93  os.mkdir(os.path.join(os.getcwd(),'log'))
94 
95  # chdir into the build directory
96  os.chdir(os.path.join(os.getcwd(),'build'))
97 
98  # Check if blas.tgz is already present in the working dir
99  # otherwise download it
100  if(not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.blasurl)))):
101  print('Downloading reference BLAS...', end=' ')
102  downloader(self.blasurl,self.downcmd)
103  print('done')
104 
105  # unzip and untar
106  print('Unzip and untar reference BLAS...', end=' ')
107  comm = 'gunzip -f blas.tgz'
108  (output, error, retz) = runShellCommand(comm)
109  if(retz != 0):
110  print('\n\nBLAS: cannot unzip blas.tgz')
111  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
112  sys.exit()
113 
114  comm = 'tar xf blas.tar'
115  (output, error, retz) = runShellCommand(comm)
116  if(retz != 0):
117  print('\n\nBLAS: cannot untar blas.tgz')
118  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
119  sys.exit()
120  os.remove('blas.tar')
121  print('done')
122 
123  # change to BLAS dir
124  os.chdir(os.path.join(os.getcwd(),'BLAS'))
125 
126  # compile and generate library
127  print('Compile and generate reference BLAS...', end=' ')
128  sys.stdout.flush()
129  comm = self.mpif77+' '+self.fcflags+' -c *.f'
130  (output, error, retz) = runShellCommand(comm)
131  if(retz != 0):
132  print('\n\nBLAS: cannot compile blas')
133  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
134  sys.exit()
135 
136  log = output+error
137 
138  comm = 'ar cr librefblas.a *.o'
139  (output, error, retz) = runShellCommand(comm)
140  if(retz != 0):
141  print('\n\nBLAS: cannot create blas library')
142  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
143  sys.exit()
144  print('done')
145 
146  # write the log on a file
147  log = log+output+error
148  fulllog = os.path.join(savecwd,'log/blaslog')
149  writefile(fulllog, log)
150  print('Installation of reference BLAS successful.')
151  print('(log is in ',fulllog,')')
152 
153  # move librefblas.a to the lib directory
154  os.rename('librefblas.a',os.path.join(savecwd,'lib/librefblas.a'))
155 
156  # set framework variables to point to the freshly installed BLAS library
157  self.blaslib = os.path.join(savecwd,'lib/librefblas.a ')
158  Frame.blaslib = os.path.join(savecwd,'lib/librefblas.a ')
159  os.chdir(savecwd)
def downloader(uri, cmd)
Definition: utils.py:150
def getURLName(url)
Definition: utils.py:137

References framework.Frame.blasurl, framework.Frame.downcmd, utils.downloader(), framework.Frame.fcflags, utils.getURLName(), if(), framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().

Referenced by blas.Blas.__init__().

Member Data Documentation

◆ blaslib


The documentation for this class was generated from the following file: