Loading src/common/common.c +2 −3 Original line number Diff line number Diff line Loading @@ -72,14 +72,13 @@ void mpi_printf(global_context_t* ctx, const char *fmt, ...) void generate_random_matrix( float_t** data, int dimensions, size_t nmin, size_t nmax, size_t n, global_context_t* ctx) { /* seed the random number generator */ srand((unsigned)time(NULL) + ctx -> mpi_rank * ctx -> world_size + ctx -> __processor_name_len); size_t n = rand() % (nmax - nmin) + nmin; //size_t n = rand() % (nmax - nmin) + nmin; float_t* local_data = (float_t*)malloc(dimensions*n*sizeof(float_t)); for(size_t i = 0; i < dimensions*n; ++i) local_data[i] = (float_t)rand()/(float_t)RAND_MAX; *data = local_data; Loading src/common/common.h +1 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,6 @@ void print_global_context(global_context_t* ); void free_context(global_context_t* ); void free_pointset(pointset_t* ); void generate_random_matrix(float_t** ,int ,size_t ,size_t ,global_context_t*); void generate_random_matrix(float_t** ,int ,size_t ,global_context_t*); src/tree/tree.c +31 −6 Original line number Diff line number Diff line Loading @@ -723,7 +723,7 @@ top_kdtree_node_t* top_tree_generate_node(global_context_t* ctx, top_kdtree_t* t void tree_print(global_context_t* ctx, top_kdtree_node_t* root) { MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tdata %lf", root, root -> split_dim, root -> data); MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tsplit_val %lf", root, root -> split_dim, root -> split_val); MPI_DB_PRINT("\n\tparent %p", root -> parent); MPI_DB_PRINT("\n\towner %d", root -> owner); MPI_DB_PRINT("\n\tbox"); Loading @@ -735,6 +735,23 @@ void tree_print(global_context_t* ctx, top_kdtree_node_t* root) if(root -> rch) tree_print(ctx, root -> rch); } void tree_print_leaves(global_context_t* ctx, top_kdtree_node_t* root) { if(root -> owner != -1) { MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tsplit_val %lf", root, root -> split_dim, root -> split_val); MPI_DB_PRINT("\n\tparent %p", root -> parent); MPI_DB_PRINT("\n\towner %d", root -> owner); MPI_DB_PRINT("\n\tbox"); MPI_DB_PRINT("\n\tlch %p", root -> lch); MPI_DB_PRINT("\n\trch %p\n", root -> rch); for(size_t d = 0; d < ctx -> dims; ++d) MPI_DB_PRINT("\n\t d%d:[%lf, %lf]",(int)d, root -> lb_node_box[d], root -> ub_node_box[d]); MPI_DB_PRINT("\n"); } if(root -> lch) tree_print_leaves(ctx, root -> lch); if(root -> rch) tree_print_leaves(ctx, root -> rch); } void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree_t *tree, int n_bins, float_t tolerance) { size_t tot_n_points = 0; Loading Loading @@ -804,7 +821,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree * ub equal to parent except for the dim of splitting */ int parent_split_dim = current_node -> parent -> split_dim; float_t parent_hp = current_node -> parent -> data; float_t parent_hp = current_node -> parent -> split_val; memcpy(current_node -> lb_node_box, current_node -> parent -> lb_node_box, ctx -> dims * sizeof(float_t)); memcpy(current_node -> ub_node_box, current_node -> parent -> ub_node_box, ctx -> dims * sizeof(float_t)); Loading @@ -820,7 +837,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree current_node -> parent -> rch = current_node; int parent_split_dim = current_node -> parent -> split_dim; float_t parent_hp = current_node -> parent -> data; float_t parent_hp = current_node -> parent -> split_val; /* * right child has ub equal to parent Loading Loading @@ -855,7 +872,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree guess_t g = compute_median_pure_binning(ctx, ¤t_pointset, fraction, current_partition.d, n_bins, tolerance); int pv = partition_data_around_value(current_pointset.data, ctx->dims, current_partition.d, 0, current_pointset.n_points, g.x_guess); current_node -> data = g.x_guess; current_node -> split_val = g.x_guess; size_t points_left = (size_t)pv; size_t points_right = current_partition.n_points - points_left; Loading Loading @@ -936,18 +953,26 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) */ /* read from files */ if (ctx->mpi_rank == 0) { data = read_data_file(ctx, "../norm_data/std_LR_091_0000", MY_TRUE); data = read_data_file(ctx, "../norm_data/blobs.npy", MY_TRUE); ctx->dims = 2; // std_g0163178_Me14_091_0000 // data = // read_data_file(ctx,"../norm_data/std_g0163178_Me14_091_0000",MY_TRUE); // ctx -> n_points = 48*5*2000; ctx->dims = 5; ctx->n_points = ctx->n_points / ctx->dims; mpi_printf(ctx, "Read %lu points in %u dims\n", ctx->n_points, ctx->dims); } /* ctx -> dims = 2; ctx -> n_points = 1000000; generate_random_matrix(&data, ctx -> dims , ctx -> n_points, ctx); */ /* communicate the total number of points*/ MPI_Bcast(&(ctx->dims), 1, MPI_UINT32_T, 0, ctx->mpi_communicator); MPI_Bcast(&(ctx->n_points), 1, MPI_UINT64_T, 0, ctx->mpi_communicator); Loading src/tree/tree.h +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ typedef struct partition_queue_t typedef struct top_kdtree_node_t { float_t data; float_t split_val; float_t* lb_node_box; //Needed? float_t* ub_node_box; //Needed? int owner; Loading Loading
src/common/common.c +2 −3 Original line number Diff line number Diff line Loading @@ -72,14 +72,13 @@ void mpi_printf(global_context_t* ctx, const char *fmt, ...) void generate_random_matrix( float_t** data, int dimensions, size_t nmin, size_t nmax, size_t n, global_context_t* ctx) { /* seed the random number generator */ srand((unsigned)time(NULL) + ctx -> mpi_rank * ctx -> world_size + ctx -> __processor_name_len); size_t n = rand() % (nmax - nmin) + nmin; //size_t n = rand() % (nmax - nmin) + nmin; float_t* local_data = (float_t*)malloc(dimensions*n*sizeof(float_t)); for(size_t i = 0; i < dimensions*n; ++i) local_data[i] = (float_t)rand()/(float_t)RAND_MAX; *data = local_data; Loading
src/common/common.h +1 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,6 @@ void print_global_context(global_context_t* ); void free_context(global_context_t* ); void free_pointset(pointset_t* ); void generate_random_matrix(float_t** ,int ,size_t ,size_t ,global_context_t*); void generate_random_matrix(float_t** ,int ,size_t ,global_context_t*);
src/tree/tree.c +31 −6 Original line number Diff line number Diff line Loading @@ -723,7 +723,7 @@ top_kdtree_node_t* top_tree_generate_node(global_context_t* ctx, top_kdtree_t* t void tree_print(global_context_t* ctx, top_kdtree_node_t* root) { MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tdata %lf", root, root -> split_dim, root -> data); MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tsplit_val %lf", root, root -> split_dim, root -> split_val); MPI_DB_PRINT("\n\tparent %p", root -> parent); MPI_DB_PRINT("\n\towner %d", root -> owner); MPI_DB_PRINT("\n\tbox"); Loading @@ -735,6 +735,23 @@ void tree_print(global_context_t* ctx, top_kdtree_node_t* root) if(root -> rch) tree_print(ctx, root -> rch); } void tree_print_leaves(global_context_t* ctx, top_kdtree_node_t* root) { if(root -> owner != -1) { MPI_DB_PRINT("Node %p: \n\tsplit_dim %d \n\tsplit_val %lf", root, root -> split_dim, root -> split_val); MPI_DB_PRINT("\n\tparent %p", root -> parent); MPI_DB_PRINT("\n\towner %d", root -> owner); MPI_DB_PRINT("\n\tbox"); MPI_DB_PRINT("\n\tlch %p", root -> lch); MPI_DB_PRINT("\n\trch %p\n", root -> rch); for(size_t d = 0; d < ctx -> dims; ++d) MPI_DB_PRINT("\n\t d%d:[%lf, %lf]",(int)d, root -> lb_node_box[d], root -> ub_node_box[d]); MPI_DB_PRINT("\n"); } if(root -> lch) tree_print_leaves(ctx, root -> lch); if(root -> rch) tree_print_leaves(ctx, root -> rch); } void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree_t *tree, int n_bins, float_t tolerance) { size_t tot_n_points = 0; Loading Loading @@ -804,7 +821,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree * ub equal to parent except for the dim of splitting */ int parent_split_dim = current_node -> parent -> split_dim; float_t parent_hp = current_node -> parent -> data; float_t parent_hp = current_node -> parent -> split_val; memcpy(current_node -> lb_node_box, current_node -> parent -> lb_node_box, ctx -> dims * sizeof(float_t)); memcpy(current_node -> ub_node_box, current_node -> parent -> ub_node_box, ctx -> dims * sizeof(float_t)); Loading @@ -820,7 +837,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree current_node -> parent -> rch = current_node; int parent_split_dim = current_node -> parent -> split_dim; float_t parent_hp = current_node -> parent -> data; float_t parent_hp = current_node -> parent -> split_val; /* * right child has ub equal to parent Loading Loading @@ -855,7 +872,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree guess_t g = compute_median_pure_binning(ctx, ¤t_pointset, fraction, current_partition.d, n_bins, tolerance); int pv = partition_data_around_value(current_pointset.data, ctx->dims, current_partition.d, 0, current_pointset.n_points, g.x_guess); current_node -> data = g.x_guess; current_node -> split_val = g.x_guess; size_t points_left = (size_t)pv; size_t points_right = current_partition.n_points - points_left; Loading Loading @@ -936,18 +953,26 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx) */ /* read from files */ if (ctx->mpi_rank == 0) { data = read_data_file(ctx, "../norm_data/std_LR_091_0000", MY_TRUE); data = read_data_file(ctx, "../norm_data/blobs.npy", MY_TRUE); ctx->dims = 2; // std_g0163178_Me14_091_0000 // data = // read_data_file(ctx,"../norm_data/std_g0163178_Me14_091_0000",MY_TRUE); // ctx -> n_points = 48*5*2000; ctx->dims = 5; ctx->n_points = ctx->n_points / ctx->dims; mpi_printf(ctx, "Read %lu points in %u dims\n", ctx->n_points, ctx->dims); } /* ctx -> dims = 2; ctx -> n_points = 1000000; generate_random_matrix(&data, ctx -> dims , ctx -> n_points, ctx); */ /* communicate the total number of points*/ MPI_Bcast(&(ctx->dims), 1, MPI_UINT32_T, 0, ctx->mpi_communicator); MPI_Bcast(&(ctx->n_points), 1, MPI_UINT64_T, 0, ctx->mpi_communicator); Loading
src/tree/tree.h +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ typedef struct partition_queue_t typedef struct top_kdtree_node_t { float_t data; float_t split_val; float_t* lb_node_box; //Needed? float_t* ub_node_box; //Needed? int owner; Loading