Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate nprocs, and better estimate for max_blocks #149

Merged
merged 2 commits into from
May 3, 2024
Merged

Conversation

anton-seaice
Copy link
Contributor

Deprecate nprocs, and better estimate for max_blocks if not set in ice_in

Closes #145

Copy link
Contributor

@micaeljtoliveira micaeljtoliveira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just a few suggestions, mostly optional.


endif

+ if (nprocs .ne. -1) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ if (nprocs .ne. -1) then
+ if (nprocs /= -1) then

Easier to read and seems to be the style favored in the rest of the module.

Comment on lines 27 to 31
+ if (nprocs .ne. -1) then
+ if (my_task == master_task) then
+ write(nu_diag,*) subname//' WARNING: nprocs is deprecated, please remove from namelist'
+ endif
+ endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move this to be inside the above if statement, so that there's no need to check again if my_task == master_task.

+
+ nprocs = get_num_procs()
+
call broadcast_scalar(nprocs, master_task)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to broadcast the number of procs anymore, as all procs are now getting the value with the call to get_num_procs.

call broadcast_scalar(add_mpi_barriers, master_task)
call broadcast_scalar(debug_blocks, master_task)
+
+ ! update nprocs_x and nprocs_y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write this in a slightly different way:

  ! Broadcast data from namelist
   call broadcast_scalar(processor_shape,   master_task)
   call broadcast_scalar(distribution_type, master_task)
   call broadcast_scalar(distribution_wght, master_task)
   call broadcast_scalar(distribution_wght_file, master_task)
   call broadcast_scalar(ew_boundary_type,  master_task)
   call broadcast_scalar(ns_boundary_type,  master_task)
   call broadcast_scalar(maskhalo_dyn,      master_task)
   call broadcast_scalar(maskhalo_remap,    master_task)
   call broadcast_scalar(maskhalo_bound,    master_task)
   call broadcast_scalar(add_mpi_barriers,  master_task)
   call broadcast_scalar(debug_blocks,      master_task)
   call broadcast_scalar(max_blocks,      master_task)
   call broadcast_scalar(block_size_x,      master_task)
   call broadcast_scalar(block_size_y,      master_task)
   call broadcast_scalar(nx_global,         master_task)
   call broadcast_scalar(ny_global,         master_task) 

   nprocs = get_num_procs()

   ! update nprocs_x and nprocs_y
   call proc_decomposition(nprocs, nprocs_x, nprocs_y)

   ! Automatically determine max_blocks if requested by user
   if (max_blocks < 1) then
      max_blocks=((nx_global-1)/block_size_x/nprocs_x+1) * &
                 ((ny_global-1)/block_size_y/nprocs_y+1)
      max_blocks=max(1,max_blocks)
      if (my_task == master_task) then
         write(nu_diag,'(/,a52,i6,/)') &
            '(ice_domain): max_block < 1: max_block estimated to ',max_blocks
      endif
   endif

I think this is easier to read, but in the end this a personal preference, so feel free to ignore this suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Micael

So broadcast_scalar calls will wait for that variable to be populated before continuing ?

i.e. On PEs which are not master_task, will this will wait for block_size and max_blocks to be read from the namelist before the max_blocks calculation starts?

Copy link
Contributor

@micaeljtoliveira micaeljtoliveira May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. On PEs which are not master_task, will this will wait for block_size and max_blocks to be read from the namelist before the max_blocks calculation starts?

Yes, exactly. Each task will only return from the call to broadcast_scalar and continue execution once it has a local copy of the value being broadcasted.

@minghangli-uni
Copy link
Contributor

Looks good to me. Thank you @anton-seaice.

@anton-seaice
Copy link
Contributor Author

anton-seaice commented May 3, 2024

Made the changes proposed and tested with 1def_iaf and max_blocks not set:

Domain Information
  Processors:  total    =     48
  block_size_x,_y       =     16    15
  max_blocks            =     10
Domain Information
  Processors:  total    =     24
  block_size_x,_y       =     16    15
  max_blocks            =     20
Domain Information
  Processors:  total    =     96
  block_size_x,_y       =     16    15
  max_blocks            =     10

@anton-seaice anton-seaice merged commit a3cf418 into main May 3, 2024
2 checks passed
@anton-seaice anton-seaice deleted the iss145 branch May 3, 2024 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CICE6 max_blocks set on the fly
3 participants