Commit f02c57bb authored by lykos98's avatar lykos98
Browse files

working h1, waiting for code cleanup

parent 7ce795f0
Loading
Loading
Loading
Loading
+722 −57

File changed.

Preview size limit exceeded, changes collapsed.

+43 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
#include "mpi.h"
#include <time.h>

#define ARRAY_INCREMENT 100

#define FREE_NOT_NULL(x) if(x){free(x); x = NULL;}

void get_context(global_context_t* ctx)
@@ -124,3 +126,44 @@ void generate_random_matrix(
	return;
}


void lu_dynamic_array_allocate(lu_dynamic_array_t * a)
{
    a -> data = (idx_t*)malloc(ARRAY_INCREMENT*sizeof(idx_t));
    a -> count = 0;
    a -> size = ARRAY_INCREMENT;
}

void lu_dynamic_array_pushBack(lu_dynamic_array_t * a, idx_t p)
{
    if(a -> count < a -> size)
    {
        a -> data[a -> count] =  p;
        a -> count += 1;
    }
    else{
        a -> size += ARRAY_INCREMENT;
        a -> data = realloc(a -> data, a -> size * sizeof(idx_t));
        a -> data[a -> count] =  p;
        a -> count += 1;
    }
}

void lu_dynamic_array_Reset(lu_dynamic_array_t * a)
{
    a -> count = 0;
}

void lu_dynamic_array_reserve(lu_dynamic_array_t * a, idx_t n)
{
    a -> data = realloc(a -> data, n*sizeof(idx_t));
    a -> size = n;
}

void lu_dynamic_array_init(lu_dynamic_array_t * a)
{
    a -> data = NULL;
    a -> count = 0;
    a -> size = 0;
}
+13 −0
Original line number Diff line number Diff line
@@ -142,8 +142,16 @@ struct pointset_t
	float_t* ub_box;
};


struct lu_dynamic_array_t {
  idx_t *data;
  idx_t size;
  idx_t count;
};

typedef struct pointset_t pointset_t;
typedef struct global_context_t global_context_t;
typedef struct lu_dynamic_array_t lu_dynamic_array_t;

void mpi_printf(global_context_t*, const char *fmt, ...);
void get_context(global_context_t*);
@@ -152,5 +160,10 @@ void free_context(global_context_t* );
void free_pointset(pointset_t* );

void generate_random_matrix(float_t** ,int ,size_t ,global_context_t*);
void lu_dynamic_array_allocate(lu_dynamic_array_t * a);
void lu_dynamic_array_pushBack(lu_dynamic_array_t * a, idx_t p);
void lu_dynamic_array_Reset(lu_dynamic_array_t * a);
void lu_dynamic_array_reserve(lu_dynamic_array_t * a, idx_t n);
void lu_dynamic_array_init(lu_dynamic_array_t * a);

+878 −6

File changed.

Preview size limit exceeded, changes collapsed.

+36 −3
Original line number Diff line number Diff line
@@ -23,6 +23,13 @@
#define VERBOSE_TRUE 1
#define VERBOSE_FALSE 0

typedef struct center_t
{
    int cluster_idx;
    idx_t idx;
    float_t density;
} center_t;


typedef struct mpi_double_int{
	float_t val;
@@ -80,9 +87,35 @@ typedef struct top_kdtree_t

} top_kdtree_t;




typedef struct border_t {
  float_t density;
  float_t error;
  idx_t idx;
} border_t;

typedef struct sparse_border_t {
  idx_t i;
  idx_t j;
  idx_t idx;
  float_t density;
  float_t error;
} sparse_border_t;

typedef struct adj_list_t {
  idx_t count;
  idx_t size;
  struct sparse_border_t* data;
} adj_list_t;


typedef struct clusters_t {
  int use_sparse_borders;
  struct adj_list_t *sparse_borders;
  struct lu_dynamic_array_t centers;
  struct border_t **borders;
  struct border_t *__borders_data;
  idx_t n;
} clusters_t;


void simulate_master_read_and_scatter(int, size_t, global_context_t* );