@@ -18,12 +18,12 @@ def init_z(nr_points):
18
18
19
19
def compute_partial_julia (args ):
20
20
z_shmem , n_shmem , idx_begin , idx_end , max_iters , max_norm = args
21
- z_sizeof = np .dtype (np .complex ).itemsize
21
+ z_size = np .dtype (np .complex ).itemsize
22
22
z_array = np .ndarray ((idx_end - idx_begin , ), dtype = np .complex ,
23
- buffer = z_shmem .buf [z_sizeof * idx_begin :z_sizeof * idx_end ])
24
- n_sizeof = np .dtype (np .int32 ).itemsize
23
+ buffer = z_shmem .buf [z_size * idx_begin :z_size * idx_end ])
24
+ n_size = np .dtype (np .int32 ).itemsize
25
25
n = np .ndarray ((idx_end - idx_begin , ), dtype = np .int32 ,
26
- buffer = n_shmem .buf [n_sizeof * idx_begin :n_sizeof * idx_end ])
26
+ buffer = n_shmem .buf [n_size * idx_begin :n_size * idx_end ])
27
27
for i , z in enumerate (z_array ):
28
28
while (n [i ] <= max_iters and np .abs (z ) <= max_norm ):
29
29
z = z ** 2 - 0.622772 + 0.42193j
@@ -34,14 +34,14 @@ def compute_partial_julia(args):
34
34
def compute_julia (nr_points = 100 , pool_size = 2 , work_size = 15 , verbose = False ,
35
35
max_iters = 255 , max_norm = 2.0 ):
36
36
size = nr_points ** 2
37
- complex_size = np .dtype (np .complex ).itemsize
38
- int32_size = np .dtype (np .int32 ).itemsize
37
+ z_size = np .dtype (np .complex ).itemsize
38
+ n_size = np .dtype (np .int32 ).itemsize
39
39
with SharedMemoryManager () as shmem_mgr :
40
40
with mp .Pool (pool_size ) as pool :
41
- z_shmem = shmem_mgr .SharedMemory (size = complex_size * size )
41
+ z_shmem = shmem_mgr .SharedMemory (size = z_size * size )
42
42
z_buf = np .ndarray ((size , ), dtype = np .complex , buffer = z_shmem .buf )
43
43
z_buf [:] = init_z (nr_points )
44
- n_shmem = shmem_mgr .SharedMemory (size = int32_size * size )
44
+ n_shmem = shmem_mgr .SharedMemory (size = n_size * size )
45
45
n_buf = np .ndarray ((size , ), dtype = np .int32 , buffer = n_shmem .buf )
46
46
n_buf [:] = np .zeros ((size , ), dtype = np .int32 )
47
47
args = [(z_shmem , n_shmem , i * work_size , min (z_buf .size , (i + 1 )* work_size ),
0 commit comments