Skip to content
Snippets Groups Projects
Select Git revision
  • 536e0993b50232be3215cfb7a26dea5a9d9e0039
  • main default protected
  • h1_optimization
  • v0.0.6
  • v0.0.5
  • v0.0.2
  • v0.0.1
7 results

tree.c

Blame
  • tree.c 118.47 KiB
    /*
     * Implementation of a distributed memory  kd-tree
     * The idea is to have a top level domain decomposition with a shallow shared
     * top level tree between computational nodes.
     *
     * Then each domain has a different set of points to work on separately
     * the top tree serves as a map to know later on in which processor ask for
     * neighbors
     */
    #include "tree.h"
    #include "heap.h"
    #include "kdtreeV2.h"
    #include "mpi.h"
    #include <math.h>
    #include <stdint.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <omp.h>
    #include <sys/sysinfo.h>
    
    //#define WRITE_NGBH
    //#define WRITE_TOP_NODES
    //#define WRITE_DENSITY
    #define WRITE_CLUSTER_ASSIGN_H1
    
    /* 
     * Maximum bytes to send with a single mpi send/recv, used 
     * while communicating results of ngbh search
     */
    
    /* Maximum allowed is 4GB */
    //#define MAX_MSG_SIZE 4294967296
    
    /* Used slices of 10 mb ? Really good? Maybe at the cause of TID thing */
    #define MAX_MSG_SIZE 1000000000 
    
    #ifdef USE_FLOAT32
    #define MPI_MY_FLOAT MPI_FLOAT
    #else
    #define MPI_MY_FLOAT MPI_DOUBLE
    #endif
    
    #define HERE printf("%d reached line %d\n", ctx -> mpi_rank, __LINE__);
    
    #define I_AM_MASTER ctx->mpi_rank == 0
    
    #define TOP_TREE_RCH 1
    #define TOP_TREE_LCH 0
    #define NO_CHILD -1
    
    unsigned int data_dims;
    const border_t border_null = {.density = -1.0, .error = 0, .idx = NOBORDER};
    const sparse_border_t sparse_border_null = {.density = -1.0, .error = 0, .idx = NOBORDER, .i = NOBORDER, .j = NOBORDER};
    
    #define PREALLOC_BORDERS 100
    
    
    int cmp_float_t(const void* a, const void* b)
    {
        float_t aa = *((float_t*)a);
        float_t bb = *((float_t*)b);
        return  (aa > bb) - (aa < bb);
    }
    
    
    float_t *read_data_file(global_context_t *ctx, const char *fname,
                            const int file_in_float32) 
    {