lapack.Lapack Class Reference
+ Inheritance diagram for lapack.Lapack:

Public Member Functions

def __init__ (self)
 
def check_lapack (self)
 
def down_install_lapack (self)
 
def set_etime (self)
 
def write_makeinc (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

 lapacklib
 
 etime
 

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 LAPACK installation. 

Constructor & Destructor Documentation

◆ __init__()

def lapack.Lapack.__init__ (   self)
18  def __init__(self):
19  print('\n','='*40)
20  print(' Lapack installation/verification')
21  print('='*40)
22 
23  if(self.lapacklib != ''):
24  self.check_lapack()
25  else:
26  if (self.downlapack):
27  self.down_install_lapack()
28  else:
29  print("Need LAPACK")
30  sys.exit()
31 
32 
33 
34 
35 
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 lapack.Lapack.check_lapack(), lapack.Lapack.down_install_lapack(), framework.Frame.downlapack, if(), framework.Frame.lapacklib, lapack.Lapack.lapacklib, and Eigen::internal.print().

Member Function Documentation

◆ check_lapack()

def lapack.Lapack.check_lapack (   self)
 Checks if the provided LAPACK library is good 
36  def check_lapack(self):
37  """ Checks if the provided LAPACK library is good """
38  print('Checking if provided LAPACK works...', end=' ')
39 
40  # This function simply generates a FORTRAN program
41  # that contains few calls to LAPACK routines and then
42  # checks if compilation, linking and execution are succesful
43 
44  sys.stdout.flush()
45  writefile('tmpf.f',"""
46  program ftest
47  integer info, ipiv(1)
48  double precision A(1)
49  A(1)=1
50  call dgetrf(1,1,A,1,ipiv,info)
51  stop
52  end\n""")
53 
54  fcomm = self.mpif77+' -o tmpf '+'tmpf.f '+self.lapacklib+' '+self.blaslib+' '+self.ldflags_f77
55  (output, error, retz) = runShellCommand(fcomm)
56 
57  if(retz != 0):
58  print('\n\nLAPACK: provided LAPACK cannot be used! aborting...')
59  print('error is:\n','*'*40,'\n',error,'\n','*'*40)
60  sys.exit()
61 
62  comm = './tmpf'
63  (output, error, retz) = runShellCommand(comm)
64  if(retz != 0):
65  print('\n\nLAPACK: provided LAPACK cannot be used! aborting...')
66  print('error is:\n','*'*40,'\n',error,'\n','*'*40)
67  sys.exit()
68 
69  killfiles(['tmpf.f','tmpf'])
70  print('yes')
71 
72  return 0;
73 
74 
75 
76 
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.lapacklib, lapack.Lapack.lapacklib, framework.Frame.ldflags_f77, framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().

Referenced by lapack.Lapack.__init__().

◆ down_install_lapack()

def lapack.Lapack.down_install_lapack (   self)
77  def down_install_lapack(self):
78  print(""" Download and install LAPACK from netlib.org""")
79 
80  savecwd = os.getcwd()
81 
82  # creating the build and lib dirs if don't exist
83  if(not os.path.isdir(os.path.join(os.getcwd(),'build'))):
84  os.mkdir(os.path.join(os.getcwd(),'build'))
85 
86  if(not os.path.isdir(os.path.join(os.getcwd(),'lib'))):
87  os.mkdir(os.path.join(os.getcwd(),'lib'))
88 
89  if(not os.path.isdir(os.path.join(os.getcwd(),'log'))):
90  os.mkdir(os.path.join(os.getcwd(),'log'))
91 
92  # chdir into the build directory
93  os.chdir(os.path.join(os.getcwd(),'build'))
94 
95  if(not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.lapackurl)))):
96  print("""Download LAPACK...""", end=' ')
97  sys.stdout.flush()
98  downloader(self.lapackurl, self.downcmd)
99  print("done")
100  print("""Unzip and untar LAPACK...""", end=' ')
101  comm = 'gunzip -f lapack.tgz'
102  (output, error, retz) = runShellCommand(comm)
103  if(retz != 0):
104  print('\n\nLAPACK: cannot unzip lapack.tgz')
105  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
106  sys.exit()
107 
108  comm = 'tar xf lapack.tar'
109  (output, error, retz) = runShellCommand(comm)
110  if(retz != 0):
111  print('\n\nLAPACK: cannot untar lapack.tgz')
112  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
113  sys.exit()
114  os.remove('lapack.tar')
115  print("done")
116 
117  # change to LAPACK dir
118  os.chdir(os.path.join(os.getcwd(),'lapack-3.2'))
119 
120  # compile and generate library
121  self.set_etime()
122  self.write_makeinc()
123 
124  print('Compiling LAPACK (this will take several minutes)...', end=' ')
125  sys.stdout.flush()
126  comm = self.make+' lib'
127  (output, error, retz) = runShellCommand(comm)
128  if(retz != 0):
129  print('\n\nLAPACK: error building LAPACK')
130  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
131  sys.exit()
132 
133  # write the log on a file
134  fulllog = os.path.join(savecwd,'log/laplog')
135  writefile(fulllog, output+error)
136  print('Installation of LAPACK successful.')
137  print('(log is in ',fulllog,')')
138 
139  # move librefblas.a to the lib directory
140  os.rename('libreflapack.a',os.path.join(savecwd,'lib/libreflapack.a'))
141 
142  # set framework variables to point to the freshly installed BLAS library
143  self.lapacklib = os.path.join(savecwd,'lib/libreflapack.a ')
144  Frame.lapacklib = os.path.join(savecwd,'lib/libreflapack.a ')
145  os.chdir(savecwd)
146 
147  return
148 
149 
150 
151 
152 
153 
154 
def downloader(uri, cmd)
Definition: utils.py:150
def getURLName(url)
Definition: utils.py:137

References framework.Frame.downcmd, utils.downloader(), utils.getURLName(), if(), framework.Frame.lapackurl, Eigen::internal::TensorBlockDescriptor< NumDims, IndexType >::DestinationBuffer.make(), Eigen::internal::TensorBlockDescriptor< NumDims, Index >::DestinationBuffer.make(), framework.Frame.make, Eigen::internal.print(), utils.runShellCommand(), lapack.Lapack.set_etime(), lapack.Lapack.write_makeinc(), and utils.writefile().

Referenced by lapack.Lapack.__init__().

◆ set_etime()

def lapack.Lapack.set_etime (   self)
 Detects the FORTRAN timer 
155  def set_etime(self):
156  """ Detects the FORTRAN timer """
157 
158  print('Setting ETIME...', end=' ')
159  writefile('tmpf.f',"""
160  PROGRAM DSECND
161  REAL T1
162  REAL TARRAY( 2 )
163  REAL ETIME_
164  EXTERNAL ETIME_
165  T1 = ETIME_( TARRAY )
166  END\n""")
167  fcomm = self.mpif77+' '+self.fcflags+' -o tmpf tmpf.f'
168  (output, error, retz) = runShellCommand(fcomm)
169 
170  if(retz == 0):
171  self.etime = 'EXT_ETIME_'
172  print(self.etime)
173  killfiles(['tmpf.f', 'tmpf'])
174  return
175 
176 
177  writefile('tmpf.f',"""
178  PROGRAM DSECND
179  REAL T1
180  REAL TARRAY( 2 )
181  REAL ETIME
182  EXTERNAL ETIME
183  T1 = ETIME( TARRAY )
184  END\n""")
185 
186  fcomm = self.mpif77+' '+self.fcflags+' -o tmpf tmpf.f'
187  (output, error, retz) = runShellCommand(fcomm)
188 
189  if(retz == 0):
190  self.etime = 'EXT_ETIME'
191  print(self.etime)
192  killfiles(['tmpf.f', 'tmpf'])
193  return
194 
195 
196  writefile('tmpf.f',"""
197  PROGRAM DSECND
198  REAL T
199  INTRINSIC ETIME
200  CALL CPU_TIME( T )
201  END\n""")
202 
203  fcomm = self.mpif77+' '+self.fcflags+' -o tmpf tmpf.f'
204  (output, error, retz) = runShellCommand(fcomm)
205 
206  if(retz == 0):
207  self.etime = 'INT_CPU_TIME'
208  print(self.etime)
209  killfiles(['tmpf.f', 'tmpf'])
210  return
211 
212 
213  writefile('tmpf.f',"""
214  PROGRAM DSECND
215  REAL T1
216  REAL TARRAY( 2 )
217  REAL ETIME
218  INTRINSIC ETIME
219  T1 = ETIME( TARRAY )
220  END\n""")
221 
222  fcomm = self.mpif77+' '+self.fcflags+' -o tmpf tmpf.f'
223  (output, error, retz) = runShellCommand(fcomm)
224 
225  if(retz == 0):
226  self.etime = 'INT_ETIME'
227  print(self.etime)
228  killfiles(['tmpf.f', 'tmpf'])
229  return
230 
231 
232  killfiles(['tmpf.f', 'tmpf'])
233  self.etime = 'NONE'
234 
235 
236 

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

Referenced by lapack.Lapack.down_install_lapack().

◆ write_makeinc()

def lapack.Lapack.write_makeinc (   self)
 Writes the make.inc file for LAPACK installation 
237  def write_makeinc(self):
238  """ Writes the make.inc file for LAPACK installation """
239 
240  print('Writing make.inc...', end=' ')
241  writefile('make.inc',"""
242 SHELL = /bin/sh
243 PLAT =
244 FORTRAN = """+self.mpif77+"""
245 OPTS = """+self.fcflags+"""
246 DRVOPTS = $(OPTS)
247 NOOPT = """+self.noopt+"""
248 LOADER = """+self.mpif77+"""
249 LOADOPTS =
250 TIMER = """+self.etime+"""
251 ARCH = ar
252 ARCHFLAGS= cr
253 RANLIB = """+self.ranlib+"""
254 BLASLIB = """+self.blaslib+"""
255 LAPACKLIB = libreflapack.a
256 TMGLIB = tmglib.a
257 EIGSRCLIB = eigsrc.a
258 LINSRCLIB = linsrc.a
259  """)
260  print('done.')

References blas.Blas.blaslib, framework.Frame.blaslib, lapack.Lapack.etime, framework.Frame.fcflags, framework.Frame.mpif77, framework.Frame.noopt, Eigen::internal.print(), framework.Frame.ranlib, and utils.writefile().

Referenced by lapack.Lapack.down_install_lapack().

Member Data Documentation

◆ etime

lapack.Lapack.etime

◆ lapacklib


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