/*********/ /* mcp.h */ /*********/ #ifndef _MCP_H #define _MCP_H #include "mcp_constants.h" /* number of particles */ int np; /* supercell geometry */ double H[3][3], HI[3][3], volume; /* reduced particle coordinates between [0,1) */ double *s; /* particle masses in reduced unit */ double *mass; /* control variables */ char potential_function[MAX_STRING_LENGTH]; int LJ6_12, WOON, random_k_sampling; char config_name[MAX_STRING_LENGTH]; int print_floprate, steps_to_inform; double work_in_Gflop; /* random number generator seed */ long iseed; /* real-space dynamical matrices in compressed storage */ double *dm; int num_dm, *dm_index; /* sample k-points */ int num_kpts; double sumweight, *kpts; /* LDOS atom */ int iatom; /* LDOS direction */ double Q[3][3], QT[3][3]; /* force constant matrix */ double force_constant[3][3]; /* multichannel method */ int ktwist, mincycle, min_channel, max_channel, mint; double tiny, min_v, max_v, shift_v; int *row, *num, *idx; double *value; double *v1, *v2, *v4, *v6, *v8, *v10, *phi, *dsin, *dcos, *ar, *ai, *fup, *fvp, *ldos; double delta, del2, del3, del4, del5, del6, del7, del8, del9, del10, del11; double ui,u1i,u2i,u3i,u4i,u5i,u6i,u7i,u8i,u9i,u10i,u11i; double vi,v1i,v2i,v3i,v4i,v5i,v6i,v7i,v8i,v9i,v10i,v11i; double u2_ibb,u4_ibb,u6_ibb,u8_ibb,u10_ibb; double v2_ibb,v4_ibb,v6_ibb,v8_ibb,v10_ibb; double uni,un1i,un2i,un3i,un4i,un5i,un6i,un7i,un8i,un9i,un10i,un11i; double vni,vn1i,vn2i,vn3i,vn4i,vn5i,vn6i,vn7i,vn8i,vn9i,vn10i,vn11i; double uoi,uo2i,uo4i,uo6i,uo8i,uo10i; double voi,vo2i,vo4i,vo6i,vo8i,vo10i; /* input/output files */ char fn_config_read[MAX_STRING_LENGTH]; char fn_kpt[MAX_STRING_LENGTH]; char fn_ldos[MAX_STRING_LENGTH]; FILE *filehandle; /* allocated shared memory segments */ int num_shm_seg; struct shm_list { key_t KEY; /* shared memory key */ int ID; /* shared memory ID */ void *addr; /* attached logical address */ int size; /* size in bytes */ } shm[MAX_SHM_SEG]; /* base logical address pointer for shm operations */ double *shm_base; double *u, *u2, *u4, *u6, *u8, *u10; double *uold, *copy[MAX_PROCESSORS]; int size_of_vector_in_bytes, size_of_vector_in_double; int num_processors, master_pid, my_pid, my_idx; double master_load; const double default_master_load[MAX_PROCESSORS] = {1., 0.98, 0.98, 0.98, 0.98, 0.98, 0.98, 0.98}; /* Must be volatile because there is no explicit data change on the thread and the optimization may choose to read in them only once */ volatile int *domain; /* index domain of sparse matrix multiplication */ volatile char *commands; /* commands to slaves given by the master process */ /* semaphore set for multiprocess scheduling */ key_t sem_KEY; /* semaphore set key */ int sem_ID; /* semaphore set ID */ struct sembuf semop_add, semop_minus, semop_zero; /* semaphore operations */ union my_semun{ int val; struct semid_ds *buf; ushort *array;} sem_set; /* semaphore initial values */ /* High resolution timers */ /* for Xolas: */ /* hrtime_t real_t_start, real_t_end; */ /* for SGI and Linux: */ /* struct rusage rus; */ /* struct rusage rue; */ time_t real_t_start, real_t_end; /*************************/ /* function declarations */ /*************************/ void force_constants (double rx, double ry, double rz, double force_constant[3][3]); double matinv(double A[3][3], double B[3][3]); void matmul (double A[3][3], double B[3][3], double D[3][3]); void cmplx_mul (double ar, double ai, double br, double bi, double *dr, double *di); double frandom(); void free_shm(); void *apply_for_shm (int size); int init_shm_arrays(int n6); int init_semaphore (int num_processors); void free_semaphore(); void slave_work_till_die(); void parallel_multiply_all (int ibb, double u2_ibb, double u4_ibb, double u6_ibb, double u8_ibb, double u10_ibb, double v2_ibb, double v4_ibb, double v6_ibb, double v8_ibb, double v10_ibb); void master_set_command (char what); void do_my_job(); void master_sleep(); void slave_sleep(); void slave_touch_base(); void my_error_handler(int signal_number); void set_my_own_error_handler(); void reset_error_handler(); void startwatch(); void checkwatch(double *time_passed_in_seconds); #endif /* _MCP_H */