@@ -18,12 +18,12 @@ def init_z(nr_points):
1818
1919def compute_partial_julia (args ):
2020 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
2222 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
2525 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 ])
2727 for i , z in enumerate (z_array ):
2828 while (n [i ] <= max_iters and np .abs (z ) <= max_norm ):
2929 z = z ** 2 - 0.622772 + 0.42193j
@@ -34,14 +34,14 @@ def compute_partial_julia(args):
3434def compute_julia (nr_points = 100 , pool_size = 2 , work_size = 15 , verbose = False ,
3535 max_iters = 255 , max_norm = 2.0 ):
3636 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
3939 with SharedMemoryManager () as shmem_mgr :
4040 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 )
4242 z_buf = np .ndarray ((size , ), dtype = np .complex , buffer = z_shmem .buf )
4343 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 )
4545 n_buf = np .ndarray ((size , ), dtype = np .int32 , buffer = n_shmem .buf )
4646 n_buf [:] = np .zeros ((size , ), dtype = np .int32 )
4747 args = [(z_shmem , n_shmem , i * work_size , min (z_buf .size , (i + 1 )* work_size ),
0 commit comments