| 1 | #ifndef __XSBENCH_HEADER_H__
|
|---|
| 2 | #define __XSBENCH_HEADER_H__
|
|---|
| 3 |
|
|---|
| 4 | #include<stdio.h>
|
|---|
| 5 | #include<stdlib.h>
|
|---|
| 6 | #include<time.h>
|
|---|
| 7 | #include<string.h>
|
|---|
| 8 | #include<strings.h>
|
|---|
| 9 | #include<math.h>
|
|---|
| 10 | #include<omp.h>
|
|---|
| 11 | #include<unistd.h>
|
|---|
| 12 | //#include<sys/time.h> // SFS: commented out, already have time.h
|
|---|
| 13 |
|
|---|
| 14 | // Papi Header
|
|---|
| 15 | #ifdef PAPI
|
|---|
| 16 | #include "papi.h"
|
|---|
| 17 | #endif
|
|---|
| 18 |
|
|---|
| 19 | // I/O Specifiers
|
|---|
| 20 | #define INFO 1
|
|---|
| 21 | #define DEBUG 1
|
|---|
| 22 | #define SAVE 1
|
|---|
| 23 |
|
|---|
| 24 | // Structures
|
|---|
| 25 | typedef struct{
|
|---|
| 26 | double energy;
|
|---|
| 27 | double total_xs;
|
|---|
| 28 | double elastic_xs;
|
|---|
| 29 | double absorbtion_xs;
|
|---|
| 30 | double fission_xs;
|
|---|
| 31 | double nu_fission_xs;
|
|---|
| 32 | } NuclideGridPoint;
|
|---|
| 33 |
|
|---|
| 34 | typedef struct{
|
|---|
| 35 | double energy;
|
|---|
| 36 | int * xs_ptrs;
|
|---|
| 37 | } GridPoint;
|
|---|
| 38 |
|
|---|
| 39 | typedef struct{
|
|---|
| 40 | int nthreads;
|
|---|
| 41 | long n_isotopes;
|
|---|
| 42 | long n_gridpoints;
|
|---|
| 43 | int lookups;
|
|---|
| 44 | char * HM;
|
|---|
| 45 | } Inputs;
|
|---|
| 46 |
|
|---|
| 47 | // Function Prototypes
|
|---|
| 48 | void logo(int version);
|
|---|
| 49 | void center_print(const char *s, int width);
|
|---|
| 50 | void border_print(void);
|
|---|
| 51 | void fancy_int(long a);
|
|---|
| 52 |
|
|---|
| 53 | NuclideGridPoint ** gpmatrix(size_t m, size_t n);
|
|---|
| 54 |
|
|---|
| 55 | void gpmatrix_free( NuclideGridPoint ** M );
|
|---|
| 56 |
|
|---|
| 57 | int NGP_compare( const void * a, const void * b );
|
|---|
| 58 |
|
|---|
| 59 | void generate_grids( NuclideGridPoint ** nuclide_grids,
|
|---|
| 60 | long n_isotopes, long n_gridpoints );
|
|---|
| 61 | void generate_grids_v( NuclideGridPoint ** nuclide_grids,
|
|---|
| 62 | long n_isotopes, long n_gridpoints );
|
|---|
| 63 |
|
|---|
| 64 | void sort_nuclide_grids( NuclideGridPoint ** nuclide_grids, long n_isotopes,
|
|---|
| 65 | long n_gridpoints );
|
|---|
| 66 |
|
|---|
| 67 | GridPoint * generate_energy_grid( long n_isotopes, long n_gridpoints,
|
|---|
| 68 | NuclideGridPoint ** nuclide_grids);
|
|---|
| 69 |
|
|---|
| 70 | void set_grid_ptrs( GridPoint * energy_grid, NuclideGridPoint ** nuclide_grids,
|
|---|
| 71 | long n_isotopes, long n_gridpoints );
|
|---|
| 72 |
|
|---|
| 73 | int binary_search( NuclideGridPoint * A, double quarry, int n );
|
|---|
| 74 |
|
|---|
| 75 | void calculate_macro_xs( double p_energy, int mat, long n_isotopes,
|
|---|
| 76 | long n_gridpoints, int * restrict num_nucs,
|
|---|
| 77 | double ** restrict concs,
|
|---|
| 78 | GridPoint * restrict energy_grid,
|
|---|
| 79 | NuclideGridPoint ** restrict nuclide_grids,
|
|---|
| 80 | int ** restrict mats,
|
|---|
| 81 | double * restrict macro_xs_vector );
|
|---|
| 82 |
|
|---|
| 83 | void calculate_micro_xs( double p_energy, int nuc, long n_isotopes,
|
|---|
| 84 | long n_gridpoints,
|
|---|
| 85 | GridPoint * restrict energy_grid,
|
|---|
| 86 | NuclideGridPoint ** restrict nuclide_grids, int idx,
|
|---|
| 87 | double * restrict xs_vector );
|
|---|
| 88 |
|
|---|
| 89 | long grid_search( long n, double quarry, GridPoint * A);
|
|---|
| 90 |
|
|---|
| 91 | int * load_num_nucs(long n_isotopes);
|
|---|
| 92 | int ** load_mats( int * num_nucs, long n_isotopes );
|
|---|
| 93 | double ** load_concs( int * num_nucs );
|
|---|
| 94 | double ** load_concs_v( int * num_nucs );
|
|---|
| 95 | int pick_mat(unsigned long * seed);
|
|---|
| 96 | double rn(unsigned long * seed);
|
|---|
| 97 | int rn_int(unsigned long * seed);
|
|---|
| 98 | void counter_stop( int * eventset, int num_papi_events );
|
|---|
| 99 | void counter_init( int * eventset, int * num_papi_events );
|
|---|
| 100 | void do_flops(void);
|
|---|
| 101 | void do_loads( int nuc,
|
|---|
| 102 | NuclideGridPoint ** restrict nuclide_grids,
|
|---|
| 103 | long n_gridpoints );
|
|---|
| 104 | Inputs read_CLI( int argc, char * argv[] );
|
|---|
| 105 | void print_CLI_error(void);
|
|---|
| 106 | double rn_v(void);
|
|---|
| 107 | double round_double( double input );
|
|---|
| 108 | unsigned int hash(unsigned char *str, int nbins);
|
|---|
| 109 | size_t estimate_mem_usage( Inputs in );
|
|---|
| 110 | void print_inputs(Inputs in, int nprocs, int version);
|
|---|
| 111 | void print_results( Inputs in, int mype, double runtime, int nprocs, unsigned long long vhash );
|
|---|
| 112 | void binary_dump(long n_isotopes, long n_gridpoints, NuclideGridPoint ** nuclide_grids, GridPoint * energy_grid);
|
|---|
| 113 | void binary_read(long n_isotopes, long n_gridpoints, NuclideGridPoint ** nuclide_grids, GridPoint * energy_grid);
|
|---|
| 114 |
|
|---|
| 115 | #endif
|
|---|