Commit 5488b2c2 authored by Andreas Marek's avatar Andreas Marek

Merge branch 'loh/python3' into 'master_pre_stage'

Loh/python3

See merge request !36
parents c204c68e 5e271fd9
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/python3
from itertools import product
def set_number_of_cores(mpi_tasks, o):
cores = 1
cores = 1 * mpi_tasks
......
#!/usr/bin/python
import sys
#!/usr/bin/python3
simple_tokens = [
"PRECISION",
......@@ -113,62 +112,63 @@ blas_prefixes = {("real","single") : "S", ("real","double") : "D", ("complex","s
def print_variant(number, precision, explicit):
for token in simple_tokens:
print "#define ", token, token.replace("PRECISION", precision).replace("UPCASENUMBER", number.upper()).replace("NUMBER", number)
print "#define ", token + "_STR", "'" + token.replace("PRECISION", precision).replace("UPCASENUMBER", number.upper()).replace("NUMBER", number) + "'"
print("#define ", token, token.replace("PRECISION", precision).replace("UPCASENUMBER", number.upper()).replace("NUMBER", number))
print("#define ", token + "_STR", "'" + token.replace("PRECISION", precision).replace("UPCASENUMBER", number.upper()).replace("NUMBER", number) + "'")
if("NUMBER" in token):
print "#define ", token.replace("NUMBER", number), token.replace("PRECISION", precision).replace("NUMBER", number)
print("#define ", token.replace("NUMBER", number), token.replace("PRECISION", precision).replace("NUMBER", number))
for token in blas_tokens:
print "#define ", token, token.replace("PRECISION_", blas_prefixes[(number, precision)])
print("#define ", token, token.replace("PRECISION_", blas_prefixes[(number, precision)]))
for token in explicit:
print "#define ", token[0], token[explicit_order[precision]]
print("#define ", token[0], token[explicit_order[precision]])
def print_undefs(number, explicit):
for token in simple_tokens:
print "#undef ", token
print "#undef ", token + "_STR"
print("#undef ", token)
print("#undef ", token + "_STR")
if("NUMBER" in token):
print "#undef ", token.replace("NUMBER", number)
print("#undef ", token.replace("NUMBER", number))
for token in blas_tokens:
print "#undef ", token
print("#undef ", token)
for token in explicit:
print "#undef ", token[0]
print("#undef ", token[0])
print "#ifdef REALCASE"
print "#undef MATH_DATATYPE"
print "#define MATH_DATATYPE real"
print("#ifdef REALCASE")
print("#undef MATH_DATATYPE")
print("#define MATH_DATATYPE real")
print_undefs("real", explicit_tokens_real)
#print_undefs("complex", explicit_tokens_complex)
print "#ifdef DOUBLE_PRECISION"
# print_undefs("complex", explicit_tokens_complex)
print("#ifdef DOUBLE_PRECISION")
print_variant("real", "double", explicit_tokens_real)
print "#endif"
print "#ifdef SINGLE_PRECISION"
print("#endif")
print("#ifdef SINGLE_PRECISION")
print_variant("real", "single", explicit_tokens_real)
print "#endif"
print "#endif"
print("#endif")
print("#endif")
print "#ifdef COMPLEXCASE"
print "#undef MATH_DATATYPE"
print "#define MATH_DATATYPE complex"
#print_undefs("real", explicit_tokens_real)
print("#ifdef COMPLEXCASE")
print("#undef MATH_DATATYPE")
print("#define MATH_DATATYPE complex")
# print_undefs("real", explicit_tokens_real)
print_undefs("complex", explicit_tokens_complex)
print "#ifdef DOUBLE_PRECISION"
print("#ifdef DOUBLE_PRECISION")
print_variant("complex", "double", explicit_tokens_complex)
print "#endif"
print "#ifdef SINGLE_PRECISION"
print("#endif")
print("#ifdef SINGLE_PRECISION")
print_variant("complex", "single", explicit_tokens_complex)
print "#endif"
print "#endif"
print("#endif")
print("#endif")
#print "#elif MACROS_TYPE == COMPLEX_DOUBLE"
#print "#undef NUMBER"
#print_undefs("complex", explicit_tokens_complex)
#print "#define NUMBER complex"
#print_variant("complex", "double", explicit_tokens_complex)
# print("#elif MACROS_TYPE == COMPLEX_DOUBLE")
# print("#undef NUMBER")
# print_undefs("complex", explicit_tokens_complex)
# print("#define NUMBER complex")
# print_variant("complex", "double", explicit_tokens_complex)
#print "#elif MACROS_TYPE == COMPLEX_SINGLE"
#print "#undef NUMBER"
#print_undefs("complex", explicit_tokens_complex)
#print "#define NUMBER complex"
#print_variant("complex", "single", explicit_tokens_complex)
#print "#endif"
# print("#elif MACROS_TYPE == COMPLEX_SINGLE")
# print("#undef NUMBER")
# print_undefs("complex", explicit_tokens_complex)
# print("#define NUMBER complex")
# print_variant("complex", "single", explicit_tokens_complex)
# print("#endif")
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/python3
from itertools import product
language_flag = {
......
#!/usr/bin/python
#!/usr/bin/python3
from __future__ import print_function
import os
import sys
import subprocess
def cpp_arg(arg):
return arg.startswith("-I") or \
return \
arg.startswith("-I") or \
arg.startswith("-D") or \
arg.startswith("-U")
......@@ -15,6 +17,7 @@ def check_call(args, **kwargs):
print(" ".join(args))
return subprocess.check_call(args, **kwargs)
def check_call_redirect(args, filename=None, **kwargs):
if os.getenv("V") == "1":
print(" ".join(args), ">", filename)
......@@ -25,11 +28,12 @@ def check_call_redirect(args, filename=None, **kwargs):
os.remove(filename)
raise SystemExit(e.returncode)
args = sys.argv[1:]
cpp_args = filter(cpp_arg, args)
cpp_args = list(filter(cpp_arg, args))
files = list(filter(lambda q: q.endswith(".F90"), args))
args = list(filter(lambda q: not q.endswith(".F90"), args))
files = filter(lambda q : q.endswith(".F90"), args)
args = filter(lambda q : not q.endswith(".F90"), args)
if len(files) > 1:
raise Exception("Specify exactly one .F90 file")
elif len(files) == 0:
......@@ -54,7 +58,7 @@ except ValueError:
tmp_filename = tmp_filename[-250:]
# preprocess
check_call_redirect(["cpp","-P", "-traditional", "-Wall", "-Werror"] + cpp_args + [file], filename=tmp_filename)
check_call_redirect(["cpp", "-P", "-traditional", "-Wall", "-Werror"] + cpp_args + [file], filename=tmp_filename)
# compile
check_call(args + [tmp_filename])
......
#!/usr/bin/env python
#!/usr/bin/python3
import numpy as np
from pyelpa import DistributedMatrix
import sys
......
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import os
......
......@@ -27,25 +27,25 @@ class Trace:
header = f.readline()
val = [int(x) for x in header.split()]
val.append(f.readline()[:-1])
print val
print(val)
return val
def __load_matrix(self, directory, filenames):
mat = []
for (mpi_rank, filename) in filenames:
#print filename, mpi_rank, prow, pcol, p_cols
#print(filename, mpi_rank, prow, pcol, p_cols)
(na, nblk, lda, localCols, my_prow, my_pcol, p_rows, p_cols, iteration, name) = self.__get_header(directory + '/' + filename)
if(mat == []):
mat = np.zeros((na, na))
(self._na, self._nblk, self._p_rows, self._p_cols) = (na, nblk, p_rows, p_cols)
prow = mpi_rank % p_rows
pcol = mpi_rank / p_rows
#print (na, nblk, lda, localCols, my_prow, my_pcol, my_nprows, my_npcols)
#print(na, nblk, lda, localCols, my_prow, my_pcol, my_nprows, my_npcols)
assert(my_prow == prow)
assert(my_pcol == pcol)
loc_mat = np.loadtxt(fname = directory + '/' + filename, skiprows = 2)
#print "lda, localCols ", lda, localCols
#print("lda, localCols ", lda, localCols)
for row_blk in range((lda-1)/nblk + 1):
loc_row_beg = row_blk * nblk
if(loc_row_beg >= lda):
......@@ -54,7 +54,7 @@ class Trace:
loc_row_end = min(loc_row_beg + nblk, lda)
glob_row_beg = (row_blk * p_rows + prow) * nblk
#print "glob_row_beg = row_blk * nblk * p_rows ", glob_row_beg, row_blk, nblk, p_rows
#print("glob_row_beg = row_blk * nblk * p_rows ", glob_row_beg, row_blk, nblk, p_rows)
assert(glob_row_beg < na)
glob_row_end = min(glob_row_beg + nblk, na)
......@@ -71,8 +71,8 @@ class Trace:
glob_col_end = min(glob_col_beg + nblk, na)
#print "local", (loc_row_beg, loc_row_end), (loc_col_beg, loc_col_end)
#print "global", (glob_row_beg, glob_row_end), (glob_col_beg, glob_col_end)
#print("local", (loc_row_beg, loc_row_end), (loc_col_beg, loc_col_end))
#print("global", (glob_row_beg, glob_row_end), (glob_col_beg, glob_col_end))
mat[glob_row_beg:glob_row_end, glob_col_beg:glob_col_end] = loc_mat[loc_row_beg:loc_row_end, loc_col_beg:loc_col_end]
return ((name, iteration), mat)
......@@ -271,7 +271,7 @@ class Snapshot(View):
self.set_limits(np.percentile(mat,1), np.percentile(mat,99))
def write(self):
print self._matrix, ", ", it._index
print(self._matrix, ", ", it._index)
def _get_matrix(self):
return self._trace._matrices[self._iterator.current()][self._matrix]
......
#!/usr/bin/env python
#!/usr/bin/env python3
from itertools import product
from scaling import *
......
#! /usr/bin/env python
#! /usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
import re
......
#! /usr/bin/env python
#! /usr/bin/env python3
import os
import subprocess
......@@ -8,10 +8,10 @@ with open("results_raw.txt", "w") as logfile:
path = subprocess.check_output('pwd')[:-1].decode() + "/"
for subdir, dirs, files in os.walk(rootdir):
# for file in files:
# print os.path.join(subdir, file)
# print subdir, dirs, files
# print(os.path.join(subdir, file))
# print(subdir, dirs, files )
if(len(files) != 0):
#print subdir, dirs, files
#print(subdir, dirs, files)
print("cd " + path + subdir)
logfile.write(subdir + "\n")
os.chdir(path + subdir)
......
#! /usr/bin/env python
#! /usr/bin/env python3
from collections import namedtuple
from subprocess import Popen, PIPE, STDOUT
......@@ -89,5 +89,3 @@ with open("results_sorted.txt", "w") as sortedfile:
sortedfile.write("*"*num_stars + "\n")
lines_to_write = []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment