def main(): data = hpx.GlobalMemory.alloc_cyclic(NUM_NODE, (DATA_PER_NODE, DIM), np.dtype(np.float)) generate_data_complete = hpx.And(NUM_NODE) for i in range(NUM_NODE): generate_data(data[i], node_size(i), rsync_lco=generate_data_complete) generate_data_complete.wait() data_this_block = data[0].try_pin() centers = data_this_block[:K] data[0].unpin() iterations = 0 while iterations < MAX_ITERATION: count_lco = hpx.Reduce(NUM_NODE, (K, ), np.dtype(np.int), initialize_count, sum_count) position_lco = hpx.Reduce(NUM_NODE, (K, DIM), np.dtype(np.float), initialize_position, sum_position) and_lco = hpx.And(NUM_NODE) for i in range(NUM_NODE): calculate_centers(data[i], node_size(i), centers, count_lco, position_lco, and_lco) counts = count_lco.get() positions = position_lco.get() centers = positions / counts.reshape((K, 1)) and_lco.wait() count_lco.delete_sync() position_lco.delete_sync() and_lco.delete_sync() iterations = iterations + 1 hpx.exit()
def main(): start = hpx.time_now() num_ranks = hpx.get_num_ranks() and_lco = hpx.And(num_ranks) for i in range(num_ranks): worker(hpx.THERE(i), i, num_ranks, rsync_lco=and_lco) and_lco.wait() print(hpx.time_elapsed_ms(start)) hpx.exit()
def main(num_action): start = hpx.time_now() and_lco = hpx.And(num_action) for i in range(num_action): calculate( hpx.HERE(), 5765760 // num_action, rsync_lco=and_lco) # 5040 is lcm(2,3,4,5,6,7,8,9,10,12,14,15,16) and_lco.wait() print(hpx.time_elapsed_ms(start)) hpx.exit()
def main(): num_ranks = hpx.get_num_ranks() print(num_ranks) array = hpx.GlobalMemory.alloc_cyclic(num_ranks, (64, 1024, 1024), dtype=np.dtype(float)) start = hpx.time_now() and_lco = hpx.And(num_ranks) for i in range(num_ranks): copy_from_array(hpx.THERE(i), array, i, num_ranks, rsync_lco=and_lco) and_lco.wait() print(hpx.time_elapsed_ms(start)) hpx.exit()
def main(): time = np.zeros((18, )) for j in range(18): num_gil = 2**j start = hpx.time_now() and_lco = hpx.And(num_action) for i in range(num_action): calculate(hpx.HERE(), num_gil, rsync_lco=and_lco) and_lco.wait() current_time = hpx.time_elapsed_ms(start) print(current_time) time[j] = current_time print(time) time.dump("time.bin") hpx.exit()
def main(n_parts, n_partition, theta_c, domain_size): set_domain_size(hpx.NULL(), domain_size, sync='rsync') root = create_node(0.0, domain_size) parts = generate_parts(n_parts, domain_size, root.addr) done = hpx.Future(shape=(1, ), dtype=moment_type) partition_node(root[0], root[0], parts, n_parts, n_partition, sync='lsync', rsync_lco=done) done.wait() done.delete() alldone = hpx.And(n_parts) spawn_computation(root[0], root[0].addr.addr, root, alldone, theta_c) alldone.wait() alldone.delete() hpx.exit()