dobj.py 1.66 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2017 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.

Martin Reinecke's avatar
Martin Reinecke committed
19
20
try:
    from mpi4py import MPI
Martin Reinecke's avatar
Martin Reinecke committed
21
    if MPI.COMM_WORLD.Get_size() == 1:
Martin Reinecke's avatar
Martin Reinecke committed
22
        from .data_objects.numpy_do import *
Martin Reinecke's avatar
Martin Reinecke committed
23
        # mprint("MPI found, but only with one task, using numpy_do...")
Martin Reinecke's avatar
Martin Reinecke committed
24
25
    else:
        from .data_objects.distributed_do import *
Martin Reinecke's avatar
Martin Reinecke committed
26
        # mprint("MPI with multiple tasks found, using distributed_do...")
Martin Reinecke's avatar
Martin Reinecke committed
27
28
except ImportError:
    from .data_objects.numpy_do import *
Martin Reinecke's avatar
Martin Reinecke committed
29
30
31
32
    # mprint("MPI not found, using numpy_do...")

__all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full",
           "empty", "zeros", "ones", "empty_like", "vdot", "abs", "exp",
Martin Reinecke's avatar
Martin Reinecke committed
33
           "log", "tanh", "sqrt", "from_object", "from_random",
34
35
           "local_data", "ibegin", "ibegin_from_shape", "np_allreduce_sum",
           "distaxis", "from_local_data", "from_global_data", "to_global_data",
Martin Reinecke's avatar
Martin Reinecke committed
36
           "redistribute", "default_distaxis", "mprint", "is_numpy"]