Skip to content
GitLab
Menu
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
954eb7f2
Commit
954eb7f2
authored
Oct 30, 2018
by
Sebastian Ohlmann
Browse files
update python tests and example
parent
c92d3037
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
python/examples/example.py
View file @
954eb7f2
#!/usr/bin/env python
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
import
sys
# set some parameters for matrix layout
...
...
@@ -11,15 +11,19 @@ nblk = 16
# create distributed matrix
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
)
# function for setting the matrix
# this is the easiest but also slowest way
def
set_matrix
(
a
):
for
global_row
,
global_col
in
a
.
global_indices
():
a
.
set_data_for_global_index
(
global_row
,
global_col
,
global_row
*
global_col
)
# set a
set_matrix
(
a
)
print
(
"Call ELPA eigenvectors"
)
sys
.
stdout
.
flush
()
set_matrix
(
a
)
# now compute nev of na eigenvectors and eigenvalues
data
=
a
.
compute_eigenvectors
()
eigenvalues
=
data
[
'eigenvalues'
]
...
...
@@ -31,12 +35,13 @@ print("Done")
# which is stored in a block-cyclic distributed layout and eigenvalues contains
# all computed eigenvalues on all cores
# set a again because it has changed after calling elpa
set_matrix
(
a
)
print
(
"Call ELPA eigenvalues"
)
sys
.
stdout
.
flush
()
set_matrix
(
a
)
# now compute nev of na eigenvalues
set_matrix
(
a
)
eigenvalues
=
a
.
compute_eigenvalues
()
print
(
"Done"
)
...
...
python/tests/test_with_mpi.py
View file @
954eb7f2
...
...
@@ -54,7 +54,7 @@ def test_distributed_matrix_from_processor_layout(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_distributed_matrix_from_communicator
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
from
mpi4py
import
MPI
comm
=
MPI
.
COMM_WORLD
...
...
@@ -68,7 +68,7 @@ def test_distributed_matrix_from_communicator(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_distributed_matrix_from_world
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
float32
,
np
.
complex64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -164,7 +164,7 @@ def test_compare_eigenvalues_to_those_from_eigenvectors(na, nev, nblk):
def
test_compare_eigenvalues_to_those_from_eigenvectors_self_functions
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
# create arrays
...
...
@@ -295,7 +295,7 @@ def test_dot_product(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_dot_product_incompatible_size
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -312,7 +312,7 @@ def test_dot_product_incompatible_size(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_validate_eigenvectors
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -338,7 +338,7 @@ def test_validate_eigenvectors(na, nev, nblk):
def
test_validate_eigenvectors_to_numpy
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
numpy
import
linalg
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -364,7 +364,7 @@ def test_validate_eigenvectors_to_numpy(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_accessing_matrix
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -381,7 +381,7 @@ def test_accessing_matrix(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_global_index_iterator
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
@@ -392,7 +392,7 @@ def test_global_index_iterator(na, nev, nblk):
@
pytest
.
mark
.
parametrize
(
"na,nev,nblk"
,
parameter_list
)
def
test_global_index_access
(
na
,
nev
,
nblk
):
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
from
pyelpa
import
DistributedMatrix
for
dtype
in
[
np
.
float64
,
np
.
complex128
]:
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
,
dtype
=
dtype
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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