FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_dynamic_load_balancing.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #include "hecmw_repart.h"
7 
8 extern struct hecmwST_local_mesh *mesh;
9 extern struct hecmwST_result_data *data;
10 extern struct hecmwST_local_mesh *new_mesh;
11 extern struct hecmwST_result_data *new_data;
12 
13 extern void mesh2graph(struct hecmwST_local_mesh *mesh, GraphType *graph,
14  Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS],
16 extern void redistribute_mesh(GraphType *graph, Result_part *result, int mynode,
17  int pesize);
18 /*extern void write_mesh_display(char *outfile, struct local_mesh *mesh, struct
19 node_elem_data *node);
20 extern void write3_mesh_display(char *outfile, struct local_mesh *mesh, struct
21 node_elem_data *node);
22 */
23 extern void hecmw_dlb_read_control(char *contfile, Control_para *ctl_para,
24  int stat_para[NUM_CONTROL_PARAS],
25  int pesize);
26 extern void hecmw_dlb_set_default_control(Control_para *ctl_para,
27  int stat_para[NUM_CONTROL_PARAS],
28  int pesize);
29 
31  int mynode, pesize;
32  FILE *test_fp;
33  char test_filename[128], out_filename[128];
34  int i, j;
35  int num_leaf_elem;
36 
37  GraphType *graph;
38  int maxnvtxs = -1, maxnedges = -1;
39  int readew = -1, readvw = -1, dummy, edge;
40  idxtype *vtxdist, *xadj, *adjncy, *vwgt, *adjwgt;
41  idxtype *your_xadj, *your_adjncy, *your_vwgt, *your_adjwgt, graphinfo[4];
42  int fmt, ncon, nobj;
43 
44  struct Global_inf *global_index;
45  Result_part *result;
46  double t1, t2, t3;
47 
48  int *num_move;
49  /* int l_child, tmp_int, *inter_elem;
50  */
51 
52  int cglevel, adaplevel, tmp, neibpetot, *neibpe, allnodtotcur, intnodetotcur,
53  *idnode, *whennode, *xyz;
54  int num_char;
55  char *contfile, buf[HECMW_FILENAME_LEN];
56  Control_para *ctl_para;
57  int stat_para[NUM_CONTROL_PARAS];
58  int flag_control;
59  HECMW_Comm_rank(mesh->HECMW_COMM, &mynode);
60  HECMW_Comm_size(mesh->HECMW_COMM, &pesize);
61  if (mynode == 0) {
62  t1 = HECMW_Wtime();
63  fprintf(stderr, "Start graph repartition now ...\n");
64  }
65 
66  ctl_para = (Control_para *)malloc(sizeof(Control_para));
67  if (ctl_para == NULL) HECMW_dlb_memory_exit("ctl_para");
68  flag_control = HECMW_ctrl_is_exists_control("dlb-ctrl");
69  if (flag_control == 0)
70  hecmw_dlb_set_default_control(ctl_para, stat_para, pesize);
71  else {
72  contfile = HECMW_ctrl_get_control_file("dlb-ctrl", buf, HECMW_FILENAME_LEN);
73  if (contfile != NULL)
74  hecmw_dlb_read_control(contfile, ctl_para, stat_para, pesize);
75  }
76 
77  graph = (GraphType *)malloc(sizeof(GraphType));
78  if (graph == NULL) HECMW_dlb_memory_exit("graph");
79  /* global_index=(struct Global_inf *)malloc(sizeof(struct Global_inf));
80  */
81  result = (Result_part *)malloc(sizeof(Result_part));
82  if (result == NULL) HECMW_dlb_memory_exit("result");
83 
84  mesh2graph(mesh, graph, ctl_para, stat_para, result, mesh->HECMW_COMM);
85  if (mynode == 0)
86  fprintf(stderr, "the edgecut number is %d\n", result->edgecut);
87  /*
88  num_move=(int *)calloc(pesize, sizeof(int));
89  for(i=0;i<pesize;i++) {
90  num_move[i]=0;
91  }
92  for(i=0;i<mesh->nn_internal;i++) {
93  num_move[result->part[i]]++;
94  }
95  for(i=0;i<pesize;i++)
96  fprintf(stderr, "in PE %d the number of nodes belong to PE %d is %d\n",
97  mynode, i, num_move[i]);
98  */
99  if (mynode == 0) {
100  t2 = HECMW_Wtime();
101  fprintf(stderr, "Finish repartition now. \n");
102  fprintf(stderr, "The time for repartition is %lf\n", t2 - t1);
103  fprintf(stderr, "Start migration...\n");
104  }
105 
107  new_mesh =
108  (struct hecmwST_local_mesh *)calloc(1, sizeof(struct hecmwST_local_mesh));
109  if (new_mesh == NULL) HECMW_dlb_memory_exit("new_mesh");
110  new_data = (struct hecmwST_result_data *)calloc(
111  1, sizeof(struct hecmwST_result_data));
112  if (new_data == NULL) HECMW_dlb_memory_exit("new_data");
113  /* global_comm_table=(Comm_table *)malloc(sizeof(Comm_table));
114  if(global_comm_table==NULL)
115  HECMW_dlb_memory_exit("global_comm_table");
116  */
117 
118  redistribute_mesh(graph, result, mynode, pesize);
119  /*
120  if(mynode==0) {
121  t3=HECMW_Wtime();
122  fprintf(stderr, "Finish migration\n");
123  fprintf(stderr, "The time for migration is %lf\n", t3-t2);
124  t3=t2;
125  }
126  */
127  return;
128 }
hecmw_dynamic_load_balancing_
void hecmw_dynamic_load_balancing_()
Definition: hecmw_dynamic_load_balancing.c:30
hecmwST_result_data
Definition: hecmw_result.h:11
NUM_CONTROL_PARAS
#define NUM_CONTROL_PARAS
Definition: hecmw_repart.h:27
HECMW_dlb_memory_exit
void HECMW_dlb_memory_exit(char *var)
Definition: hecmw_dlb_mem_util.c:7
HECMW_ctrl_get_control_file
char * HECMW_ctrl_get_control_file(char *name_ID)
Definition: hecmw_control.c:2428
hecmwST_local_mesh
Definition: hecmw_struct.h:139
HECMW_ctrl_is_exists_control
int HECMW_ctrl_is_exists_control(char *name_ID)
Definition: hecmw_control.c:2443
_control_para_struct
Definition: hecmw_repart.h:34
hecmw_repart.h
redistribute_mesh
void redistribute_mesh(GraphType *graph, Result_part *result, int mynode, int pesize)
Definition: hecmw_dlb_migrate.c:56
mesh2graph
void mesh2graph(struct hecmwST_local_mesh *mesh, GraphType *graph, Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], Result_part *result, HECMW_Comm repart_comm)
Definition: hecmw_dlb_mesh2graph.c:233
data
struct hecmwST_result_data * data
Definition: neu_reporter.cpp:18
new_mesh
struct hecmwST_local_mesh * new_mesh
Definition: hecmw_repart.h:72
hecmw_dlb_read_control
void hecmw_dlb_read_control(char *contfile, Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], int pesize)
Definition: hecmw_dlb_read_control.c:214
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
_result_partition_struct::edgecut
int edgecut
Definition: hecmw_repart.h:53
new_data
struct hecmwST_result_data * new_data
Definition: hecmw_repart.h:76
_result_partition_struct
Definition: hecmw_repart.h:52
repart_comm
int repart_comm
Definition: hecmw_repart.h:70
HECMW_Comm
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
HECMW_Comm_rank
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
Definition: hecmw_comm.c:18
HECMW_Comm_size
int HECMW_Comm_size(HECMW_Comm comm, int *size)
Definition: hecmw_comm.c:37
HECMW_Wtime
double HECMW_Wtime(void)
Definition: hecmw_time.c:8
hecmw_dlb_set_default_control
void hecmw_dlb_set_default_control(Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], int pesize)
Definition: hecmw_dlb_read_control.c:432
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
HECMW_FILENAME_LEN
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
HECMW_Barrier
int HECMW_Barrier(HECMW_Comm comm)
Definition: hecmw_comm.c:95
hecmwST_local_mesh::HECMW_COMM
HECMW_Comm HECMW_COMM
Definition: hecmw_struct.h:209