2828 'in --exec-args (if any).' )
2929def run_with_advisor (path , output , name , exec_args ):
3030 path = Path (path )
31- check (path .is_file (), '%s not found' % path )
32- check (path .suffix == '.py' , '%s not a Python file' % path )
31+ check (path .is_file (), f' { path } not found' )
32+ check (path .suffix == '.py' , f' { path } not a Python file' )
3333
3434 # Create a directory to store the profiling report
3535 if name is None :
3636 name = path .stem
3737 if exec_args :
38- name = "%s_%s" % ( name , '' .join (exec_args .split ()))
38+ name = f" { name } _ { '' .join (exec_args .split ())} "
3939 if output is None :
4040 output = Path (gettempdir ()).joinpath ('devito-profilings' )
4141 output .mkdir (parents = True , exist_ok = True )
4242 else :
4343 output = Path (output )
4444 if name is None :
45- output = Path (mkdtemp (dir = str (output ), prefix = "%s-" % name ))
45+ output = Path (mkdtemp (dir = str (output ), prefix = f" { name } -" ))
4646 else :
4747 output = Path (output ).joinpath (name )
4848 output .mkdir (parents = True , exist_ok = True )
4949
50- # Intel Advisor and Intel compilers must be available through either
51- # Intel oneAPI (tested with Intel oneAPI 2025.1)
50+ # advixe-cl and icx should be available through Intel oneAPI
51+ # (tested with Intel oneAPI 2025.1)
5252 try :
5353 ret = check_output (['advixe-cl' , '--version' ]).decode ("utf-8" )
54+ log (f"Found advixe-cl version: { ret .strip ()} \n " )
5455 except FileNotFoundError :
55- check (False , "Error: Couldn't detect `advixe-cl` to run Intel Advisor." )
56+ check (False , "Error: Couldn't detect `advixe-cl` to run Intel Advisor."
57+ " Please source the Advisor environment." )
5658
5759 try :
5860 ret = check_output (['icx' , '--version' ]).decode ("utf-8" )
59- log ("Found icx version: %s" % ret .strip ())
61+ log (f "Found icx version: { ret .strip ()} \n " )
6062 except FileNotFoundError :
61- check (False , "Error: Couldn't detect Intel Compiler (icx)." )
63+ check (False , "Error: Couldn't detect Intel Compiler (icx)."
64+ " Please source the Intel oneAPI compilers." )
6265
6366 # All good, Intel compiler and advisor are available
6467 os .environ ['DEVITO_ARCH' ] = 'icx'
@@ -82,7 +85,6 @@ def run_with_advisor(path, output, name, exec_args):
8285 ret = check_output (['numactl' , '--show' ]).decode ("utf-8" )
8386 ret = dict (i .split (':' ) for i in ret .split ('\n ' ) if i )
8487 n_sockets = len (ret ['cpubind' ].split ())
85- n_cores = len (ret ['physcpubind' ].split ()) # noqa
8688 except FileNotFoundError :
8789 check (False , "Couldn't detect `numactl`, necessary for thread pinning." )
8890
@@ -145,9 +147,9 @@ def run_with_advisor(path, output, name, exec_args):
145147 advixe_handler .setFormatter (advixe_formatter )
146148 advixe_logger .addHandler (advixe_handler )
147149
148- log ("Project folder: %s" % str ( output ) )
149- log ("Logging progress in: `%s`" % str ( advixe_handler ) )
150-
150+ log (f "Project folder: { output } " )
151+ log (f "Logging progress in: `{ advixe_handler . baseFilename } `" )
152+
151153 with progress ('Performing `cache warm-up` run' ):
152154 try :
153155 p_warm_up = Popen (py_cmd , stdout = PIPE , stderr = PIPE )
@@ -171,13 +173,13 @@ def run_with_advisor(path, output, name, exec_args):
171173 except OSError :
172174 check (False , 'Failed!' )
173175
174- log ('Storing `survey` and `tripcounts` data in `%s`' % str ( output ) )
176+ log (f 'Storing `survey` and `tripcounts` data in `{ output } `' )
175177 log ('To plot a roofline type: ' )
176- log ('python3 roofline.py --name %s --project %s --scale %f'
177- % (name , str (output ), n_sockets ))
178+ log (f'python3 roofline.py --name { name } --project { output } --scale { n_sockets } ' )
178179
179180 log ('\n To open the roofline using advixe-gui: ' )
180- log ('advixe-gui %s' % str (output ))
181+ log (f'advixe-gui { output } ' )
182+
181183
182184if __name__ == '__main__' :
183185 run_with_advisor ()
0 commit comments