blacs.Blacs Class Reference
+ Inheritance diagram for blacs.Blacs:

Public Member Functions

def __init__ (self)
 
def check_blacs (self)
 
def down_install_blacs (self)
 
def set_transcomm (self)
 
def write_bmake (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

 blacslib
 
 blacsClib
 
 blacsF77lib
 
 transcomm
 

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 blacs.Blacs.__init__ (   self)
17  def __init__(self):
18  print('\n','='*40)
19  print(' BLACS installation/verification')
20  print('='*40)
21 
22  if (self.downblacs):
23  self.down_install_blacs()
24  elif(self.blacslib != '' and self.blacsClib!='' and self.blacsF77lib !=''):
25  self.check_blacs()
26  else:
27  print('need blacs')
28  sys.exit()
29 
30 
31 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166

References blacs.Blacs.blacsClib, framework.Frame.blacsClib, blacs.Blacs.blacsF77lib, framework.Frame.blacsF77lib, blacs.Blacs.blacslib, framework.Frame.blacslib, blacs.Blacs.check_blacs(), blacs.Blacs.down_install_blacs(), framework.Frame.downblacs, and Eigen::internal.print().

Member Function Documentation

◆ check_blacs()

def blacs.Blacs.check_blacs (   self)
 Checks if BLACS libraries are good 
32  def check_blacs(self):
33  """ Checks if BLACS libraries are good """
34 
35  # This function simply generates a FORTRAN program
36  # that contains few calls to BLACS routine and then
37  # checks if compilation, linking and execution are succesful
38  print('Checking if provided BLACS works...', end=' ')
39  sys.stdout.flush()
40  writefile('tmpf.f',"""
41  program ftest
42  integer itmp, iam, nnodes
43  call blacs_pinfo(iam, nnodes)
44  if(nnodes.gt.0) then
45  call blacs_get( 0, 0, itmp )
46  call blacs_gridinit(itmp, 'c', 1, nnodes)
47  call blacs_gridexit(itmp)
48  end if
49  stop
50  end\n""")
51 
52  fcomm = self.mpif77+' '+self.ldflags_f77+' -o tmpf '+'tmpf.f '+self.blacsF77lib+' '+self.blacslib+' '+self.blacsClib
53  (output, error, retz) = runShellCommand(fcomm)
54 
55  if(retz != 0):
56  print('\n\nBLACS: provided BLACS cannot be used! aborting...')
57  print('error is:\n','*'*40,'\n',error,'\n','*'*40)
58  sys.exit()
59 
60  comm = 'date'
61  (output, error, retz) = runShellCommand(comm)
62  if(retz != 0):
63  print('\n\nBLACS: provided BLACS 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 
73 
if(UPLO(*uplo)==INVALID) info
Definition: level3_impl.h:428
def runShellCommand(command)
Definition: utils.py:87
def killfiles(lst)
Definition: utils.py:23
def writefile(fname, fill)
Definition: utils.py:17

References blacs.Blacs.blacsClib, framework.Frame.blacsClib, blacs.Blacs.blacsF77lib, framework.Frame.blacsF77lib, blacs.Blacs.blacslib, framework.Frame.blacslib, if(), utils.killfiles(), framework.Frame.ldflags_f77, framework.Frame.mpif77, Eigen::internal.print(), utils.runShellCommand(), and utils.writefile().

Referenced by blacs.Blacs.__init__().

◆ down_install_blacs()

def blacs.Blacs.down_install_blacs (   self)
 Downloads and installs BLACS libraries 
74  def down_install_blacs(self):
75  """ Downloads and installs BLACS libraries """
76 
77  savecwd = os.getcwd()
78 
79  # creating the build and lib dirs if don't exist
80  if(not os.path.isdir(os.path.join(os.getcwd(),'build'))):
81  os.mkdir(os.path.join(os.getcwd(),'build'))
82 
83  if(not os.path.isdir(os.path.join(os.getcwd(),'lib'))):
84  os.mkdir(os.path.join(os.getcwd(),'lib'))
85 
86  if(not os.path.isdir(os.path.join(os.getcwd(),'log'))):
87  os.mkdir(os.path.join(os.getcwd(),'log'))
88 
89  # chdir into the build directory
90  os.chdir(os.path.join(os.getcwd(),'build'))
91  # checks if mpiblacs.tgz is already present in the current directory
92  # and if not it downloads it
93  if(not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.blacsurl)))):
94  print('Downloading BLACS...', end=' ')
95  downloader(self.blacsurl, self.downcmd)
96  print('done')
97 
98  # unzip and untar
99  print('Unzip and untar BLACS...', end=' ')
100  comm = 'gunzip -f mpiblacs.tgz'
101  (output, error, retz) = runShellCommand(comm)
102  if(retz != 0):
103  print('\n\nBLACS: cannot unzip mpiblacs.tgz')
104  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
105  sys.exit()
106 
107 
108  comm = 'tar xf mpiblacs.tar'
109  (output, error, retz) = runShellCommand(comm)
110  if(retz != 0):
111  print('\n\nBLACS: cannot untar mpiblacs.tgz')
112  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
113  sys.exit()
114  os.remove('mpiblacs.tar')
115  print('done')
116 
117  # goes in the BLACS dir
118  os.chdir(os.path.join(os.getcwd(),'BLACS'))
119 
120  # set TRANSCOMM
121  self.set_transcomm()
122  # write Bmake.inc file
123  self.write_bmake()
124 
125  # compile
126  print('Compiling BLACS...', end=' ')
127  sys.stdout.flush()
128  comm = self.make+' mpi'
129  (output, error, retz) = runShellCommand(comm)
130  if(retz != 0):
131  print('\n\nBLACS: error building BLACS')
132  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
133  sys.exit()
134 
135  # write a log file containing the BLACS compilation output
136  fulllog = os.path.join(savecwd,'log/blacslog')
137  writefile(fulllog, output+error)
138  print('done.')
139  print(' (log is in ',fulllog,')')
140 
141  os.rename('LIB/blacs.a',os.path.join(savecwd,'lib/blacs.a'))
142  os.rename('LIB/blacsC.a',os.path.join(savecwd,'lib/blacsC.a'))
143  os.rename('LIB/blacsF77.a',os.path.join(savecwd,'lib/blacsF77.a'))
144 
145  # sets framework variables to point to the freshly installed BLACS libraries
146  self.blacslib = os.path.join(savecwd,'lib/blacs.a ')
147  self.blacsClib = os.path.join(savecwd,'lib/blacsC.a ')
148  self.blacsF77lib = os.path.join(savecwd,'lib/blacsF77.a ')
149  Frame.blacslib = os.path.join(savecwd,'lib/blacs.a ')
150  Frame.blacsClib = os.path.join(savecwd,'lib/blacsC.a ')
151  Frame.blacsF77lib = os.path.join(savecwd,'lib/blacsF77.a ')
152  os.chdir(savecwd)
153 
154 
155 
156 
157 
158 
def downloader(uri, cmd)
Definition: utils.py:150
def getURLName(url)
Definition: utils.py:137

References framework.Frame.blacsurl, framework.Frame.downcmd, utils.downloader(), utils.getURLName(), if(), Eigen::internal::TensorBlockDescriptor< NumDims, Index >::DestinationBuffer.make(), Eigen::internal::TensorBlockDescriptor< NumDims, IndexType >::DestinationBuffer.make(), framework.Frame.make, Eigen::internal.print(), utils.runShellCommand(), blacs.Blacs.set_transcomm(), blacs.Blacs.write_bmake(), and utils.writefile().

Referenced by blacs.Blacs.__init__().

◆ set_transcomm()

def blacs.Blacs.set_transcomm (   self)
 Sets the TRANSCOMM variable in Bmake.inc 
159  def set_transcomm(self):
160  """ Sets the TRANSCOMM variable in Bmake.inc """
161  # This one compiles few programs equivalent to those in BLACS/INSTALL
162  # in order to set the TRANSCOMM value
163 
164  print('Setting TRANSCOMM...', end=' ')
165  sys.stdout.flush()
166 
167  writefile('tmpf.f',"""
168  program tctst
169  include 'mpif.h'
170  integer i, ierr
171  external Ccommcheck
172  integer Ccommcheck
173 
174  call mpi_init(ierr)
175 
176  i = Ccommcheck(MPI_COMM_WORLD, MPI_COMM_SELF)
177  if (i .ne. 0) then
178  print*,'-DCSameF77'
179  end if
180 
181  call mpi_finalize(ierr)
182 
183  stop
184  end\n""")
185 
186  writefile('tmpc.c',"""
187 #include <mpi.h>
188 
189 int Ccommcheck(int F77World, int f77comm){
190  int Np, Iam, i, OK=1;
191 
192  if (sizeof(int) != sizeof(MPI_Comm)) OK=0;
193  else if ((MPI_Comm) F77World != MPI_COMM_WORLD) OK=0;
194  else {
195  MPI_Comm_rank(MPI_COMM_WORLD, &Iam);
196  i = MPI_Comm_size((MPI_Comm) f77comm, &Np);
197  if (i != MPI_SUCCESS) OK = 0;
198  else if (Np != 1) OK = 0;
199  }
200  return(OK);
201 }
202 int CCOMMCHECK(int *F77World, int *f77comm){ return(Ccommcheck(*F77World, *f77comm));}
203 int ccommcheck_(int *F77World, int *f77comm){return(Ccommcheck(*F77World, *f77comm));}
204 int ccommcheck(int *F77World, int *f77comm){return(Ccommcheck(*F77World, *f77comm));}\n""")
205 
206  ccomm = self.mpicc+' '+self.ccflags+' -c tmpc.c -o tmpc.o'
207  fcomm = self.mpif77+' '+self.fcflags+' tmpf.f tmpc.o -o xtc_CsameF77'
208 
209  (output, error, retz) = runShellCommand(ccomm)
210  if(retz != 0):
211  print('\n\nBLACS: Error in transcomm setting! cannot compile')
212  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
213  sys.exit()
214 
215  (output, error, retz) = runShellCommand(fcomm)
216  if(retz != 0):
217  print('\n\n1BLACS: Error in transcomm setting! cannot compile')
218  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
219  sys.exit()
220 
221  comm = os.path.join(os.getcwd(),'xtc_CsameF77')
222  (output, error, retz) = runShellCommand(comm)
223  #if(retz != 0):
224  # print '\n\nBLACS: Error in transcomm setting! cannot run xtc_CsameF77'
225  # print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
226  # sys.exit()
227 
228  killfiles(['tmpf.f', 'tmpc.c', 'tmpc.o', 'xtc_CsameF77'])
229 
230  self.transcomm = output
231 
232 
233  if(self.transcomm == ''):
234  writefile('tmpc.c',"""
235  #include <stdio.h>
236  #include <mpi.h>
237  main(){
238  MPI_Comm ccomm;
239  int fcomm;
240  extern void *MPIR_ToPointer();
241  extern int MPIR_FromPointer();
242  extern void *MPIR_RmPointer();
243 
244  if (sizeof(int) < sizeof(int*)) {
245  fcomm = MPIR_FromPointer(MPI_COMM_WORLD);
246  ccomm = (MPI_Comm) MPIR_ToPointer(fcomm);
247  if (ccomm == MPI_COMM_WORLD)
248  fprintf(stdout,\" -DUseMpich -DPOINTER_64_BITS=1\");
249  }
250  return 0;
251  }\n""")
252 
253  ccomm = self.mpicc+' '+self.ccflags+' tmpc.c -o UseMpich'
254  (output, error, retz) = runShellCommand(ccomm)
255  if(retz != 0):
256  print(self.transcomm)
257  return 1;
258 
259  comm = os.path.join(os.getcwd(),'UseMpich')
260  (output, error, retz) = runShellCommand(comm)
261  if(retz != 0):
262  print('\n\nBLACS: Error in transcomm setting! cannot run UseMpich')
263  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
264  sys.exit()
265 
266  killfiles(['tmpc.c','UseMpich'])
267  self.transcomm = output
268 
269 # Testing MPI2 implementation
270  if(self.transcomm == ''):
271  writefile('tmpc.c',"""
272  #include <stdio.h>
273  #include <mpi.h>
274  int main(int argc, char** argv)
275  {
276  int version, subversion;
277  MPI_Init(&argc, &argv);
278  MPI_Get_version(&version, &subversion);
279  if (version==2) fprintf(stdout,\" -DUseMpi2\");
280  MPI_Finalize();
281  return 0;
282  }\n""")
283 
284  ccomm = self.mpicc+' '+self.ccflags+' tmpc.c -o UseMPI2'
285  (output, error, retz) = runShellCommand(ccomm)
286  if(retz != 0):
287  print(self.transcomm)
288  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
289  sys.exit()
290 
291  comm = os.path.join(os.getcwd(),'UseMPI2')
292  (output, error, retz) = runShellCommand(comm)
293  if(retz != 0):
294  print('\n\nBLACS: Error in transcomm setting! cannot run UseMPI2')
295  print('stderr:\n','*'*40,'\n',error,'\n','*'*40)
296  sys.exit()
297 
298  killfiles(['tmpc.c','UseMPI2'])
299  self.transcomm = output
300 
301  print(self.transcomm)
302 
303 
304  return 1;
305 
306 

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

Referenced by blacs.Blacs.down_install_blacs().

◆ write_bmake()

def blacs.Blacs.write_bmake (   self)
 Writes the Bmake.inc file for BLACS installation 
307  def write_bmake(self):
308  """ Writes the Bmake.inc file for BLACS installation """
309  print('Writing Bmake.inc...', end=' ')
310  sys.stdout.flush()
311  writefile('Bmake.inc',"""
312 SHELL = /bin/sh
313 BTOPdir = """+os.getcwd()+"""
314 COMMLIB = MPI
315 PLAT =
316 BLACSdir = $(BTOPdir)/LIB
317 BLACSDBGLVL = 0
318 BLACSFINIT = $(BLACSdir)/blacsF77.a
319 BLACSCINIT = $(BLACSdir)/blacsC.a
320 BLACSLIB = $(BLACSdir)/blacs.a
321 
322 MPIINCdir = """+self.mpiincdir+"""
323 MPILIB =
324 
325 BTLIBS = $(BLACSFINIT) $(BLACSLIB) $(BLACSFINIT) $(MPILIB)
326 INSTdir = $(BTOPdir)/INSTALL/EXE
327 TESTdir = $(BTOPdir)/TESTING/EXE
328 FTESTexe = $(TESTdir)/xFbtest_$(COMMLIB)-$(PLAT)-$(BLACSDBGLVL)
329 CTESTexe = $(TESTdir)/xCbtest_$(COMMLIB)-$(PLAT)-$(BLACSDBGLVL)
330 SYSINC = -I$(MPIINCdir)
331 INTFACE = """+self.mangling+"""
332 SENDIS =
333 BUF =
334 TRANSCOMM = """+self.transcomm+"""
335 WHATMPI =
336 SYSERRORS =
337 DEBUGLVL = -DBlacsDebugLvl=$(BLACSDBGLVL)
338 DEFS1 = -DSYSINC $(SYSINC) $(INTFACE) $(DEFBSTOP) $(DEFCOMBTOP) $(DEBUGLVL)
339 BLACSDEFS = $(DEFS1) $(SENDIS) $(BUFF) $(TRANSCOMM) $(WHATMPI) $(SYSERRORS)
340 
341 F77 = """+self.mpif77+"""
342 F77NO_OPTFLAGS = """+self.noopt+"""
343 F77FLAGS = $(F77NO_OPTFLAGS) """+self.fcflags+"""
344 F77LOADER = $(F77)
345 F77LOADFLAGS = """+self.ldflags_f77+"""
346 CC = """+self.mpicc+"""
347 CCFLAGS = """+self.ccflags+"""
348 CCLOADER = $(F77)
349 CCLOADFLAGS = """+self.ldflags_c+"""
350 ARCH = ar
351 ARCHFLAGS = r
352 RANLIB = """+self.ranlib+"""
353  """)
354  print('done.')
355  return 1;
356 

References framework.Frame.ccflags, framework.Frame.fcflags, framework.Frame.ldflags_c, framework.Frame.ldflags_f77, framework.Frame.mangling, framework.Frame.mpicc, framework.Frame.mpif77, framework.Frame.mpiincdir, framework.Frame.noopt, Eigen::internal.print(), framework.Frame.ranlib, blacs.Blacs.transcomm, and utils.writefile().

Referenced by blacs.Blacs.down_install_blacs().

Member Data Documentation

◆ blacsClib

◆ blacsF77lib

◆ blacslib

◆ transcomm

blacs.Blacs.transcomm

Referenced by blacs.Blacs.write_bmake().


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