-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.py
50 lines (37 loc) · 995 Bytes
/
sanity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import minifftw as m
import sys
import time
import numpy as np
import random
def checker(a, b):
ok = 0
not_ok = 0
for (i,j) in zip(a, b):
if i < j + 0.05 and i > j - 0.05:
ok += 1
else:
not_ok += 1
print("Ok: {}, Not Ok: {}".format(ok, not_ok))
data_len = int(2**18)
nr_of_threads = 1
flags = 0
m.init(sys.argv, nr_of_threads, flags)
data_in = np.zeros(data_len) + np.zeros(data_len) * 1j
#print(data_in)
p_fwd = m.plan_dft_1d(data_in, data_in, m.FFTW_FORWARD, m.FFTW_ESTIMATE);
p_bwd = m.plan_dft_1d(data_in, data_in, m.FFTW_BACKWARD, m.FFTW_ESTIMATE);
for i in range(0, len(data_in)):
data_in[i] = i + i*1j
data_orig = data_in.copy()
for i in range(0, 100):
m.execute(p_fwd)
m.execute(p_bwd)
data_in /= data_len
# if m.get_mpi_rank() == 0:
# print(data_in)
if m.get_mpi_rank() == 0:
checker(data_orig, data_in)
#print(data_orig, "\n", data_in)
#print(data_in, data_out)
time.sleep(1)
m.finit()