Commit 9ae06572 authored by lykos98's avatar lykos98
Browse files

added working kstar density

parent 8507be87
Loading
Loading
Loading
Loading
+33 −23

File changed.

Preview size limit exceeded, changes collapsed.

+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ void get_context(global_context_t* ctx)
    ctx -> n_halo_points_send = NULL;
    ctx -> halo_datapoints  = NULL;
    ctx -> local_datapoints = NULL;
    ctx -> __recv_heap_buffers = NULL;
}

void free_context(global_context_t* ctx)
@@ -39,14 +40,17 @@ void free_context(global_context_t* ctx)
    {
        for(int i = 0; i < ctx -> world_size; ++i) 
        {
            /*
            for(int j = 0; j < ctx -> n_halo_points_recv[i]; ++j)
            {
                FREE_NOT_NULL(ctx -> halo_datapoints[i][j].ngbh.data);
            }
            */
            FREE_NOT_NULL(ctx -> halo_datapoints[i]);
        }
    }
    FREE_NOT_NULL(ctx -> halo_datapoints);
    FREE_NOT_NULL(ctx -> __recv_heap_buffers);

    if(ctx -> idx_halo_points_recv)
    {
+4 −0
Original line number Diff line number Diff line
@@ -29,9 +29,12 @@ typedef struct datapoint_info_t {
	#define float_t double
#endif


#define MY_TRUE  1
#define MY_FALSE 0

#define CHECK_ALLOCATION(x) if(!x){printf("[!!!] %d rank encountered failed allocation at line %s ", ctx -> mpi_rank, __LINE__ ); exit(1);};

#define DB_PRINT(...) printf(__VA_ARGS__)
#ifdef NDEBUG
	#undef DB_PRINT(...)
@@ -126,6 +129,7 @@ struct global_context_t
    int* rank_n_points;
	char processor_mame[MPI_MAX_PROCESSOR_NAME];
	MPI_Comm mpi_communicator;
    heap_node* __recv_heap_buffers;
};

struct pointset_t
+14 −5
Original line number Diff line number Diff line
@@ -2366,12 +2366,20 @@ void find_foreign_nodes(global_context_t* ctx, datapoint_info_t* dp, datapoint_i
    {
        for(int j = 0; j < n_heap_to_recv[i]; ++j)
        {
            /*
            foreign_dp[i][j].array_idx = array_indexes_to_request[i][j];
            init_heap(&(foreign_dp[i][j].ngbh));
            allocate_heap(&(foreign_dp[i][j].ngbh), k);
            foreign_dp[i][j].ngbh.N     = k;
            foreign_dp[i][j].ngbh.count = k;
            memcpy(foreign_dp[i][j].ngbh.data, heap_buffer_to_recv + k * (j + rdispls[i]), k * sizeof(heap_node));
            */

            foreign_dp[i][j].array_idx = array_indexes_to_request[i][j];
            //init_heap(&(foreign_dp[i][j].ngbh));
            foreign_dp[i][j].ngbh.N     = k;
            foreign_dp[i][j].ngbh.count = k;
            foreign_dp[i][j].ngbh.data =  heap_buffer_to_recv + k * (j + rdispls[i]);

            if(foreign_dp[i][j].ngbh.data[0].array_idx != array_indexes_to_request[i][j])
            {
@@ -2402,7 +2410,8 @@ void find_foreign_nodes(global_context_t* ctx, datapoint_info_t* dp, datapoint_i
    free(count_to_request);
    free(capacities);

    free(heap_buffer_to_recv);
    /* free(heap_buffer_to_recv); this needs to be preserved*/
    ctx -> __recv_heap_buffers = heap_buffer_to_recv;
    free(heap_buffer_to_send);
    free(idx_buffer_to_send);
    free(idx_buffer_to_recv);
@@ -2701,7 +2710,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 * 0.5) / 10;
        ctx->n_points = (ctx->n_points * 0.1) / 10;
        // ctx -> n_points = ctx -> world_size * 1000;

        //ctx -> n_points = 10000000 * ctx -> world_size;
@@ -2817,7 +2826,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx)
    elapsed_time = TIME_STOP;
    //id = 3.920865231328582;
    //id = 4.008350298212649;
    //id = 4.;
    id = 4.;
    LOG_WRITE("ID estimate", elapsed_time)

    MPI_DB_PRINT("ID %lf \n",id);