FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
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
8extern struct hecmwST_local_mesh *mesh;
9extern struct hecmwST_result_data *data;
10extern struct hecmwST_local_mesh *new_mesh;
11extern struct hecmwST_result_data *new_data;
12
13extern void mesh2graph(struct hecmwST_local_mesh *mesh, GraphType *graph,
14 Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS],
16extern 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
19node_elem_data *node);
20extern void write3_mesh_display(char *outfile, struct local_mesh *mesh, struct
21node_elem_data *node);
22*/
23extern void hecmw_dlb_read_control(char *contfile, Control_para *ctl_para,
24 int stat_para[NUM_CONTROL_PARAS],
25 int pesize);
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;
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}
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
Definition: hecmw_comm.c:18
int HECMW_Comm_size(HECMW_Comm comm, int *size)
Definition: hecmw_comm.c:37
int HECMW_Barrier(HECMW_Comm comm)
Definition: hecmw_comm.c:95
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
int HECMW_ctrl_is_exists_control(char *name_ID)
char * HECMW_ctrl_get_control_file(char *name_ID)
void HECMW_dlb_memory_exit(char *var)
struct hecmwST_result_data * new_data
Definition: hecmw_repart.h:76
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)
void hecmw_dlb_read_control(char *contfile, Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], int pesize)
void redistribute_mesh(GraphType *graph, Result_part *result, int mynode, int pesize)
void hecmw_dynamic_load_balancing_()
struct hecmwST_local_mesh * new_mesh
Definition: hecmw_repart.h:72
void hecmw_dlb_set_default_control(Control_para *ctl_para, int stat_para[NUM_CONTROL_PARAS], int pesize)
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
struct hecmwST_result_data * data
#define NULL
int repart_comm
Definition: hecmw_repart.h:70
#define NUM_CONTROL_PARAS
Definition: hecmw_repart.h:27
double HECMW_Wtime(void)
Definition: hecmw_time.c:8
HECMW_Comm HECMW_COMM
Definition: hecmw_struct.h:208