Commit a62fa254 authored by Ultima's avatar Ultima
Browse files

Fixed import of MPI_dummy.py

Fixed zero-centering mask for even dimensions.
parent c37dd717
......@@ -132,4 +132,26 @@ COMPLEX = _datatype("MPI_COMPLEX")
DOUBLE_COMPLEX = _datatype("MPI_DOUBLE_COMPLEX")
COMM_WORLD = Intracomm('MPI_dummy_COMM_WORLD')
class _comm_wrapper(object):
def __init__(self, name):
self.cache = None
self.name = name
@property
def comm(self):
if self.cache is None:
self.cache = Intracomm(self.name)
return self.cache
def __getattr__(self, x):
return self.comm.__getattribute__(x)
COMM_WORLD = _comm_wrapper('MPI_dummy_COMM_WORLD')
......@@ -1815,7 +1815,7 @@ class point_space(space):
def __repr__(self):
string = ""
string += str(type(self)) + "\n"
string += "paradict: " + str(self.paradict)
string += "paradict: " + str(self.paradict) + "\n"
string += 'dtype: ' + str(self.dtype) + "\n"
string += 'datamodel: ' + str(self.datamodel) + "\n"
string += 'comm: ' + self.comm.name + "\n"
......
......@@ -1297,7 +1297,6 @@ class distributor(object):
distribution_strategy='freeform',
comm=self.comm)
# disperse the data one after another
print ('i', i, temp_data_update)
self._disperse_data_primitive(
data=data,
to_key=to_key_list[i],
......
......@@ -311,6 +311,7 @@ class fft_fftw(fft):
return return_val
# The instances of plan_and_info store the fftw plan and all
# other information needed in order to perform a mpi-fftw transformation
class _fftw_plan_and_info(object):
......@@ -354,7 +355,9 @@ class _fftw_plan_and_info(object):
self.overall_sign = (-1)**np.sum(
np.array(self.in_zero_centered_dimensions) *
np.array(self.out_zero_centered_dimensions))
np.array(self.out_zero_centered_dimensions) *
(np.array(self.global_input_shape)//2 % 2)
)
self.local_node_dimensions = np.append((self.fftw_local_size[1],),
self.global_input_shape[1:])
......
......@@ -1672,7 +1672,7 @@ class rg_space(point_space):
else:
fig.canvas.draw()
def __repr__(self):
string = super(rg_space, self).__repr__()
string += repr(self.fft_machine) + "\n "
return string
\ No newline at end of file
def __repr__(self):
string = super(rg_space, self).__repr__()
string += repr(self.fft_machine) + "\n "
return string
\ No newline at end of file
......@@ -930,6 +930,35 @@ class Test_RG_Space(unittest.TestCase):
0.03107832 + 0.04714527j, 0.01865586 + 0.08640926j,
-0.03414096 + 0.02605602j, 0.09492552 - 0.01306734j]])))
###############################################################################
@parameterized.expand(
itertools.product(fft_modules,
[(6, 6), (8, 8), (6, 8)],
[(True, True), (False, False),
(True, False), (False, True)],
[(True, True), (False, False),
(True, False), (False, True)],
DATAMODELS['rg_space']),
testcase_func_name=custom_name_func)
def test_calc_transform_variations(self, fft_module, shape, zerocenter_in,
zerocenter_out, datamodel):
data = np.arange(np.prod(shape)).reshape(shape)
x = rg_space(shape, complexity=2, zerocenter=zerocenter_in,
fft_module=fft_module, datamodel=datamodel)
y = x.get_codomain()
y.paradict['zerocenter'] = zerocenter_out
casted_data = x.cast(data)
x_result = x.calc_transform(casted_data, codomain=y)
np_data = data.copy()
np_data = np.fft.fftshift(np_data, axes=np.where(zerocenter_in)[0])
np_data = np.fft.fftn(np_data)
np_data = np.fft.fftshift(np_data, axes=np.where(zerocenter_out)[0])
np_result = np_data/np.prod(shape)
assert(check_almost_equality(x, x_result, np_result))
###############################################################################
@parameterized.expand(DATAMODELS['rg_space'],
......
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