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

tree.c

Blame
  • tree.c 91.78 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
    
    /* 
     * 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 */
    #define MAX_MSG_SIZE 10000000 
    
    #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;
    
    
    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) 
    {
    
        FILE *f = fopen(fname, "r");
        if (!f) 
        {
            printf("Nope\n");
            exit(1);