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
Neel Shah
NIFTy
Commits
fee7b4d2
Commit
fee7b4d2
authored
Jul 18, 2018
by
Martin Reinecke
Browse files
fixes
parent
1be2685f
Changes
4
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
fee7b4d2
...
...
@@ -348,6 +348,12 @@ def np_allreduce_min(arr):
return
res
def
np_allreduce_max
(
arr
):
res
=
np
.
empty_like
(
arr
)
_comm
.
Allreduce
(
arr
,
res
,
MPI
.
MAX
)
return
res
def
distaxis
(
arr
):
return
arr
.
_distaxis
...
...
nifty5/data_objects/numpy_do.py
View file @
fee7b4d2
...
...
@@ -75,6 +75,10 @@ def np_allreduce_min(arr):
return
arr
def
np_allreduce_max
(
arr
):
return
arr
def
distaxis
(
arr
):
return
-
1
...
...
nifty5/dobj.py
View file @
fee7b4d2
...
...
@@ -33,6 +33,7 @@ __all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full",
"empty"
,
"zeros"
,
"ones"
,
"empty_like"
,
"vdot"
,
"exp"
,
"log"
,
"tanh"
,
"sqrt"
,
"from_object"
,
"from_random"
,
"local_data"
,
"ibegin"
,
"ibegin_from_shape"
,
"np_allreduce_sum"
,
"np_allreduce_min"
,
"np_allreduce_max"
,
"distaxis"
,
"from_local_data"
,
"from_global_data"
,
"to_global_data"
,
"redistribute"
,
"default_distaxis"
,
"is_numpy"
,
"lock"
,
"locked"
]
nifty5/operators/dof_distributor.py
View file @
fee7b4d2
...
...
@@ -41,9 +41,9 @@ class DOFDistributor(LinearOperator):
----------
dofdex: Field of integers
An integer Field on exactly one Space establishing the association
between the locations in the operators target and the underlying
between the locations in the operator
'
s target and the underlying
degrees of freedom in its domain.
It has to start at 0 and it increases monotonicly, no empty bins are
It has to start at 0 and it increases monotonic
al
ly, no empty bins are
allowed.
target: Domain, tuple of Domain, or DomainTuple, optional
The target of the operator. If not specified, the domain of the dofdex
...
...
@@ -70,12 +70,17 @@ class DOFDistributor(LinearOperator):
if
partner
!=
dofdex
.
domain
[
0
]:
raise
ValueError
(
"incorrect dofdex domain"
)
nbin
=
dofdex
.
max
()
ldat
=
dofdex
.
local_data
if
ldat
.
size
==
0
:
# can happen for weird configurations
nbin
=
0
else
:
nbin
=
ldat
.
max
()
nbin
=
dobj
.
np_allreduce_max
(
np
.
array
(
nbin
))[()]
+
1
if
partner
.
scalar_dvol
is
not
None
:
wgt
=
np
.
bincount
(
dofdex
.
local_data
.
ravel
(),
minlength
=
nbin
)
wgt
=
wgt
*
partner
.
scalar_dvol
else
:
dvol
=
dobj
.
lo
c
al_data
(
partner
.
dvol
)
dvol
=
Field
.
from_g
lo
b
al_data
(
partner
,
partner
.
dvol
).
local_data
wgt
=
np
.
bincount
(
dofdex
.
local_data
.
ravel
(),
minlength
=
nbin
,
weights
=
dvol
)
# The explicit conversion to float64 is necessary because bincount
...
...
Write
Preview
Supports
Markdown
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