Merge lp:~fluidity-core/fluidity/zoltan into lp:fluidity

Proposed by Paul Woodhams
Status: Merged
Merged at revision: 3973
Proposed branch: lp:~fluidity-core/fluidity/zoltan
Merge into: lp:fluidity
Diff against target: 233 lines (+54/-31)
3 files modified
assemble/Adapt_State.F90 (+19/-13)
assemble/Zoltan_integration.F90 (+34/-16)
tools/Flredecomp.F90 (+1/-2)
To merge this branch: bzr merge lp:~fluidity-core/fluidity/zoltan
Reviewer Review Type Date Requested Status
Jon Hill Approve
Review via email: mp+85829@code.launchpad.net

Description of the change

One of the MPI_AllReduces is only necessary when using additional adapt iterations. This commit fixes the code so that it only does the collective communication when the additional adapt iterations option is being used.

Also adds some more logging messages detailing the selection of partitioners.

To post a comment you must log in.
Revision history for this message
Jon Hill (jon-hill) wrote :

Looks good.

review: Approve
lp:~fluidity-core/fluidity/zoltan updated
3449. By Jon Hill

Merge from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'assemble/Adapt_State.F90'
--- assemble/Adapt_State.F90 2011-09-28 13:38:45 +0000
+++ assemble/Adapt_State.F90 2012-04-03 09:59:20 +0000
@@ -1003,13 +1003,9 @@
1003 call get_option("/mesh_adaptivity/hr_adaptivity/zoltan_options/element_quality_cutoff", &1003 call get_option("/mesh_adaptivity/hr_adaptivity/zoltan_options/element_quality_cutoff", &
1004 & quality_tolerance, default = 0.6)1004 & quality_tolerance, default = 0.6)
10051005
1006 if (max_adapt_iteration .ne. 1) then1006 zoltan_min_adapt_iterations = adapt_iterations()
1007 zoltan_min_adapt_iterations = adapt_iterations()1007 zoltan_max_adapt_iterations = zoltan_min_adapt_iterations + zoltan_additional_adapt_iterations
1008 zoltan_max_adapt_iterations = zoltan_min_adapt_iterations + zoltan_additional_adapt_iterations1008
1009 else
1010 zoltan_min_adapt_iterations = adapt_iterations()
1011 zoltan_max_adapt_iterations = zoltan_min_adapt_iterations
1012 end if
1013#endif1009#endif
10141010
1015 finished_adapting = .false.1011 finished_adapting = .false.
@@ -1238,7 +1234,11 @@
1238 ! call zoltan now but we need to pass in both the 2d metric (metric) and the 3d full metric (full_metric)1234 ! call zoltan now but we need to pass in both the 2d metric (metric) and the 3d full metric (full_metric)
1239 ! the first is needed to define the element qualities while the second must be interpolated to the newly1235 ! the first is needed to define the element qualities while the second must be interpolated to the newly
1240 ! decomposed mesh1236 ! decomposed mesh
1241 call zoltan_drive(states, final_adapt_iteration, global_min_quality, metric = metric, full_metric = full_metric)1237 if (zoltan_additional_adapt_iterations .gt. 0) then
1238 call zoltan_drive(states, final_adapt_iteration, global_min_quality = global_min_quality, metric = metric, full_metric = full_metric)
1239 else
1240 call zoltan_drive(states, final_adapt_iteration, metric = metric, full_metric = full_metric)
1241 end if
1242 default_stat%zoltan_drive_call=.true.1242 default_stat%zoltan_drive_call=.true.
12431243
1244 ! now we can deallocate the horizontal metric and point metric back at the full metric again1244 ! now we can deallocate the horizontal metric and point metric back at the full metric again
@@ -1246,7 +1246,11 @@
1246 metric = full_metric1246 metric = full_metric
1247 else1247 else
12481248
1249 call zoltan_drive(states, final_adapt_iteration, global_min_quality, metric = metric)1249 if (zoltan_additional_adapt_iterations .gt. 0) then
1250 call zoltan_drive(states, final_adapt_iteration, global_min_quality = global_min_quality, metric = metric)
1251 else
1252 call zoltan_drive(states, final_adapt_iteration, metric = metric)
1253 end if
1250 default_stat%zoltan_drive_call=.true.1254 default_stat%zoltan_drive_call=.true.
12511255
1252 end if1256 end if
@@ -1303,10 +1307,12 @@
1303 ewrite(2,*) "The next iteration will be final adapt iteration else we'll go over the maximum adapt iterations."1307 ewrite(2,*) "The next iteration will be final adapt iteration else we'll go over the maximum adapt iterations."
1304 end if1308 end if
13051309
1306 if (global_min_quality .le. quality_tolerance) then1310 if (zoltan_additional_adapt_iterations .gt. 0) then
1307 ewrite(-1,*) "Mesh contains elements with quality below element quality tolerance. May need to increase number of adapt iterations to ensure good quality mesh."1311 if (global_min_quality .le. quality_tolerance) then
1308 ewrite(-1,*) "min_quality = ", global_min_quality1312 ewrite(-1,*) "Mesh contains elements with quality below element quality tolerance. May need to increase number of adapt iterations to ensure good quality mesh."
1309 ewrite(-1,*) "quality_tolerance = ", quality_tolerance1313 ewrite(-1,*) "min_quality = ", global_min_quality
1314 ewrite(-1,*) "quality_tolerance = ", quality_tolerance
1315 end if
1310 end if1316 end if
1311 1317
1312 final_adapt_iteration = .true.1318 final_adapt_iteration = .true.
13131319
=== modified file 'assemble/Zoltan_integration.F90'
--- assemble/Zoltan_integration.F90 2011-09-26 17:04:31 +0000
+++ assemble/Zoltan_integration.F90 2012-04-03 09:59:20 +0000
@@ -60,7 +60,7 @@
6060
61 type(state_type), dimension(:), intent(inout), target :: states61 type(state_type), dimension(:), intent(inout), target :: states
62 logical, intent(in) :: final_adapt_iteration62 logical, intent(in) :: final_adapt_iteration
63 real, intent(out) :: global_min_quality63 real, intent(out), optional :: global_min_quality
64 ! the metric is the metric we base the quality functions on64 ! the metric is the metric we base the quality functions on
65 type(tensor_field), intent(inout), optional :: metric65 type(tensor_field), intent(inout), optional :: metric
66 ! the full_metric is the metric we need to interpolate66 ! the full_metric is the metric we need to interpolate
@@ -152,23 +152,27 @@
152 & p1_num_export, p1_export_global_ids, p1_export_local_ids, p1_export_procs, &152 & p1_num_export, p1_export_global_ids, p1_export_local_ids, p1_export_procs, &
153 & load_imbalance_tolerance, flredecomp, flredecomp_input_procs, flredecomp_target_procs)153 & load_imbalance_tolerance, flredecomp, flredecomp_input_procs, flredecomp_target_procs)
154154
155 if (.NOT. final_adapt_iteration) then
156155
157 if (.NOT. zoltan_global_calculated_local_min_quality) then156 ! Only calculate the global minimum element quality if additional adapt iterations are being used
158 FLAbort("Minimum element quality was not calculated during the load balance call.")157 if (present(global_min_quality)) then
158 if (.NOT. final_adapt_iteration) then
159
160 if (.NOT. zoltan_global_calculated_local_min_quality) then
161 FLAbort("Minimum element quality was not calculated during the load balance call.")
162 end if
163
164 ! calculate the global minimum element quality
165 call mpi_allreduce(zoltan_global_local_min_quality, global_min_quality, 1, getPREAL(), &
166 & MPI_MIN, MPI_COMM_FEMTOOLS, ierr)
167 assert(ierr == MPI_SUCCESS)
168
169 ewrite(1,*) "local minimum element quality = ", zoltan_global_local_min_quality
170 ewrite(1,*) "global minimum element quality = ", global_min_quality
171
172 else
173 ! On final iteration we do not calculate the minimum element quality
174 global_min_quality = 1.0
159 end if175 end if
160
161 ! calculate the global minimum element quality
162 call mpi_allreduce(zoltan_global_local_min_quality, global_min_quality, 1, getPREAL(), &
163 & MPI_MIN, MPI_COMM_FEMTOOLS, ierr)
164 assert(ierr == MPI_SUCCESS)
165
166 ewrite(1,*) "local minimum element quality = ", zoltan_global_local_min_quality
167 ewrite(1,*) "global minimum element quality = ", global_min_quality
168
169 else
170 ! On final iteration we do not calculate the minimum element quality
171 global_min_quality = 1.0
172 end if176 end if
173177
174 if (changes .eqv. .false.) then178 if (changes .eqv. .false.) then
@@ -524,6 +528,7 @@
524 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/metis")) then528 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/metis")) then
525 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)529 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
526 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)530 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)
531 ewrite(3,*) "Setting the partitioner to be ParMETIS."
527 ! turn off graph checking unless debugging, this was filling the error file with Zoltan warnings532 ! turn off graph checking unless debugging, this was filling the error file with Zoltan warnings
528 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then533 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then
529 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)534 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)
@@ -540,9 +545,11 @@
540 if (trim(method) == "graph") then545 if (trim(method) == "graph") then
541 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)546 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
542 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)547 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)
548 ewrite(3,*) "Setting the partitioner to be Zoltan-Graph."
543 else if (trim(method) == "hypergraph") then549 else if (trim(method) == "hypergraph") then
544 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "HYPERGRAPH"); assert(ierr == ZOLTAN_OK)550 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "HYPERGRAPH"); assert(ierr == ZOLTAN_OK)
545 ierr = Zoltan_Set_Param(zz, "HYPERGRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)551 ierr = Zoltan_Set_Param(zz, "HYPERGRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)
552 ewrite(3,*) "Setting the partitioner to be Zoltan-Hypergraph."
546 end if553 end if
547 554
548 end if555 end if
@@ -550,6 +557,7 @@
550 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/scotch")) then557 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/scotch")) then
551 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)558 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
552 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "SCOTCH"); assert(ierr == ZOLTAN_OK)559 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "SCOTCH"); assert(ierr == ZOLTAN_OK)
560 ewrite(3,*) "Setting the partitioner to be Scotch."
553 ! Probably not going to want graph checking unless debugging561 ! Probably not going to want graph checking unless debugging
554 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then562 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then
555 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)563 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)
@@ -563,6 +571,7 @@
563 ! Use the Zoltan graph partitioner by default571 ! Use the Zoltan graph partitioner by default
564 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)572 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
565 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)573 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)
574 ewrite(3,*) "No partitioner option set, defaulting to using Zoltan-Graph."
566 end if575 end if
567576
568 else577 else
@@ -572,6 +581,7 @@
572 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/metis")) then581 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/metis")) then
573 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)582 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
574 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)583 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)
584 ewrite(3,*) "Setting the final partitioner to be ParMETIS."
575 ! turn off graph checking unless debugging, this was filling the error file with Zoltan warnings585 ! turn off graph checking unless debugging, this was filling the error file with Zoltan warnings
576 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then586 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then
577 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)587 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)
@@ -588,9 +598,11 @@
588 if (trim(method) == "graph") then598 if (trim(method) == "graph") then
589 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)599 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
590 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)600 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)
601 ewrite(3,*) "Setting the final partitioner to be Zoltan-Graph."
591 else if (trim(method) == "hypergraph") then602 else if (trim(method) == "hypergraph") then
592 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "HYPERGRAPH"); assert(ierr == ZOLTAN_OK)603 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "HYPERGRAPH"); assert(ierr == ZOLTAN_OK)
593 ierr = Zoltan_Set_Param(zz, "HYPERGRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)604 ierr = Zoltan_Set_Param(zz, "HYPERGRAPH_PACKAGE", "PHG"); assert(ierr == ZOLTAN_OK)
605 ewrite(3,*) "Setting the final partitioner to be Zoltan-Hypergraph."
594 end if606 end if
595 607
596 end if608 end if
@@ -598,6 +610,7 @@
598 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/scotch")) then610 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/scotch")) then
599 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)611 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
600 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "SCOTCH"); assert(ierr == ZOLTAN_OK)612 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "SCOTCH"); assert(ierr == ZOLTAN_OK)
613 ewrite(3,*) "Setting the final partitioner to be Scotch."
601 ! Probably not going to want graph checking unless debugging614 ! Probably not going to want graph checking unless debugging
602 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then615 if (have_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking")) then
603 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)616 call get_option(trim(zoltan_global_base_option_path) // "/zoltan_debug/graph_checking", graph_checking_level)
@@ -611,6 +624,7 @@
611 ! Use ParMETIS by default on the final adapt iteration624 ! Use ParMETIS by default on the final adapt iteration
612 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)625 ierr = Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); assert(ierr == ZOLTAN_OK)
613 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)626 ierr = Zoltan_Set_Param(zz, "GRAPH_PACKAGE", "PARMETIS"); assert(ierr == ZOLTAN_OK)
627 ewrite(3,*) "No final partitioner option set, defaulting to using ParMETIS."
614 end if628 end if
615629
616 end if630 end if
@@ -620,16 +634,20 @@
620 ! iteration to produce a load balanced partitioning634 ! iteration to produce a load balanced partitioning
621 if (final_adapt_iteration) then635 if (final_adapt_iteration) then
622 ierr = Zoltan_Set_Param(zz, "LB_APPROACH", "PARTITION"); assert(ierr == ZOLTAN_OK)636 ierr = Zoltan_Set_Param(zz, "LB_APPROACH", "PARTITION"); assert(ierr == ZOLTAN_OK)
637 ewrite(3,*) "Setting partitioning approach to PARTITION."
623 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/metis") .OR. &638 if (have_option(trim(zoltan_global_base_option_path) // "/final_partitioner/metis") .OR. &
624 & (.NOT.(have_option(trim(zoltan_global_base_option_path) // "/final_partitioner")))) then639 & (.NOT.(have_option(trim(zoltan_global_base_option_path) // "/final_partitioner")))) then
625 ! chosen to match what Sam uses640 ! chosen to match what Sam uses
626 ierr = Zoltan_Set_Param(zz, "PARMETIS_METHOD", "PartKway"); assert(ierr == ZOLTAN_OK)641 ierr = Zoltan_Set_Param(zz, "PARMETIS_METHOD", "PartKway"); assert(ierr == ZOLTAN_OK)
642 ewrite(3,*) "Setting ParMETIS method to PartKway."
627 end if643 end if
628 else644 else
629 ierr = Zoltan_Set_Param(zz, "LB_APPROACH", "REPARTITION"); assert(ierr == ZOLTAN_OK)645 ierr = Zoltan_Set_Param(zz, "LB_APPROACH", "REPARTITION"); assert(ierr == ZOLTAN_OK)
646 ewrite(3,*) "Setting partitioning approach to REPARTITION."
630 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/metis")) then647 if (have_option(trim(zoltan_global_base_option_path) // "/partitioner/metis")) then
631 ! chosen to match what Sam uses648 ! chosen to match what Sam uses
632 ierr = Zoltan_Set_Param(zz, "PARMETIS_METHOD", "AdaptiveRepart"); assert(ierr == ZOLTAN_OK)649 ierr = Zoltan_Set_Param(zz, "PARMETIS_METHOD", "AdaptiveRepart"); assert(ierr == ZOLTAN_OK)
650 ewrite(3,*) "Setting ParMETIS method to AdaptiveRepart."
633 ierr = Zoltan_Set_Param(zz, "PARMETIS_ITR", "100000.0"); assert(ierr == ZOLTAN_OK)651 ierr = Zoltan_Set_Param(zz, "PARMETIS_ITR", "100000.0"); assert(ierr == ZOLTAN_OK)
634 end if652 end if
635 end if653 end if
636654
=== modified file 'tools/Flredecomp.F90'
--- tools/Flredecomp.F90 2011-09-20 13:54:07 +0000
+++ tools/Flredecomp.F90 2012-04-03 09:59:20 +0000
@@ -76,7 +76,6 @@
76#ifdef HAVE_ZOLTAN76#ifdef HAVE_ZOLTAN
77 real(zoltan_float) :: ver77 real(zoltan_float) :: ver
78 integer(zoltan_int) :: ierr78 integer(zoltan_int) :: ierr
79 real :: global_min_quality
8079
81 ierr = Zoltan_Initialize(ver) 80 ierr = Zoltan_Initialize(ver)
82 assert(ierr == ZOLTAN_OK)81 assert(ierr == ZOLTAN_OK)
@@ -170,7 +169,7 @@
170 no_active_processes = target_nprocs169 no_active_processes = target_nprocs
171 170
172#ifdef HAVE_ZOLTAN171#ifdef HAVE_ZOLTAN
173 call zoltan_drive(state, .true., global_min_quality, initialise_fields=.true., ignore_extrusion=skip_initial_extrusion, &172 call zoltan_drive(state, .true., initialise_fields=.true., ignore_extrusion=skip_initial_extrusion, &
174 & flredecomping=.true., input_procs = input_nprocs, target_procs = target_nprocs)173 & flredecomping=.true., input_procs = input_nprocs, target_procs = target_nprocs)
175#else174#else
176 call strip_level_2_halo(state, initialise_fields=.true.)175 call strip_level_2_halo(state, initialise_fields=.true.)