Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
elpa
elpa
Commits
5e271fd9
Commit
5e271fd9
authored
Jul 20, 2020
by
Andreas Marek
Browse files
First attempt at going Python-3 only
Only minimal changes done so far (mostly print() stuff)
parent
c204c68e
Changes
11
Hide whitespace changes
Inline
Side-by-side
ci_test_scripts/generate_gitlab_ci_tests.py
View file @
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
...
...
generate/generate_precision.py
View file @
5e271fd9
#!/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"
)
generate_automake_test_programs.py
View file @
5e271fd9
#!/usr/bin/env python
from
__future__
import
print_function
#!/usr/bin/python3
from
itertools
import
product
language_flag
=
{
...
...
manual_cpp
View file @
5e271fd9
#!/usr/bin/python
#!/usr/bin/python
3
from
__future__
import
print_function
import
os
import
sys
import
subprocess
def
cpp_arg
(
arg
):
return
arg
.
startswith
(
"-I"
)
or
\
arg
.
startswith
(
"-D"
)
or
\
arg
.
startswith
(
"-U"
)
return
\
arg
.
startswith
(
"-I"
)
or
\
arg
.
startswith
(
"-D"
)
or
\
arg
.
startswith
(
"-U"
)
def
check_call
(
args
,
**
kwargs
):
...
...
@@ -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
])
...
...
python/examples/example.py
View file @
5e271fd9
#!/usr/bin/
env
python
#!/usr/bin/python
3
import
numpy
as
np
from
pyelpa
import
DistributedMatrix
import
sys
...
...
remove_xcompiler
View file @
5e271fd9
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
import
os
...
...
utils/matrix_plotter/plot.py
View file @
5e271fd9
...
...
@@ -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
]
...
...
utils/scaling_scripts/batch_run.py
View file @
5e271fd9
#!/usr/bin/env python
#!/usr/bin/env python
3
from
itertools
import
product
from
scaling
import
*
...
...
utils/scaling_scripts/plot.py
View file @
5e271fd9
#! /usr/bin/env python
#! /usr/bin/env python
3
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
re
...
...
utils/scaling_scripts/process.py
View file @
5e271fd9
#! /usr/bin/env python
#! /usr/bin/env python
3
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
)
...
...
utils/scaling_scripts/process_raw.py
View file @
5e271fd9
#! /usr/bin/env python
#! /usr/bin/env python
3
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
=
[]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment