예제 #1
0
파일: sdk.py 프로젝트: llinder/gaeenv
def download(version=None):
	"""
    Download App Engine SDK
    """
	if not version:
		version = get_latest_version()
	if type(version) is str:
		version = tuple(version.split('.'))

	response = requests.get('https://storage.googleapis.com/appengine-sdks')
	response.raise_for_status()
	tree = ET.fromstring(response.text)

	path = None
	for key in tree.iter('{http://doc.s3.amazonaws.com/2006-03-01}Key'):
		match = re.match('^.*google_appengine_{0}.{1}.{2}\.zip$'.format(*version), key.text)
		if match:
			path = key.text
			break

	url = 'https://storage.googleapis.com/appengine-sdks/{path}'.format(**locals())

	logger.debug(' * Starting SDK download for version {0}.{1}.{2}'.format(*version))
	response = requests.get(url)
	response.raise_for_status()

	temp_zip = os.path.join(gettempdir(), 'google_appengine_{0}.{1}.{2}.zip'.format(*version))
	writefile(temp_zip, response.content, encode=None)
	return temp_zip
예제 #2
0
파일: build.py 프로젝트: yanni4night/ursa2
    def _html(self):
        '''
        generate html

        HTML直接以输出好的模板文件做渲染。

        由于数据原因个别子模板单独渲染会失败,这里用{html_force_output}变量
        可以跳过这类模板。

        TODO:考虑支持require_html_modules
        '''
        fs = utils.FileSearcher(r'\.%s$'%C('template_ext'),self._build_tpl_dir)
        tpls = fs.search()
        for tpl in tpls:
            if C('ignore_parents') and tpl.endswith('parent.'+C('template_ext')):
                continue
            try:
                tr = TokenRender(re.sub(r'\.%s$'%C('template_ext'),'',tpl))
                html = tr.render( build = True)
                target_dir= os.path.join(self._build_html_dir,os.path.dirname(tpl))
                if not os.path.exists(target_dir):
                    os.makedirs(target_dir)
                dst_file = re.sub(r'\.%s$'%C('template_ext'),'.html',os.path.join(self._build_html_dir,tpl))
                utils.writefile(dst_file,html)
            except Exception,e:
                if not C('html_force_output') and not self._force:
                    raise e
                else:
                    log.error(e)
예제 #3
0
def handleFile (f, outdir, parser, config, verbose=False):
    """Translate a wiki file with name f to the corresponding LaTeX file.

    Information where and how to translate are giving in config. Parser is
    a parser object for the correct wiki style.

    Exception: if the filename contains bibtex in some capitalization, we append .bib, not .tex. 
    """

    if re.search ('bibtex', f, re.IGNORECASE):
        suffix = ".bib"
    else:
        suffix = ".tex"
        
    fileName = os.path.basename(f)
    inputDir = os.path.dirname(f)
    if verbose:
        print "Generating LaTeX from wiki file " + fileName  + " in dir: " + inputDir
        print " and storing it in " + outdir + " as path " + os.path.join (outdir, fileName)+suffix

    # caution: we have to open that as UTF-8 files!
    wiki = codecs.open (f, 'r', 'utf-8').read()

    # if verbose:
    #     print wiki
    #     print parser.getLaTeX (wiki)

    utils.writefile (parser.getLaTeX (wiki, fileName), os.path.join (outdir, fileName+suffix))
예제 #4
0
파일: build.py 프로젝트: yanni4night/ursa2
    def _tpl(self):
        '''
        handle tempaltes

        模板仅需加时间戳和变量替换。

        这里需要加入额外的{compile_dir}文件夹下的文本文件。
        '''
        fs = utils.FileSearcher(r'\.%s$'%C('template_ext'),self._build_tpl_dir,relative = False)
        tpls = fs.search()
        if self._compile_dir:
            nfs = utils.FileSearcher(r'.+',self._build_compile_dir,relative = False)
            compile_files = nfs.search()
            for f in compile_files:
                if not utils.isBinary(f):
                    tpls.insert(0,f)

        for tpl in tpls:
            try:
                content = utils.readfile(tpl)
                #模板的静态资源相对目录应该写死为cwd,即资源路径应该始终是绝对路径
                content = allt(content,self._build_dir,force_abspath = False)
                content = replace(content,self._target)
                content = removeCssDepsDeclaration(content)
                utils.writefile(tpl,content)
            except Exception,e:
                if self._force:
                    log.error('[tpl]%s'%e)
                else:
                    raise e
예제 #5
0
파일: framework.py 프로젝트: randyp/randyp
    def check_linking(self):
        """ Check if C main can be linked to Fortran subroutine """

        # This one checks if the linking command works out of the box or
        # if any specific flag is required. For example if the linker if the
        # Intel FORTRAN compiler, then the "-nofor_main" is usually required.
        # This function only checks if linker works but does not automatically
        # detect the required flags
        print 'Checking loader...',
        sys.stdout.flush()
        writefile('tmpf.f',"""
      subroutine fsub()
      write(*,*)'success'
      stop
      end\n""")
        writefile('tmpc.c',"""
      #if defined ADD_
      #define fsub fsub_
      #elif defined NOCHANGE
      #define fsub fsub
      #elif defined fcIsF2C
      #define fsub fsub_
      #elif defined UPCASE
      #define fsub FSUB
      #endif
      void main(){
      fsub();}\n""")

        ccomm = self.config.cc+' '+self.config.ccflags+' '+self.mangling+' -c -o tmpc.o tmpc.c'
        fcomm = self.config.fc+' '+self.config.fcflags+' -c -o tmpf.o tmpf.f'
        lcomm = self.config.fc+' '+self.config.ldflags_fc+' '+self.config.ld_fcmain+' -o lnk tmpf.o tmpc.o'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ',ccomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ',fcomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(lcomm)
        if retz:
            print """\n\nCOMMON: in check_linking: cannot link
            Cannot link a C main program to a Fortran77 subroutine
            Make sure that the appropriate flags are passed to the linker."""
            print 'command is: ',lcomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()


        killfiles(['lnk', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print 'works'
        return 1;
예제 #6
0
파일: build.py 프로젝트: yanni4night/ursa2
    def _css(self):
        '''
        handle css

        r.js会对不同目录下CSS合并时的URL进行修正,因而对于@something@开头的路径会被认为是相对路径,
        产生修正错误,解决方案是先对所有CSS文件进行变量替换,时间戳添加,再由r.js合并。这会降低处理速
        度但可以解决该问题。

        考虑到速度,此过程仅支持在build时进行,开发服务器访问时不能使用。

        所有静态资源路径都应该使用绝对路径,避免在CSS中引用相对路径的图像资源。
        '''

        #搜索所有CSS文件
        all_css_files = utils.FileSearcher(r'\.css$',self._build_css_dir,relative = False).search()

        #替换和加时间戳
        for dst in all_css_files:
            try:
                content = utils.readfile(dst)
                content = all_url(content,os.path.dirname(dst))
                content = replace(content,self._target)
                utils.writefile(dst,content)
            except Exception,e:
                if self._force:
                    log.error('[css]%s'%e)
                else:
                    raise e
예제 #7
0
def workpackageXML(wiki, parser, verbose=False):
    """Produce the workpackage-related XML structure.
    - The include commands in the project-wide XML
    - The per-workpackage XML
    """

    wplist = parser.getList(parser.getSection (wiki, "Workpackages", 2))
    # print wplist

    wpIncluder = "" 
    t = "<workpackages>\n"
    for wp in wplist:
        t += "#include<wp/" + wp + ".xml>\n"
    t+="</workpackages>\n"

    # and generate the individual wps:
    wpCount = 1
    for wp in wplist:
        if verbose:
            print "now parsing into XML of workpackage : " + wp 
        import codecs 
        wpwiki = codecs.open(os.path.join(config.get('PathNames', 'wikiwppath'),
                                   wp),
                      'r', 'utf-8').read()
        # print type(wpwiki)
        wpMain = singleWorkpackageXML (wp, wpwiki, parser, wpCount)
        # pp(wpMain)
        wpCount += 1 
        wpIncluder += "\\input{wp/Wp_"+ wpMain['Shortname'] + ".tex}\n \n"

    utils.writefile (wpIncluder, 
                     os.path.join(config.get('PathNames', 'genlatexwppath'),
                                  'wpIncluder.tex'))
    
    return t
예제 #8
0
def handleFile(f, outdir, parser, config, verbose=False):
    """Translate a wiki file with name f to the corresponding LaTeX file.

    Information where and how to translate are giving in config. Parser is
    a parser object for the correct wiki style.

    Exception: if the filename contains bibtex in some capitalization, we append .bib, not .tex. 
    """

    if re.search('bibtex', f, re.IGNORECASE):
        suffix = ".bib"
    else:
        suffix = ".tex"

    fileName = os.path.basename(f)
    inputDir = os.path.dirname(f)
    if verbose:
        print "Generating LaTeX from wiki file " + fileName + " in dir: " + inputDir
        print " and storing it in " + outdir + " as path " + os.path.join(
            outdir, fileName) + suffix

    # caution: we have to open that as UTF-8 files!
    wiki = codecs.open(f, 'r', 'utf-8').read()

    # if verbose:
    #     print wiki
    #     print parser.getLaTeX (wiki)

    utils.writefile(parser.getLaTeX(wiki, fileName),
                    os.path.join(outdir, fileName + suffix))
예제 #9
0
def test_remote_feedback_not_overwriting_local_changes(dynsync, local_dir, remote_dir):
    import time
    time.sleep(1)
    filepath = join(local_dir, "file")
    writefile(filepath, byte_count=100)
    wait_dirs_equal(local_dir, remote_dir)
    assert getsize(filepath) == 100
예제 #10
0
파일: jaeschke.py 프로젝트: pchelkanat/spsp
def screen_by_t(a_base, B, t, equal_list):
    clearfile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt")

    ### Посчет времени работы
    start_time = time.time()
    ###

    screening_list = []
    for item in equal_list:  # item - простые числа с одинаковой сигнатурой
        if len(item.primes) >= t - 1 and item.primes[0] > a_base[-1]:
            # берем больше, так как позже будем проверять по группам p1*p2*...*p(t-1)^2<B
            combine = combinations(item.primes, t - 1)  # в порядке возрастания
            for prms in combine:
                prod = np.prod(prms) * prms[-1]
                if prod < B:
                    screening_list.append(Signature(item.sign, prms))

    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ### Запись в файл
    for j in range(len(screening_list)):
        s = f"{j}    {screening_list[j].sign}     {screening_list[j].primes}\n"
        writefile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt", s)
    writefile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt", total_time)

    return screening_list
예제 #11
0
def step1(a_base, primes):
    clearfile(f"lib/mu/{a_base}/total_time.txt")
    ### Посчет времени работы
    start_time = time.time()
    ###
    primes_dict = {}
    for prime in primes[len(a_base):]:
        mu = Mu_p(a_base, prime)
        print(prime, mu)
        # if mu == 1:
        #    continue
        if mu in primes_dict.keys():
            primes_dict[mu].append(prime)
        else:
            primes_dict[mu] = [prime]

    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    tot_s = total_time
    writefile(f"lib/mu/{a_base}/total_time.txt", tot_s)

    for item in primes_dict:
        clearfile(f"lib/mu/{a_base}/mu_{item}.txt")
        s = ''.join(
            str(l) + ' ' + '\n' * (n % 8 == 7)
            for n, l in enumerate(primes_dict[item]))
        writefile(f"lib/mu/{a_base}/mu_{item}.txt", s)

    return primes_dict
예제 #12
0
    def write_slmakeinc(self):
        """ Writes the SLmake.inc file for ScaLAPACK installation """

        sdir = os.getcwd()
        print 'Writing SLmake.inc...',
        sys.stdout.flush()
        writefile(
            'SLmake.inc', """
#
#  C preprocessor definitions:  set CDEFS to one of the following:
#
#     -DNoChange (fortran subprogram names are lower case without any suffix)
#     -DUpCase   (fortran subprogram names are upper case without any suffix)
#     -DAdd_     (fortran subprogram names are lower case with "_" appended)

CDEFS         = """ + self.mangling + """

#
#  The fortran and C compilers, loaders, and their flags
#

FC            = """ + self.config.mpif90 + """ -fallow-argument-mismatch
CC            = """ + self.config.mpicc + """
NOOPT         = """ + self.config.noopt + """
FCFLAGS       = """ + self.config.fcflags + """
CCFLAGS       = """ + self.config.ccflags + """
SRCFLAG       =
FCLOADER      = $(FC)
CCLOADER      = $(CC)
FCLOADFLAGS   = """ + self.config.ldflags_fc + """
CCLOADFLAGS   = """ + self.config.ldflags_c + """

#
#  The archiver and the flag(s) to use when building archive (library)
#  Also the ranlib routine.  If your system has no ranlib, set RANLIB = echo
#

ARCH          = ar
ARCHFLAGS     = cr
RANLIB        = """ + self.config.ranlib + """

#
#  The name of the ScaLAPACK library to be created
#

SCALAPACKLIB  = libscalapack.a

#
#  BLAS, LAPACK (and possibly other) libraries needed for linking test programs
#

BLASLIB       = """ + self.config.blaslib + """
LAPACKLIB     = """ + self.config.lapacklib + """
LIBS          = $(LAPACKLIB) $(BLASLIB)
        """)

        self.scalapackdir = sdir
        print 'done.'
예제 #13
0
파일: build.py 프로젝트: chshouyu/ursa
def compileCss():
    """为所有css文件内部的图片引用加上时间戳
    """
    base = os.path.join(PATH , 'build' , 'static' , 'css')
    cssfiles = []
    for dirpath , dirnames, filenames in os.walk(base):
        cssfiles.extend( [ os.path.join(dirpath , f) for f in filenames if f.endswith('.css') ] )
    for css in cssfiles:
        f = parser.compileCss(css)
        utils.writefile(css , f)
예제 #14
0
파일: build.py 프로젝트: chshouyu/ursa
def compileCommon(token):
    """
    """
    base = os.path.join(PATH , 'build' )
    files = []
    for dirpath , dirnames, filenames in os.walk(base):
        files.extend( [ os.path.join(dirpath , f) for f in filenames ] )
    for fi in files:
        f = parser.compileCommon(fi , token)
        if f:
            utils.writefile(fi , f)
예제 #15
0
    def check_blas(self):

        print "Checking if provided BLAS works...",
        # This function simply generates a FORTRAN program
        # that contains few calls to BLAS routine and then
        # checks if compilation, linking and execution are succesful

        # Try to detect which BLAS is used
        if re.search('mkl', self.config.blaslib, re.IGNORECASE):
            self.config.blasname = "mkl"
        elif re.search('acml', self.config.blaslib, re.IGNORECASE):
            self.config.blasname = "acml"

        if self.config.blasname != "Unknown":
            if self.config.compiler == "Intel":
                self.config.cflags += ''  #" -openmp"
        #        self.config.ldflags_c  += " -openmp"
        #        self.config.ldflags_fc += " -openmp"
            elif self.config.compiler == "GNU":
                self.config.cflags += ''  #" -fopenmp"
        #        self.config.ldflags_c  += " -fopenmp"
        #        self.config.ldflags_fc += " -fopenmp"

        sys.stdout.flush()
        writefile(
            'tmpf.f', """
      program ftest
      double precision da, dx(1)
      dx(1)=1
      da = 2
      call dscal(1,da,dx,1)
      stop
      end\n""")

        #fcomm = self.config.fc+' -o tmpf '+'tmpf.f '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
        fcomm = self.config.fc + ' -o tmpf ' + 'tmpf.f ' + self.config.blaslib + ' -lm'
        (output, error, retz) = shellcmd(fcomm)

        if (retz != 0):
            print '\n\nBLAS: provided BLAS cannot be used! aborting...'
            print 'error is:\n', '*' * 50, '\n', fcomm, '\n', error, '\n', '*' * 50
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = shellcmd(comm)
        if (retz != 0):
            print '\n\nBLAS: provided BLAS cannot be used! aborting...'
            print 'error is:\n', '*' * 50, '\n', comm, '\n', error, '\n', '*' * 50
            sys.exit()

        delfiles(['tmpf.f', 'tmpf'])
        print 'yes'

        return 0
예제 #16
0
파일: cblas.py 프로젝트: mawussi/BBLAS-ref
    def check_cblas(self):

        print "Checking if provided CBLAS works...",
        # This function simply generates a C program
        # that contains few calls to CBLAS routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile(
            'tmpc.c', """
int main(int argc, char*agv[]) {
  double da    = 2.0;
  double dx[2] = {1.0, 2.0};
  cblas_dscal(2, da, dx, 1);
  return 0;
}
\n""")

        ccomm = self.config.cc + ' -o tmpc.o ' + '-c tmpc.c ' + self.config.ccflags
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        ccomm = self.config.fc + ' -o tmpc ' + 'tmpc.o ' + self.config.fcflags + ' ' + self.config.cblaslib + ' ' + self.config.blaslib + ' ' + self.config.ldflags_fc + ' ' + self.config.ld_fcmain + ' -lm'
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        killfiles(['tmpc.o', 'tmpc.c', 'tmpc'])
        print 'yes'

        return 0
예제 #17
0
def compileCommon(token):
    """
    """
    base = os.path.join(PATH, 'build')
    files = []
    for dirpath, dirnames, filenames in os.walk(base):
        files.extend([os.path.join(dirpath, f) for f in filenames])
    for fi in files:
        f = parser.compileCommon(fi, token)
        if f:
            utils.writefile(fi, f)
예제 #18
0
def compileCss():
    """为所有css文件内部的图片引用加上时间戳
    """
    base = os.path.join(PATH, 'build', 'static', 'css')
    cssfiles = []
    for dirpath, dirnames, filenames in os.walk(base):
        cssfiles.extend([
            os.path.join(dirpath, f) for f in filenames if f.endswith('.css')
        ])
    for css in cssfiles:
        f = parser.compileCss(css)
        utils.writefile(css, f)
예제 #19
0
파일: cblas.py 프로젝트: randyp/randyp
    def check_cblas(self):

        print "Checking if provided CBLAS works...",
        # This function simply generates a C program
        # that contains few calls to CBLAS routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
int main(int argc, char*agv[]) {
  double da    = 2.0;
  double dx[2] = {1.0, 2.0};
  cblas_dscal(2, da, dx, 1);
  return 0;
}
\n""")

        ccomm = self.config.cc+' -o tmpc.o '+'-c tmpc.c '+self.config.ccflags
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ccomm = self.config.fc+' -o tmpc '+'tmpc.o '+self.config.fcflags+' '+self.config.cblaslib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' '+self.config.ld_fcmain+' -lm'
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o', 'tmpc.c','tmpc'])
        print 'yes'

        return 0;
예제 #20
0
파일: lapcwrapper.py 프로젝트: pjzuk/GRPY
    def check_lapc(self):

        print "Checking if provided LAPACK C interface works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK C interface routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
#include <lapacke.h>
int main(int argc, char*agv[]) {
  double eps;
  eps = LAPACKE_dlamch('e');
  LAPACKE_dlatms_work(0, 0, 0, 'A', NULL, 'A', NULL, 0, 0., 0., 0, 0, 'A', NULL, 0, NULL );
  return 0;
}
\n""")

        ccomm = self.config.cc+' '+self.config.ldflags_c+' -o tmpc.o -c tmpc.c '+self.config.lapackinc
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ldflg = self.config.ld_fcmain+' '+self.config.ldflags_fc+' '+self.config.lapclib+' '+self.config.lapacklib+' '+self.config.blaslib+' -lm'
        ccomm = self.config.fc+' -o tmpc tmpc.o '+ldflg
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o','tmpc.c','tmpc'])
        print 'yes'

        return 0;
예제 #21
0
def getWorkpackages(masterPage, pullInstance, config, parser, verbose=False):
    """Identify all the workpackages and download them"""

    t = parser.getSection(masterPage, "Workpackages", 2)
    pages = parser.getList(t)

    for p in pages:
        if verbose:
            print "Now pulling workpackge: " + p
        t = pullInstance.getPage(p)
        utils.writefile(t,
                        os.path.join(config.get("PathNames", "wikiwppath"), p))
예제 #22
0
def getWorkpackages (masterPage, pullInstance, config, parser, verbose=False):
    """Identify all the workpackages and download them""" 

    t = parser.getSection(masterPage, "Workpackages", 2)
    pages = parser.getList (t)

    for p in pages:
        if verbose:
            print "Now pulling workpackge: " + p
        t = pullInstance.getPage (p)
        utils.writefile (t,
                         os.path.join(config.get("PathNames", "wikiwppath"), p))
예제 #23
0
def getProposalStructure (masterPage, pullInstance, config, parser, verbose=False):
    """Extract all the relevant files for the actual proposal text from the wiki."""

    t = parser.getSection(masterPage, "Proposal structure", 2)
    pages = parser.getList (t)

    for p in pages:
        if verbose:
            print "Now pulling page: "  + p
        t = pullInstance.getPage (p)
        utils.writefile (t,
                         os.path.join(config.get("PathNames", "wikipath"), p))
예제 #24
0
    def check_lapc(self):

        print "Checking if provided LAPACK C interface works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK C interface routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
#include <lapacke.h>
int main(int argc, char*agv[]) {
  double eps;
  eps = LAPACKE_dlamch('e');
  return 0;
}
\n""")

        ccomm = self.config.cc+' '+self.config.ldflags_c+' -o tmpc.o -c tmpc.c '+self.config.lapackinc
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ldflg = self.config.ld_fcmain+' '+self.config.ldflags_fc+' '+self.config.lapclib+' '+self.config.lapacklib+' '+self.config.blaslib+' -lm'
        ccomm = self.config.fc+' -o tmpc tmpc.o '+ldflg
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o','tmpc.c','tmpc'])
        print 'yes'

        return 0;
예제 #25
0
    def set_mangling(self):
        """ Sets the INTFACE variable in Bmake.inc """
        # This one generates a program equivalent to that in BLACS/INSTALL
        # that checks the mangling in FORTRAN function symbols
        print 'Setting Fortran mangling...',
        sys.stdout.flush()
        writefile(
            'tmpf.f', """
      program intface
      external c_intface
      integer i
      call c_intface(i)
      stop
      end\n""")
        writefile(
            'tmpc.c', """
      #include <stdio.h>
      void c_intface_(int *i){fprintf(stdout, \"-DADD_\");fflush(stdout);}
      void c_intface(int *i){fprintf(stdout, \"-DNOCHANGE\");fflush(stdout);}
      void c_intface__(int *i){fprintf(stdout, \"-DfcIsF2C\");fflush(stdout);}
      void C_INTFACE(int *i){fprintf(stdout, \"-DUPCASE\");fflush(stdout);}\n"""
        )

        ccomm = self.config.cc + ' ' + self.config.cflags + ' -c tmpc.c -o tmpc.o'
        fcomm = self.config.fc + ' ' + self.config.fflags + '  tmpf.f tmpc.o -o xintface'

        (output, error, retz) = shellcmd(ccomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            #sys.exit()

        (output, error, retz) = shellcmd(fcomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            #sys.exit()

        comm = os.path.join(os.getcwd(), 'xintface')
        (output, error, retz) = shellcmd(comm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot run xintface'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            #sys.exit()

        self.mangling = output
        delfiles(['xintface', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print self.mangling
        return 1
예제 #26
0
    def check_tmg(self):

        print "Checking if provided LAPACK works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile(
            'tmpf.f', """
      program ftest
        double precision D(1), A(1:1), B(2)
        integer          ISEED( 4 )
        integer          INFO
        B(1)   = 1

        do  I = 1, 4
            ISEED( I ) = 1
        enddo
        call dlarnv( 1, ISEED, 1, D )
        call dlagsy( 1, 0, D, A, 1, ISEED, B, INFO )
        stop
      end\n""")

        ldflg = self.config.cblaslib + ' ' + self.config.lapacklib + ' ' + self.config.blaslib + ' ' + self.config.ldflags_fc
        ccomm = self.config.fc + ' -o tmpf ' + 'tmpf.f ' + ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if (retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            sys.exit()

        killfiles(['tmpf.f', 'tmpf'])
        print 'yes'

        return 0
예제 #27
0
def getPartners(masterPage, pullInstance, config, parser, verbose=False):
    """get all the partner description files"""

    t = parser.getSection(masterPage, "Partner data", 2)
    table = parser.getTable(t)
    # pp(table)

    for p in table:
        pw = str(p['Wiki'])
        if verbose:
            print "Now pulling partner: " + pw
        t = pullInstance.getPage(pw)
        utils.writefile(
            t, os.path.join(config.get("PathNames", "wikipartnerpath"), pw))
예제 #28
0
def getPartners (masterPage, pullInstance, config, parser, verbose=False):
    """get all the partner description files"""

    t = parser.getSection(masterPage, "Partner data", 2)
    table = parser.getTable (t) 
    # pp(table)

    for p in table:
        pw = str(p['Wiki'])
        if verbose:
            print "Now pulling partner: " + pw 
        t = pullInstance.getPage (pw)
        utils.writefile (t,
                         os.path.join(config.get("PathNames", "wikipartnerpath"), pw))
예제 #29
0
파일: tmg.py 프로젝트: randyp/randyp
    def check_tmg(self):

        print "Checking if provided LAPACK works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpf.f',"""
      program ftest
        double precision D(1), A(1:1), B(2)
        integer          ISEED( 4 )
        integer          INFO
        B(1)   = 1

        do  I = 1, 4
            ISEED( I ) = 1
        enddo
        call dlarnv( 1, ISEED, 1, D )
        call dlagsy( 1, 0, D, A, 1, ISEED, B, INFO )
        stop
      end\n""")

        ldflg = self.config.cblaslib+' '+self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc
        ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            sys.exit()

        killfiles(['tmpf.f','tmpf'])
        print 'yes'

        return 0;
예제 #30
0
def getProposalStructure(masterPage,
                         pullInstance,
                         config,
                         parser,
                         verbose=False):
    """Extract all the relevant files for the actual proposal text from the wiki."""

    t = parser.getSection(masterPage, "Proposal structure", 2)
    pages = parser.getList(t)

    for p in pages:
        if verbose:
            print "Now pulling page: " + p
        t = pullInstance.getPage(p)
        utils.writefile(t, os.path.join(config.get("PathNames", "wikipath"),
                                        p))
예제 #31
0
파일: framework.py 프로젝트: randyp/randyp
    def set_mangling(self):
        """ Sets the INTFACE variable in Bmake.inc """
        # This one generates a program equivalent to that in BLACS/INSTALL
        # that checks the mangling in FORTRAN function symbols
        print 'Setting Fortran mangling...',
        sys.stdout.flush()
        writefile('tmpf.f',"""
      program intface
      external c_intface
      integer i
      call c_intface(i)
      stop
      end\n""")
        writefile('tmpc.c',"""
      #include <stdio.h>
      void c_intface_(int *i){fprintf(stdout, \"-DADD_\");fflush(stdout);}
      void c_intface(int *i){fprintf(stdout, \"-DNOCHANGE\");fflush(stdout);}
      void c_intface__(int *i){fprintf(stdout, \"-DfcIsF2C\");fflush(stdout);}
      void C_INTFACE(int *i){fprintf(stdout, \"-DUPCASE\");fflush(stdout);}\n""")

        ccomm = self.config.cc+' '+self.config.ccflags+' -c tmpc.c -o tmpc.o'
        fcomm = self.config.fc+' '+self.config.fcflags+' '+self.config.ldflags_fc+' tmpf.f tmpc.o -o xintface'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        comm = os.path.join(os.getcwd(),'xintface')
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot run xintface'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        self.mangling = output
        killfiles(['xintface', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print self.mangling
        return 1;
예제 #32
0
파일: build.py 프로젝트: yanni4night/ursa2
 def _replace(self):
     '''
     替换所有文本的变量
     '''
     files = utils.FileSearcher(r'.+',self._build_dir).search()
     for f in files:
         f = os.path.join(self._build_dir,f)
         if not utils.isBinary(f):
             try:
                 content = utils.readfile(f)
                 content = replace(content,self._target)
                 utils.writefile(f,content)
             except Exception,e:
                 if self._force:
                     log.error('[replace][%s]%s'%(f,e))
                 else:
                     e
예제 #33
0
def step0(Q11):
    clearfile(f"lib/free_sqr.txt")
    start_time = time.time()
    free_sqr = []
    for n in range(3, Q11, 2):
        print(n)
        arr = numth.factorization(n)
        power = 1
        for i in range(len(arr)):
            power *= arr[i][1]
        if power == 1:
            free_sqr.append(n)
            writefile(f"lib/free_sqr.txt", f"{n} ")
    total_time = "\n--- %s seconds ---\n" % (time.time() - start_time)
    writefile(f"lib/free_sqr.txt", total_time)

    return free_sqr
예제 #34
0
파일: build.py 프로젝트: yanni4night/ursa2
    def build_js(self,src,dst,base_dir):
        '''
        handle one js src to dst

        合并、替换、加时间戳并按需压缩。
        '''
        js = os.path.relpath(src,base_dir)
        subprocess.call( 'node ' + RJS_PATH +' -o name=' + js[0:-3] + ' out='+ dst + ' optimize=none baseUrl='\
            + base_dir , shell = True)
        #repalce
        content = utils.readfile(dst)
        content = replace(content,self._target)
        utils.writefile(dst,content)
        if C('js_ascii_only'):
            subprocess.call( 'node ' + RPL_PATH +' '+dst+' '+dst,shell = True)
        if self._compress:
            subprocess.call( 'java -jar ' + YC_PATH + ' --type js --charset ' + C('encoding') + ' ' + dst + ' -o ' + dst , shell = True )
예제 #35
0
파일: jaeschke.py 프로젝트: pchelkanat/spsp
def t_more_3(a_base, B, t, primes_list):
    clearfile(f"res/jae/{t}/{a_base}/spsp_{B}.txt")
    spsp = []
    ### Посчет времени работы
    start_time = time.time()
    ###
    i = 1
    equal_list = parsefile(f"lib/equal/{a_base}/equal_signs.txt")

    for item in equal_list:  # item - простые числа с одинаковой сигнатурой
        if len(item.primes) >= t - 1 and item.primes[0] > a_base[-1]:
            # берем больше, так как позже будем проверять по группам p1*p2*...*p(t-1)^2<B
            combine = combinations(item.primes, t - 1)  # в порядке возрастания
            for prms in combine:
                prod = np.prod(prms)
                if prod * prms[-1] < B:
                    a = a_base[0]
                    mu = Lambda_list([a], prms)
                    if gcd(mu, prod) > 1:
                        continue
                    else:
                        import gmpy2
                        c = gmpy2.powmod(prod, -1, mu)
                        for pt in primes_list:
                            if pt > prms[
                                    -1] and pt <= B / prod and pt % mu == c:
                                if psp(a_base, pt * prod) and check_signs(
                                        a_base, [pt, prms[-1]]):
                                    item = Signature(Sign(a_base, pt),
                                                     prms + [pt])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/{t}/{a_base}/spsp_{B}.txt",
                                        s)
                                    i += 1
                                    spsp.append(item)

                else:
                    break  # к другому item'у т.к. combine упорядочен вертикально и горизонтально

    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###
    writefile(f"res/jae/{t}/{a_base}/spsp_{B}.txt", total_time)
    return spsp
예제 #36
0
def compileHTML(needCompress=False, needHtml=False):
    """为所有tpl文件加上时间戳
    """
    base = os.path.join(PATH, 'build', 'template')
    tplfiles = []
    for dirpath, dirnames, filenames in os.walk(base):
        tplfiles.extend([
            os.path.join(dirpath, f) for f in filenames if f.endswith('.tpl')
        ])
    if COMPILE_FOLDER:
        for dirpath, dirnames, filenames in os.walk(
                os.path.join(PATH, 'build', COMPILE_FOLDER)):
            tplfiles.extend([os.path.join(dirpath, f) for f in filenames])

    for tpl in tplfiles:
        f = parser.compileHTML(tpl, needCompress)
        utils.writefile(tpl, f)

    if needHtml:
        log.log('Render html file.\nIt will under build folder.')
        files = os.listdir(os.path.join(base))
        tplfiles = []
        for dirpath, dirnames, filenames in os.walk(base):
            tplfiles.extend([
                os.path.join(dirpath, f) for f in filenames
                if f.endswith('.tpl')
            ])
        for fname in tplfiles:
            token = fname.replace(base + '/', '').replace('.tpl', '')
            try:  #有强行编译的需求
                html = parser.parseTpl(token, isbuild=True)

                if token.find('/') != -1:
                    subfolder = os.path.join(PATH, 'build', 'html',
                                             token.split('/')[0])
                    if not os.path.exists(subfolder):
                        utils.createfolder(subfolder)

                utils.writefile(
                    os.path.join(PATH, 'build', 'html', token + '.html'), html)
            except Exception as e:
                log.error(str(e))
                if not conf.getConfig().get('html_force_output'):
                    raise
        log.success('Render html success')
예제 #37
0
def publish():
    code = request.form.get('code')
    if not code:
        return jsonify({'err': 1, 'message': 'Code cannot be empty'})
    elif len(code) > 500 * 1024:
        return jsonify({'err': 1, 'message': 'Code size cannot exceed 500K'})

    key = writefile(code, request.form.get('title'))
    return jsonify({'err': 0, 'data': key})
예제 #38
0
    def check_cc(self):
        """ checking if cc works """
        # simply generates a C program containing a couple of calls
        # to MPI routines and checks if the compilation and execution
        # are succesful
        print 'Checking if cc works...',
        sys.stdout.flush()
        # generate
        writefile(
            'tmpc.c', """
            #include <stdio.h>
            int main(int argc, char **argv){
            int iam;
            fprintf(stdout, \"success\" );fflush(stdout);
            return 0;
            }\n""")

        # compile
        #ccomm = self.config.cc+" "+self.config.cflags+" "+self.config.ldflags_c+" -o tmpc "+os.path.join(os.getcwd(),"tmpc.c")
        import re
        cflags_ = re.sub(
            '-O3', '-O0', self.config.cflags
        )  # -O3 would take too much time. Do not need optimization here....
        ccomm = self.config.cc + " " + cflags_ + "  -o tmpc " + os.path.join(
            os.getcwd(), "tmpc.c")
        (output, error, retz) = shellcmd(ccomm)

        if retz:
            print '\n\nCOMMON: C compiler not working! aborting...'
            print 'stderr:\n', '*' * 50, '\n', error, '\n', '*' * 50
            sys.exit()

        # run
        comm = './tmpc'
        (output, error, retz) = shellcmd(comm)
        if retz:
            print '\n\nCOMMON: cc not working! aborting...'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            sys.exit()

        # cleanup
        delfiles(['tmpc.c', 'tmpc'])
        print 'yes'
        return 0
예제 #39
0
def partnerXML(wiki, parser):
    """Produce the partner XML file. And while we are at it, as produce the
    Partner includer file for latex"""

    partnerDict = parser.getTable(parser.getSection (wiki, "Partner data", 2))

    # pp(partnerDict) 

    # is there budget information?
    budgetTable = parser.getTable(parser.getSection(wiki, "Budget", 2))
    if budgetTable:
        # pp( budgetTable)

        for x in budgetTable:
            # just to make sure that all field types are present in the partnerDict

            fieldType = x['FieldType']
            for p in partnerDict:
                try:
                    p[fieldType] = float(x[p['Shortname']])
                except:
                    p[fieldType] = 0.0


    pp(partnerDict)
    
    xml = "<allpartners>\n"
    for partner in partnerDict:
        xml += "\t<partnerdescription>\n"
        for k,v in partner.iteritems():
            if type(v) == float:
                xml += "\t\t<" + k + " type='float'> " + str(v) + "</" + k + ">\n"
            elif type(v) == int:
                xml += "\t\t<" + k + " type='int'> " + str(v) + "</" + k + ">\n"
            else:
                xml += "\t\t<" + k + "> " + v + "</" + k + ">\n"  
        xml += "\t</partnerdescription>\n"
    xml += "</allpartners>\n"

    utils.writefile (xml, 
                     os.path.join(config.get('PathNames', 'xmlpath'),
                                  'partners.xml'))
예제 #40
0
def partnerXML(wiki, parser):
    """Produce the partner XML file. And while we are at it, as produce the
    Partner includer file for latex"""

    partnerDict = parser.getTable(parser.getSection(wiki, "Partner data", 2))

    # pp(partnerDict)

    # is there budget information?
    budgetTable = parser.getTable(parser.getSection(wiki, "Budget", 2))
    if budgetTable:
        # pp( budgetTable)

        for x in budgetTable:
            # just to make sure that all field types are present in the partnerDict

            fieldType = x['FieldType']
            for p in partnerDict:
                try:
                    p[fieldType] = float(x[p['Shortname']])
                except:
                    p[fieldType] = 0.0

    pp(partnerDict)

    xml = "<allpartners>\n"
    for partner in partnerDict:
        xml += "\t<partnerdescription>\n"
        for k, v in partner.iteritems():
            if type(v) == float:
                xml += "\t\t<" + k + " type='float'> " + str(
                    v) + "</" + k + ">\n"
            elif type(v) == int:
                xml += "\t\t<" + k + " type='int'> " + str(
                    v) + "</" + k + ">\n"
            else:
                xml += "\t\t<" + k + "> " + v + "</" + k + ">\n"
        xml += "\t</partnerdescription>\n"
    xml += "</allpartners>\n"

    utils.writefile(
        xml, os.path.join(config.get('PathNames', 'xmlpath'), 'partners.xml'))
예제 #41
0
def dynsync(local_dir, remote_dir, ignored, initial_files):
    try:
        for f in initial_files:
            writefile((local_dir, f))
        p = subprocess.Popen(["dynsync", local_dir, "localhost:" +
                              remote_dir] +
                             ["--ignore=%s" % i for i in ignored])

        def pred():
            if not p.pid:
                return False
            with process_stopped(p.pid):
                fds_path = "/proc/%d/fd" % p.pid
                cmd = "find %s -lname anon_inode:inotify" % fds_path
                return isdir(fds_path) and subprocess.check_output(
                    shlex.split(cmd))

        wait_for(pred)
        yield p
    finally:
        p.terminate()
예제 #42
0
파일: tester.py 프로젝트: Leo1973/work
def init(spirit_name, confs, c_lenseinfo):
    global lenseinfo_name 
    directory_log = newlogs + c_lenseinfo.name + "/"
    directory_conf = newconfs + c_lenseinfo.name + "/"
    lenseinfo_name = c_lenseinfo.name
    #print conf_path
    #print conf
    print "now",spirit_name
    confcp2(c_lenseinfo.conf_path, directory_conf + spirit_name)
    logread = runscript[c_lenseinfo.name](spirit_name)
    print logread
    if utils.writefile(logread, "./"+directory_log + spirit_name):
        print "succeed!"
예제 #43
0
파일: jaeschke.py 프로젝트: pchelkanat/spsp
def find_equal_signs(a_base, primes_list):
    clearfile(f"lib/equal/{a_base}/equal_signs.txt")
    clearfile(f"lib/equal/{a_base}/total_time.txt")

    ### Посчет времени работы
    start_time = time.time()
    ###
    signs_list = [
    ]  # так как нельзя вернуть словарь с ключом-списком, заводим список сигнатур
    primes_dict = {}  # ключами являются индексы в списке сигнатур
    for prime in primes_list[len(a_base):]:
        print("finding equal ... %s" % (prime))
        sign = Sign(a_base, prime)
        if sign in signs_list:
            primes_dict[signs_list.index(sign)].append(prime)
        else:
            signs_list.append(sign)
            primes_dict[signs_list.index(sign)] = [prime]
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ### Преобразование по классу
    equal_list = []
    for j in range(len(signs_list)):
        temp = Signature(signs_list[j], primes_dict[j])
        equal_list.append(temp)

    ###Запись в файл
    tot_s = total_time
    writefile(f"lib/equal/{a_base}/total_time.txt", tot_s)

    s = ""
    for j in range(len(signs_list)):
        s += f"{j}    {equal_list[j].sign}     {equal_list[j].primes}\n"
    writefile(f"lib/equal/{a_base}/equal_signs.txt", s)

    return equal_list
예제 #44
0
    def check_fc(self):
        """ check if the Fortran compiler works """
        # simply generates a F77 program and checks if the compilation and execution
        # are succesful
        print "Checking if the Fortran compiler works...",
        sys.stdout.flush()
        # generate
        writefile(
            "tmpf.f", """
      program ftest
      integer i
      print*,'success'
      stop
      end\n""")

        # compile
        #fcomm = self.config.fc+' '+self.config.fcflags+" "+self.config.ldflags_fc+' -o tmpf '+'tmpf.f'
        fcomm = self.config.fc + ' ' + self.config.fflags + '  -o tmpf ' + 'tmpf.f'
        (output, error, retz) = shellcmd(fcomm)

        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            sys.exit()

        # run
        comm = './tmpf'
        (output, error, retz) = shellcmd(comm)
        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n', '*' * 50, '\n', error, '\n', '*' * 50
            sys.exit()

        # cleanup
        delfiles(['tmpf.f', 'tmpf', 'tmpf.o'])
        print 'yes'

        return 0
예제 #45
0
파일: build.py 프로젝트: chshouyu/ursa
def compileHTML( needCompress = False , needHtml = False ):
    """为所有tpl文件加上时间戳
    """
    base = os.path.join(PATH , 'build' , 'template')
    tplfiles = []
    for dirpath , dirnames , filenames  in os.walk(base):
        tplfiles.extend([ os.path.join( dirpath , f ) for f in filenames if f.endswith('.tpl')  ])
    if COMPILE_FOLDER:
        for dirpath , dirnames , filenames  in os.walk(os.path.join(PATH , 'build' , COMPILE_FOLDER)):
            tplfiles.extend([ os.path.join( dirpath , f ) for f in filenames  ])
        
    for tpl in tplfiles:
        f = parser.compileHTML(tpl , needCompress)
        utils.writefile(tpl , f)

    if needHtml:
        log.log('Render html file.\nIt will under build folder.')
        files = os.listdir( os.path.join( base ) )
        tplfiles = []
        for dirpath , dirnames, filenames in os.walk(base):
            tplfiles.extend( [ os.path.join(dirpath , f) for f in filenames if f.endswith('.tpl') ] )
        for fname in tplfiles:
            token = fname.replace( base + '/' , '' ).replace('.tpl' , '')
            try:#有强行编译的需求
                html = parser.parseTpl(token  , isbuild=True)
            
                if token.find('/') != -1:
                    subfolder = os.path.join(PATH , 'build' , 'html'  , token.split('/')[0])
                    if not os.path.exists(subfolder):
                        utils.createfolder(subfolder)
            
                utils.writefile( os.path.join(PATH , 'build' , 'html' , token + '.html' ) , html )
            except Exception as e:
                log.error(str(e))
                if not conf.getConfig().get('html_force_output'):
                    raise
        log.success('Render html success');
예제 #46
0
파일: framework.py 프로젝트: randyp/randyp
    def check_cc(self):
        """ checks if cc works """
        # simply generates a C program containing a couple of calls
        # to MPI routines and checks if the compilation and execution
        # are succesful
        print 'Checking if cc works...',
        sys.stdout.flush()
        # generate
        writefile('tmpc.c',"""
            #include <stdio.h>
            int main(int argc, char **argv){
            int iam;
            fprintf(stdout, \"success\" );fflush(stdout);
            return 0;
            }\n""")

        # compile
        ccomm = self.config.cc+" "+self.config.ccflags+" "+self.config.ldflags_c+" -o tmpc "+os.path.join(os.getcwd(),"tmpc.c")
        (output, error, retz) = runShellCommand(ccomm)

        if retz:
            print '\n\nCOMMON: C compiler not working! aborting...'
            print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # run
        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: cc not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # cleanup
        killfiles(['tmpc.c','tmpc'])
        print 'yes'
        return 0;
예제 #47
0
파일: blas.py 프로젝트: randyp/randyp
    def check_blas(self):

        print "Checking if provided BLAS works...",
        # This function simply generates a FORTRAN program
        # that contains few calls to BLAS routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpf.f',"""
      program ftest
      double precision da, dx(1)
      dx(1)=1
      da = 2
      call dscal(1,da,dx,1)
      stop
      end\n""")

        fcomm = self.config.fc+' -o tmpf '+'tmpf.f '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
        (output, error, retz) = runShellCommand(fcomm)

        if(retz != 0):
            print '\n\nBLAS: provided BLAS cannot be used! aborting...'
            print 'error is:\n','*'*40,'\n',fcomm,'\n',error,'\n','*'*40
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            print '\n\nBLAS: provided BLAS cannot be used! aborting...'
            print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        killfiles(['tmpf.f','tmpf'])
        print 'yes'

        return 0;
예제 #48
0
파일: framework.py 프로젝트: randyp/randyp
    def check_fc(self):
        """ check if the Fortran compiler works """
        # simply generates a F77 program and checks if the compilation and execution
        # are succesful
        print "Checking if the Fortran compiler works...",
        sys.stdout.flush()
        # generate
        writefile("tmpf.f","""
      program ftest
      integer i
      print*,'success'
      stop
      end\n""")

        # compile
        fcomm = self.config.fc+' '+self.config.fcflags+" "+self.config.ldflags_fc+' -o tmpf '+'tmpf.f'
        (output, error, retz) = runShellCommand(fcomm)

        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # run
        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # cleanup
        killfiles(['tmpf.f','tmpf','tmpf.o'])
        print 'yes'

        return 0;
예제 #49
0
 def write_export_records(self, output, file_name, batch):
     '''
     write formatted records to file. backend for both bibtex and html
     '''
     try:
         rv = writefile(file_name, output)
     except Exception as error:
         if not batch:
             hub.show_errors(str(error))
         else:
             traceback.print_exc()
     else:
         # hub.show_info("File %s written" % file_name)
         if not batch:
             hub.set_status_bar("Output sent to %s" % rv)
예제 #50
0
def workpackageXML(wiki, parser, verbose=False):
    """Produce the workpackage-related XML structure.
    - The include commands in the project-wide XML
    - The per-workpackage XML
    """

    wplist = parser.getList(parser.getSection(wiki, "Workpackages", 2))
    # print wplist

    wpIncluder = ""
    t = "<workpackages>\n"
    for wp in wplist:
        t += "#include<wp/" + wp + ".xml>\n"
    t += "</workpackages>\n"

    # and generate the individual wps:
    wpCount = 1
    for wp in wplist:
        if verbose:
            print "now parsing into XML of workpackage : " + wp
        import codecs
        wpwiki = codecs.open(
            os.path.join(config.get('PathNames', 'wikiwppath'), wp), 'r',
            'utf-8').read()
        # print type(wpwiki)
        wpMain = singleWorkpackageXML(wp, wpwiki, parser, wpCount)
        # pp(wpMain)
        wpCount += 1
        wpIncluder += "\\input{wp/Wp_" + wpMain['Shortname'] + ".tex}\n \n"

    utils.writefile(
        wpIncluder,
        os.path.join(config.get('PathNames', 'genlatexwppath'),
                     'wpIncluder.tex'))

    return t
예제 #51
0
파일: jaeschke.py 프로젝트: pchelkanat/spsp
def t_2(a_base, B, primes_list):
    clearfile(f"res/jae/2/{a_base}/spsp_{B}.txt")
    spsp = []
    ### Посчет времени работы
    start_time = time.time()
    ###
    i = 1
    for p in primes_list:
        if p < int(root(B, 2)):
            if p > a_base[-1]:
                lmd_p = Lambda_p(a_base, p)
                lmd = numth.lcm(lmd_p, 2)
                for k in range(int(1 + (p - 1) / lmd),
                               int((B - p) / (p * lmd)) + 1, 1):
                    q = 1 + k * lmd
                    if p * q <= B:  # and p * q > B // 100:
                        if numth.is_prime(q) and q > p:
                            if q + 1 == 2 * p:
                                if check_signs(a_base, [p, q]) and psp_2(
                                        a_base, [p, q]):
                                    item = Signature(Sign(a_base, p), [p, q])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/2/{a_base}/spsp_{B}.txt", s)
                                    i += 1
                                    spsp.append(item)
                                else:
                                    continue

                            else:
                                P = p * (1 + k * lmd)
                                if psp(a_base, P) and check_signs(
                                        a_base, [p, q]):
                                    item = Signature(Sign(a_base, p), [p, q])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/2/{a_base}/spsp_{B}.txt", s)
                                    i += 1
                                    spsp.append(item)
                    # else:
                    # break
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###
    writefile(f"res/jae/2/{a_base}/spsp_{B}.txt", total_time)
    return spsp
예제 #52
0
파일: plasma.py 프로젝트: randyp/randyp
    def write_makeinc(self):
        """ Writes the make.inc file for PLASMA installation """

        sdir = os.getcwd()
        print 'Writing make.inc...',
        sys.stdout.flush()
        old = 0
        for ver in self.oldversions:
            if self.version == ver :
                old = 1
                break

        if old == 1:
            print "Version under 2.3.0 are not handle by this installer, please use the release 1.2.0"
            exit
            makeinc = """
#/////////////////// P /// L /// A /// S /// M /// A //////////////////
#/// PLASMA is a software package provided by Univ. of Tennessee,  ///
#/// Univ. of California Berkeley and Univ. of Colorado Denver     ///
#//////////// M /// A /// K /// E /// . /// I /// N /// C /////////////

#///////////// U /// S /// E /// R ////// P /// A /// R /// T //////////

PLASMA_DIR  = """+sdir+"""

CC          = """+self.config.cc+"""
FC          = """+self.config.fc+"""
LINKER      = $(FC)

ARCH        = ar
ARCHFLAGS   = """+self.config.arflags+"""
RANLIB      = """+self.config.ranlib+"""

OPTS        = """+self.config.ccflags+""" """+self.mangling+"""
FOPTS       = """+self.config.fcflags+"""
LDOPTS      = """+self.config.ldflags_fc+' '+self.config.ld_fcmain+"""

# Blas Library
LIBBLAS     = """+self.config.blaslib+"""
#///// D /// O ////// N /// O /// T ////// T /// O /// U /// C /// H /////

# Include directory
INC         = -I$(PLASMA_DIR)/include

# Location of the libraries.
LIBDIR      = -L$(PLASMA_DIR)/lib

# Location and name of the PLASMA library.
LIBCBLAS      = $(PLASMA_DIR)/lib/libcblas.a
LIBCORELAPACK = $(PLASMA_DIR)/lib/libcorelapack.a
LIBCOREBLAS   = $(PLASMA_DIR)/lib/libcoreblas.a
LIBPLASMA     = $(PLASMA_DIR)/lib/libplasma.a

#  All libraries required by the tester.
LIB           = -lplasma -lcoreblas -lcorelapack -lcblas $(LIBBLAS) -lpthread -lm

#//////////////////////////////////////////////////////////////////////////
"""
        else:
            makeinc ="""
#/////////////////// P /// L /// A /// S /// M /// A //////////////////
#/// PLASMA is a software package provided by Univ. of Tennessee,  ///
#/// Univ. of California Berkeley and Univ. of Colorado Denver     ///
#//////////// M /// A /// K /// E /// . /// I /// N /// C /////////////
# make.inc automatically generated by plasma-installer

prefix      = """+self.prefix+"""

CC          = """+self.config.cc+"""
FC          = """+self.config.fc+"""
LOADER      = $(FC)

ARCH        = ar
ARCHFLAGS   = """+self.config.arflags+"""
RANLIB      = """+self.config.ranlib+"""

CFLAGS      = """+self.config.ccflags+""" """+self.mangling+"""
FFLAGS      = """+self.config.fcflags+"""
LDFLAGS     = """+self.config.ldflags_fc+' '+self.config.ld_fcmain+"""

# Blas Library
LIBBLAS     = """+self.config.blaslib+"""
# CBlas library
LIBCBLAS    = """+self.config.cblaslib+"""
# lapack and tmg library (lapack is included in acml)
LIBLAPACK   = """+self.config.lapacklib+"""
INCCLAPACK  = """+self.config.lapackinc+"""
LIBCLAPACK  = """+self.config.lapclib+"""
"""
        writefile('make.inc',makeinc)

        self.plasmadir = sdir
        print 'done.'
예제 #53
0
파일: blas.py 프로젝트: mawussi/BBLAS-ref
    def down_install_blas(self):

        print """
The reference BLAS library is being installed.
Don't expect high performance from this reference library!
If you want performance, you need to use an optimized BLAS library and,
to avoid unnecessary complications, if you need to compile this optimized BLAS
library, use the same compiler you're using here."""
        sys.stdout.flush()

        savecwd = os.getcwd()

        # creating the build,lib and log dirs if don't exist
        if not os.path.isdir(os.path.join(self.prefix, 'lib')):
            os.mkdir(os.path.join(self.prefix, 'lib'))

        if not os.path.isdir(os.path.join(os.getcwd(), 'log')):
            os.mkdir(os.path.join(os.getcwd(), 'log'))

        # Check if blas.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(
                os.path.join(os.getcwd(), getURLName(self.blasurl))):
            print "Downloading reference BLAS...",
            downloader(self.blasurl, self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'gunzip -f blas.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nBLAS: cannot unzip blas.tgz'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()

        comm = 'mkdir BLAS && tar x --strip-components=1 -C BLAS -f blas.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nBLAS: cannot untar blas.tgz'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()
        os.remove('blas.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(), 'BLAS'))

        # compile and generate library
        print 'Compile and generate reference BLAS...',
        sys.stdout.flush()
        comm = self.config.fc + ' ' + self.config.fcflags + " -c *.f"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot compile blas"
            print "stderr:\n", "*" * 40, "\n", comm, '\n', error, "\n", "*" * 40
            sys.exit()

        log = output + error

        comm = "ar cr librefblas.a *.o"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create blas library"
            print "stderr:\n", "*" * 40, "\n", comm, '\n', error, "\n", "*" * 40
            sys.exit()
        print "done"

        log = log + output + error

        comm = self.config.ranlib + " librefblas.a"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create table of contents for blas library"
            print "stderr:\n", "*" * 40, "\n", comm, '\n', error, "\n", "*" * 40
            sys.exit()
        print "done"

        # write the log on a file
        log = log + output + error
        fulllog = os.path.join(savecwd, 'log/blaslog')
        writefile(fulllog, log)
        print 'Installation of reference BLAS successful.'
        print '(log is in ', fulllog, ')'

        # move librefblas.a to the lib directory
        shutil.copy('librefblas.a', os.path.join(self.prefix, 'lib/libblas.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.blaslib = '-L' + os.path.join(self.prefix,
                                                  'lib') + ' -lblas '
        self.config.blasdir = self.prefix
        os.chdir(savecwd)
예제 #54
0
def test_ignore_remote(dynsync, local_dir, remote_dir):
    import time
    time.sleep(1)
    writefile((remote_dir, "ignored_file"))
    with pytest.raises(NotEqualException):
        wait_dirs_equal(local_dir, remote_dir)
예제 #55
0
파일: lapack.py 프로젝트: randyp/randyp
    def down_install_lapack(self):

        print """
The reference LAPACK library is being installed.
"""
        sys.stdout.flush()

        savecwd = os.getcwd()

        # creating the build,lib and log dirs if don't exist
        if not os.path.isdir(os.path.join(self.prefix,'lib')):
            os.mkdir(os.path.join(self.prefix,'lib'))

        if not os.path.isdir(os.path.join(os.getcwd(),'log')):
            os.mkdir(os.path.join(os.getcwd(),'log'))

        # Check if lapack.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.lapackurl))):
            print "Downloading reference LAPACK...",
            downloader(self.lapackurl,self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'tar -xvzf  lapack-3.4.1.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nLAPACK: cannot unzip lapack.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        print 'done'

#         # Overwrite [sd]lamch.f
#         shutil.copy(os.path.join(self.plasma.installerdir,'src/dlamch.f'),
#                     os.path.join(os.getcwd(),'lapack-3.3.1/INSTALL'))
#         shutil.copy(os.path.join(self.plasma.installerdir,'src/slamch.f'),
#                     os.path.join(os.getcwd(),'lapack-3.3.1/INSTALL'))

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(), 'lapack-3.4.1')) #self.lapversion))

        # Write Makefile.in
        writefile('make.inc', """
# -*- Makefile generated by PLASMA installer -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.4.0                                           #
#  April 2012                                                      #
####################################################################
#
SHELL = /bin/sh
#
#  Modify the FORTRAN and OPTS definitions to refer to the
#  compiler and desired compiler options for your machine.  NOOPT
#  refers to the compiler options desired when NO OPTIMIZATION is
#  selected.  Define LOADER and LOADOPTS to refer to the loader and
#  desired load options for your machine.
#
FORTRAN  = """+self.config.fc+"""
OPTS     = """+self.config.fcflags+"""
DRVOPTS  = $(OPTS)
NOOPT    = """+self.config.noopt+"""
LOADER   = """+self.config.fc+"""
LOADOPTS = """+self.config.ldflags_fc+"""
#
# Timer for the SECOND and DSECND routines
#
# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
# TIMER    = EXT_ETIME
# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
# TIMER    = EXT_ETIME_
# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
# TIMER    = INT_ETIME
# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
# SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME
TIMER    = INT_CPU_TIME
# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
# TIMER     = NONE
#
#  Configuration LAPACKE: Native C interface to LAPACK
#  To generate LAPACKE library: type 'make lapackelib'
#  Configuration file: turned off (default)
#  Complex types: C99 (default)
#  Name pattern: mixed case (default)
#  (64-bit) Data model: LP64 (default)
#
# CC is the C compiler, normally invoked with options CFLAGS.
#
CC     = """+self.config.cc+"""
CFLAGS = """+self.config.ccflags+"""
#
#  The archiver and the flag(s) to use when building archive (library)
#  If you system has no ranlib, set RANLIB = echo.
#
ARCH     = ar
ARCHFLAGS= """+self.config.arflags+"""
RANLIB   = """+self.config.ranlib+"""
#
#  The location of BLAS library for linking the testing programs.
#  The target's machine-specific, optimized BLAS library should be
#  used whenever possible.
#
BLASLIB      = """+self.config.blaslib+"""
#
#  Location of the extended-precision BLAS (XBLAS) Fortran library
#  used for building and testing extended-precision routines.  The
#  relevant routines will be compiled and XBLAS will be linked only if
#  USEXBLAS is defined.
#
# USEXBLAS    = Yes
XBLASLIB     =
# XBLASLIB    = -lxblas
#
#  Names of generated libraries.
#
LAPACKLIB    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
LAPACKELIB   = liblapacke.a
""")

        # compile and generate library
        print 'Compile and generate LAPACK...',
        sys.stdout.flush()
        comm = self.make+' lapacklib tmglib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nLAPACK: cannot compile LAPACK"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/lapacklog')
        writefile(fulllog, log)
        print 'Installation of liblapack.a successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('liblapack.a',os.path.join(self.prefix,'lib/liblapack.a'))
        shutil.copy('libtmg.a',os.path.join(self.prefix,'lib/libtmg.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapacklib  = '-L'+os.path.join(self.prefix,'lib')+' -ltmg -llapack'
        os.chdir(savecwd)

        self.config.lapinstalled = 1;

        # Check if the installation is successful
        self.plasma.verbose = 1
        ret = self.check_lapack()
        self.plasma.verbose = 0
        if ret != 0:
            sys.exit()
예제 #56
0
def test_ignore_local(dynsync, local_dir, remote_dir):
    writefile((local_dir, "ignored_file"))
    with pytest.raises(NotEqualException):
        wait_dirs_equal(local_dir, remote_dir)
예제 #57
0
파일: lapack.py 프로젝트: randyp/randyp
    def check_lapack(self):

        print "Checking if provided LAPACK works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpf.f',"""

      program ftest
      integer  N
      parameter (N = 1)
      double precision A(N, N), B(N)
      integer  I(N)
      integer  INFO
      B(:)   = 1
      A(:,:) = 2
      I(:)   = 0
      call cheevd( 'N', 'U', N, A, N, B, B, -1,
     $     B, -1, I, -1, INFO)
      stop
      end\n""")

        ldflg = self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
        ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPACK: provided LAPACK cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPACK: provided LAPACK cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpf.f','tmpf'])
        print 'yes'

        print "Checking if provided LAPACK contains functions for test works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpf.f',"""
      program ftest
        double precision D(1), A(1:1), B(2)
        integer          ISEED( 4 )
        integer          INFO
        B(1)   = 1

        do  I = 1, 4
            ISEED( I ) = 1
        enddo
        call dlarnv( 1, ISEED, 1, D )
        call dlagsy( 1, 0, D, A, 1, ISEED, B, INFO )
        stop
      end\n""")

        ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            print 'no'
            self.plasma.needtmg = 1
        else:
            comm = './tmpf'
            (output, error, retz) = runShellCommand(comm)
            if(retz != 0):
                print 'no'
                self.plasma.needtmg = 1;
            else:
                self.plasma.needtmg = 0;
                print 'yes'
        killfiles(['tmpf.f','tmpf'])

        return 0;
예제 #58
0
파일: cblas.py 프로젝트: randyp/randyp
    def down_install_cblas(self):

        print """
The reference CBLAS library is being installed.
"""
        sys.stdout.flush()

        savecwd = os.getcwd()

        # creating the build,lib and log dirs if don't exist
        if not os.path.isdir(os.path.join(self.prefix,'lib')):
            os.mkdir(os.path.join(self.prefix,'lib'))

        if not os.path.isdir(os.path.join(self.prefix,'include')):
            os.mkdir(os.path.join(self.prefix,'include'))

        if not os.path.isdir(os.path.join(os.getcwd(),'log')):
            os.mkdir(os.path.join(os.getcwd(),'log'))

        # Check if cblas.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.cblasurl))):
            print "Downloading reference CBLAS...",
            downloader(self.cblasurl,self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'gunzip -f cblas.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot unzip cblas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        comm = 'tar xf cblas.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot untar cblas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()
        os.remove('cblas.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(),'CBLAS'))

        # Write Makefile.in
        writefile('Makefile.in', """
# Makefile.in (Plasma Installer)
#
#-----------------------------------------------------------------------------
# Shell
#-----------------------------------------------------------------------------
SHELL = /bin/sh

#-----------------------------------------------------------------------------
# Platform
#-----------------------------------------------------------------------------

PLAT = """+self.plat+"""

#-----------------------------------------------------------------------------
# Libraries and includs
#-----------------------------------------------------------------------------

BLLIB = """+self.config.blaslib+"""
CBDIR = """+os.getcwd()+"""
CBLIBDIR = $(CBDIR)/lib
CBLIB = $(CBLIBDIR)/libcblas.a

#-----------------------------------------------------------------------------
# Compilers
#-----------------------------------------------------------------------------

CC = """+self.config.cc+"""
FC = """+self.config.fc+"""
LOADER = $(FC)

#-----------------------------------------------------------------------------
# Flags for Compilers
#-----------------------------------------------------------------------------

CFLAGS = """+self.config.ccflags+""" """+self.mangling+"""
FFLAGS = """+self.config.fcflags+"""

#-----------------------------------------------------------------------------
# Archive programs and flags
#-----------------------------------------------------------------------------

ARCH      = ar
ARCHFLAGS = """+self.config.arflags+"""
RANLIB    = """+self.config.ranlib+"""
""")

        # compile and generate library
        print 'Compile and generate reference CBLAS...',
        sys.stdout.flush()
        comm = self.make+' alllib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nCBLAS: cannot compile cblas"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/cblaslog')
        writefile(fulllog, log)
        print 'Installation of reference CBLAS successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('lib/libcblas.a',os.path.join(self.prefix,'lib/libcblas.a'))

        # move cblas.h to the include directory
        shutil.copy('include/cblas.h',os.path.join(self.prefix,'include/cblas.h'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.cblaslib  = '-L'+os.path.join(self.prefix,'lib')+' -lcblas'
        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1;
        ret = self.check_cblas()
        self.plasma.verbose = 0;
        if ret != 0 :
            sys.exit()
예제 #59
0
파일: blas.py 프로젝트: randyp/randyp
    def down_install_blas(self):

        print """
The reference BLAS library is being installed.
Don't expect high performance from this reference library!
If you want performance, you need to use an optimized BLAS library and,
to avoid unnecessary complications, if you need to compile this optimized BLAS
library, use the same compiler you're using here."""
        sys.stdout.flush()

        savecwd = os.getcwd()

        # creating the build,lib and log dirs if don't exist
        if not os.path.isdir(os.path.join(self.prefix,'lib')):
            os.mkdir(os.path.join(self.prefix,'lib'))

        if not os.path.isdir(os.path.join(os.getcwd(),'log')):
            os.mkdir(os.path.join(os.getcwd(),'log'))

        # Check if blas.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.blasurl))):
            print "Downloading reference BLAS...",
            downloader(self.blasurl,self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'gunzip -f blas.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nBLAS: cannot unzip blas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        comm = 'tar xf blas.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nBLAS: cannot untar blas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()
        os.remove('blas.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(),'BLAS'))

        # compile and generate library
        print 'Compile and generate reference BLAS...',
        sys.stdout.flush()
        comm = self.config.fc+' '+self.config.fcflags+" -c *.f"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot compile blas"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        comm = "ar cr librefblas.a *.o"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create blas library"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()
        print "done"

        log = log+output+error

        comm = self.config.ranlib+" librefblas.a"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create table of contents for blas library"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()
        print "done"
        
        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/blaslog')
        writefile(fulllog, log)
        print 'Installation of reference BLAS successful.'
        print '(log is in ',fulllog,')'

        # move librefblas.a to the lib directory
        shutil.copy('librefblas.a',os.path.join(self.prefix,'lib/librefblas.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.blaslib  = '-L'+os.path.join(self.prefix,'lib')+' -lrefblas '
        os.chdir(savecwd)
예제 #60
0
파일: tmg.py 프로젝트: randyp/randyp
    def down_install_tmg(self):

        print """
The libtmg from reference LAPACK library is being installed.
"""
        sys.stdout.flush()

        savecwd = os.getcwd()

        # creating the build,lib and log dirs if don't exist
        if not os.path.isdir(os.path.join(self.prefix,'lib')):
            os.mkdir(os.path.join(self.prefix,'lib'))

        if not os.path.isdir(os.path.join(os.getcwd(),'log')):
            os.mkdir(os.path.join(os.getcwd(),'log'))

        # Check if lapack.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.lapackurl))):
            print "Downloading reference LAPACK...",
            downloader(self.lapackurl,self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'gunzip -f lapack.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nlibtmg: cannot unzip lapack.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        comm = 'tar xf lapack.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nlibtmg: cannot untar lapack.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()
        os.remove('lapack.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(),'lapack-3.3.1'))

        # Write Makefile.in
        writefile('make.inc', """
# -*- Makefile -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.3.1                                           #
#  April 2009                                                      #
####################################################################
#
# See the INSTALL/ directory for more examples.
#
SHELL = /bin/sh
#
#  The machine (platform) identifier to append to the library names
#
PLAT = _LINUX
#
#  Modify the FORTRAN and OPTS definitions to refer to the
#  compiler and desired compiler options for your machine.  NOOPT
#  refers to the compiler options desired when NO OPTIMIZATION is
#  selected.  Define LOADER and LOADOPTS to refer to the loader
#  and desired load options for your machine.
#
FORTRAN  = """+self.config.fc+"""
OPTS     = """+self.config.fcflags+"""
DRVOPTS  = $(OPTS)
NOOPT    = """+self.config.noopt+"""
LOADER   = """+self.config.fc+"""
LOADOPTS = """+self.config.ldflags_fc+"""
#
# Timer for the SECOND and DSECND routines
#
# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
# TIMER    = EXT_ETIME
# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
# TIMER    = EXT_ETIME_
# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
# TIMER    = INT_ETIME
# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
# SECOND and DSECND will use a call to the Fortran standard INTERNAL FUNCTION CPU_TIME
TIMER    = INT_CPU_TIME
# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
# TIMER     = NONE
#
#  The archiver and the flag(s) to use when building archive (library)
#  If you system has no ranlib, set RANLIB = echo.
#
ARCH     = ar
ARCHFLAGS= """+self.config.arflags+"""
RANLIB   = """+self.config.ranlib+"""
#
#  The location of BLAS library for linking the testing programs.
#  The target's machine-specific, optimized BLAS library should be
#  used whenever possible.
#
BLASLIB      = """+self.config.cblaslib+"""
#
#  Location of the extended-precision BLAS (XBLAS) Fortran library
#  used for building and testing extended-precision routines.  The
#  relevant routines will be compiled and XBLAS will be linked only if
#  USEXBLAS is defined.
#
# USEXBLAS    = Yes
XBLASLIB     =
# XBLASLIB    = -lxblas
#
#  Names of generated libraries.
#
LAPACKLIB    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
""")

        # compile and generate library
        print 'Compile and generate libtmg...',
        sys.stdout.flush()
        comm = self.make+' tmglib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nlintmg: cannot compile libtmg"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/tmglog')
        writefile(fulllog, log)
        print 'Installation of libtmg.a successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('libtmg.a',os.path.join(self.prefix,'lib/libtmg.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapacklib = '-L'+os.path.join(self.prefix,'lib')+' -ltmg '+self.config.lapacklib

        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1
        self.check_tmg()
        self.plasma.verbose = 0