@@ -209,8 +209,8 @@ def add_profiling_arguments(parser: argparse.ArgumentParser) -> None:
209209 """Add command-line arguments for common profiler settings within
210210 LBANN.
211211
212- Adds the following options: `--profile`, `--profile-init `,
213- `--caliper` and `--caliper-config`.
212+ Adds the following options: `--profile`, `--memory-profile `,
213+ `--profile-init`, `-- caliper` and `--caliper-config`.
214214
215215 `--caliper-config` implies `--caliper`. `--caliper` without a
216216 `--caliper-config` will use the default configuration in LBANN.
@@ -229,6 +229,10 @@ def add_profiling_arguments(parser: argparse.ArgumentParser) -> None:
229229 action = 'store_true' ,
230230 default = False ,
231231 help = 'enable profiling instrumentation and markers' )
232+ parser .add_argument ('--memory-profile' ,
233+ action = 'store_true' ,
234+ default = False ,
235+ help = 'enable itemized memory usage analysis' )
232236 parser .add_argument ('--profile-init' ,
233237 action = 'store_true' ,
234238 default = False ,
@@ -242,9 +246,12 @@ def add_profiling_arguments(parser: argparse.ArgumentParser) -> None:
242246 default = None ,
243247 type = str ,
244248 help = 'Configuration string for Caliper' )
249+ parser .add_argument ('--memory-profile-verbose' ,
250+ action = 'store_true' ,
251+ default = False ,
252+ help = 'increase memory usage analysis verbosity' )
245253
246-
247- def create_profile_callback (args : argparse .Namespace ) -> Any :
254+ def create_profile_callbacks (args : argparse .Namespace ) -> Any :
248255 """Create a profiler callback from command-line arguments.
249256
250257 The parsed arguments must be generated by an
@@ -262,13 +269,20 @@ def create_profile_callback(args: argparse.Namespace) -> Any:
262269 try :
263270 profile = args .profile
264271 profile_init = not args .profile_init
272+ memprofile = args .memory_profile
273+ memprof_verbose = args .memory_profile_verbose
265274 except AttributeError :
266275 raise ValueError ('passed arguments have not been processed by '
267276 '`add_profiling_arguments`' )
268277
278+ result = []
269279 if profile :
270- return lbann .CallbackProfiler (skip_init = profile_init )
271- return None
280+ result .append (lbann .CallbackProfiler (skip_init = profile_init ))
281+ if memprofile :
282+ result .append (lbann .CallbackMemoryProfiler (
283+ detailed_first_step = memprof_verbose ))
284+
285+ return result
272286
273287
274288def get_profile_args (args : argparse .Namespace ) -> list [str ]:
0 commit comments