Loading src/common/common.h +5 −1 Original line number Diff line number Diff line Loading @@ -37,8 +37,12 @@ #define TIME_STOP #else #define TIME_DEF struct timespec __start,__end; #define TIME_START clock_gettime(CLOCK_MONOTONIC,&__start); #define TIME_START { \ MPI_Barrier(ctx -> mpi_communicator); \ clock_gettime(CLOCK_MONOTONIC,&__start); \ } #define TIME_STOP { \ MPI_Barrier(ctx -> mpi_communicator); \ clock_gettime(CLOCK_MONOTONIC,&__end); \ MPI_DB_PRINT("[TIME] elapsed time %.2lfs\n", (double)(__end.tv_sec - __start.tv_sec) \ + (__end.tv_nsec - __start.tv_nsec)/1e9); \ Loading src/tree/tree.c +22 −16 Original line number Diff line number Diff line Loading @@ -1116,6 +1116,7 @@ void exchange_points(global_context_t* ctx, top_kdtree_t* tree) ctx -> local_n_points = tot_count / ctx -> dims; int* ppp = (int*)malloc(ctx -> world_size * sizeof(int)); MPI_Allgather(&(ctx -> local_n_points), 1, MPI_INT, ppp, 1, MPI_INT, ctx -> mpi_communicator); ctx -> idx_start = 0; for(int i = 0; i < ctx -> mpi_rank; ++i) Loading @@ -1129,23 +1130,14 @@ void exchange_points(global_context_t* ctx, top_kdtree_t* tree) free(ctx -> local_data); ctx -> local_data = rcvbuffer; for(int i = 0; i < ctx -> local_n_points; ++i) { float_t d1 = ctx -> local_data[i * ctx -> dims] + 8.33416939; float_t d2 = ctx -> local_data[i * ctx -> dims + 1] + 8.22858047; if (sqrt(d1 * d1 + d2 * d2) < 1e-5) { DB_PRINT("Rank %d found it!!! idx %d\n", ctx -> mpi_rank, i); } } /* check exchange */ /* for(size_t i = 0; i < ctx -> local_n_points; ++i) { /* tree walk */ int o = compute_point_owner(ctx, tree, ctx -> local_data + (i * ctx -> dims)); if(o != ctx -> mpi_rank) DB_PRINT("rank %d got an error\n",ctx -> mpi_rank); } */ free(points_owners); free(points_per_proc); free(partition_offset); Loading Loading @@ -1497,12 +1489,12 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre { heap_batches_per_node[p] = __heap_batches_to_snd + (uint64_t)rcv_displ[p] * (uint64_t)k; } TIME_STOP /* compute everything */ MPI_DB_PRINT("[MASTER] Working on recieved points\n"); MPI_Barrier(ctx -> mpi_communicator); TIME_STOP MPI_DB_PRINT("[MASTER] Working on recieved points\n"); TIME_START for(int p = 0; p < ctx -> world_size; ++p) Loading Loading @@ -1676,6 +1668,7 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre TIME_START for(int i = 0; i < ctx -> world_size; ++i) { if(data_to_send_per_proc[i]) free(data_to_send_per_proc[i]); Loading @@ -1697,6 +1690,7 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre free(__heap_batches_to_snd); free(__rcv_points); free(__snd_points); TIME_STOP } void test_the_idea(global_context_t* ctx) Loading Loading @@ -1779,7 +1773,10 @@ void ordered_data_to_file(global_context_t* ctx) void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) { float_t *data; TIME_DEF TIME_START MPI_DB_PRINT("[MASTER] Reading file and scattering\n"); if (ctx->mpi_rank == 0) { //data = read_data_file(ctx, "../norm_data/50_blobs_more_var.npy", MY_TRUE); Loading Loading @@ -1808,7 +1805,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) // ctx -> n_points = 48*5*2000; ctx->n_points = ctx->n_points / ctx->dims; //ctx->n_points = ctx->n_points / 2; ctx->n_points = (ctx->n_points * 10) / 10; //ctx -> n_points = ctx -> world_size * 1000; mpi_printf(ctx, "Read %lu points in %u dims\n", ctx->n_points, ctx->dims); } Loading Loading @@ -1856,9 +1853,9 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) original_ps.ub_box = (float_t*)malloc(ctx -> dims * sizeof(float_t)); float_t tol = 0.002; TIME_STOP top_kdtree_t tree; TIME_DEF TIME_START top_tree_init(ctx, &tree); TIME_STOP Loading @@ -1866,6 +1863,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) TIME_START build_top_kdtree(ctx, &original_ps, &tree, k_global, tol); exchange_points(ctx, &tree); MPI_Barrier(ctx -> mpi_communicator); TIME_STOP //test_the_idea(ctx); Loading @@ -1879,8 +1877,16 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) build_local_tree(ctx, &local_tree); TIME_STOP TIME_START MPI_DB_PRINT("[MASTER] Performing ngbh search\n"); MPI_Barrier(ctx -> mpi_communicator); mpi_ngbh_search(ctx, dp_info, &tree, &local_tree, ctx -> local_data, k); MPI_Barrier(ctx -> mpi_communicator); MPI_DB_PRINT("Tot time ---->"); TIME_STOP #if defined (WRITE_NGBH) ordered_data_to_file(ctx); Loading Loading
src/common/common.h +5 −1 Original line number Diff line number Diff line Loading @@ -37,8 +37,12 @@ #define TIME_STOP #else #define TIME_DEF struct timespec __start,__end; #define TIME_START clock_gettime(CLOCK_MONOTONIC,&__start); #define TIME_START { \ MPI_Barrier(ctx -> mpi_communicator); \ clock_gettime(CLOCK_MONOTONIC,&__start); \ } #define TIME_STOP { \ MPI_Barrier(ctx -> mpi_communicator); \ clock_gettime(CLOCK_MONOTONIC,&__end); \ MPI_DB_PRINT("[TIME] elapsed time %.2lfs\n", (double)(__end.tv_sec - __start.tv_sec) \ + (__end.tv_nsec - __start.tv_nsec)/1e9); \ Loading
src/tree/tree.c +22 −16 Original line number Diff line number Diff line Loading @@ -1116,6 +1116,7 @@ void exchange_points(global_context_t* ctx, top_kdtree_t* tree) ctx -> local_n_points = tot_count / ctx -> dims; int* ppp = (int*)malloc(ctx -> world_size * sizeof(int)); MPI_Allgather(&(ctx -> local_n_points), 1, MPI_INT, ppp, 1, MPI_INT, ctx -> mpi_communicator); ctx -> idx_start = 0; for(int i = 0; i < ctx -> mpi_rank; ++i) Loading @@ -1129,23 +1130,14 @@ void exchange_points(global_context_t* ctx, top_kdtree_t* tree) free(ctx -> local_data); ctx -> local_data = rcvbuffer; for(int i = 0; i < ctx -> local_n_points; ++i) { float_t d1 = ctx -> local_data[i * ctx -> dims] + 8.33416939; float_t d2 = ctx -> local_data[i * ctx -> dims + 1] + 8.22858047; if (sqrt(d1 * d1 + d2 * d2) < 1e-5) { DB_PRINT("Rank %d found it!!! idx %d\n", ctx -> mpi_rank, i); } } /* check exchange */ /* for(size_t i = 0; i < ctx -> local_n_points; ++i) { /* tree walk */ int o = compute_point_owner(ctx, tree, ctx -> local_data + (i * ctx -> dims)); if(o != ctx -> mpi_rank) DB_PRINT("rank %d got an error\n",ctx -> mpi_rank); } */ free(points_owners); free(points_per_proc); free(partition_offset); Loading Loading @@ -1497,12 +1489,12 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre { heap_batches_per_node[p] = __heap_batches_to_snd + (uint64_t)rcv_displ[p] * (uint64_t)k; } TIME_STOP /* compute everything */ MPI_DB_PRINT("[MASTER] Working on recieved points\n"); MPI_Barrier(ctx -> mpi_communicator); TIME_STOP MPI_DB_PRINT("[MASTER] Working on recieved points\n"); TIME_START for(int p = 0; p < ctx -> world_size; ++p) Loading Loading @@ -1676,6 +1668,7 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre TIME_START for(int i = 0; i < ctx -> world_size; ++i) { if(data_to_send_per_proc[i]) free(data_to_send_per_proc[i]); Loading @@ -1697,6 +1690,7 @@ void mpi_ngbh_search(global_context_t* ctx, datapoint_info_t* dp_info, top_kdtre free(__heap_batches_to_snd); free(__rcv_points); free(__snd_points); TIME_STOP } void test_the_idea(global_context_t* ctx) Loading Loading @@ -1779,7 +1773,10 @@ void ordered_data_to_file(global_context_t* ctx) void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) { float_t *data; TIME_DEF TIME_START MPI_DB_PRINT("[MASTER] Reading file and scattering\n"); if (ctx->mpi_rank == 0) { //data = read_data_file(ctx, "../norm_data/50_blobs_more_var.npy", MY_TRUE); Loading Loading @@ -1808,7 +1805,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) // ctx -> n_points = 48*5*2000; ctx->n_points = ctx->n_points / ctx->dims; //ctx->n_points = ctx->n_points / 2; ctx->n_points = (ctx->n_points * 10) / 10; //ctx -> n_points = ctx -> world_size * 1000; mpi_printf(ctx, "Read %lu points in %u dims\n", ctx->n_points, ctx->dims); } Loading Loading @@ -1856,9 +1853,9 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) original_ps.ub_box = (float_t*)malloc(ctx -> dims * sizeof(float_t)); float_t tol = 0.002; TIME_STOP top_kdtree_t tree; TIME_DEF TIME_START top_tree_init(ctx, &tree); TIME_STOP Loading @@ -1866,6 +1863,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) TIME_START build_top_kdtree(ctx, &original_ps, &tree, k_global, tol); exchange_points(ctx, &tree); MPI_Barrier(ctx -> mpi_communicator); TIME_STOP //test_the_idea(ctx); Loading @@ -1879,8 +1877,16 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) build_local_tree(ctx, &local_tree); TIME_STOP TIME_START MPI_DB_PRINT("[MASTER] Performing ngbh search\n"); MPI_Barrier(ctx -> mpi_communicator); mpi_ngbh_search(ctx, dp_info, &tree, &local_tree, ctx -> local_data, k); MPI_Barrier(ctx -> mpi_communicator); MPI_DB_PRINT("Tot time ---->"); TIME_STOP #if defined (WRITE_NGBH) ordered_data_to_file(ctx); Loading