diff --git a/TurTLE/DNS.py b/TurTLE/DNS.py index ffa839e29f77b4afd3592ae7c00cce2148a6b0fb..31812591c7eccd150bd8bc6d55fdb6509df67e5b 100644 --- a/TurTLE/DNS.py +++ b/TurTLE/DNS.py @@ -511,52 +511,6 @@ class DNS(_code): if (self.dns_type in ['NSVE', 'NSVE_no_output']): return None return None - def job_parser_arguments( - self, - parser): - parser.add_argument( - '--ncpu', - type = int, - dest = 'ncpu', - default = -1) - parser.add_argument( - '--np', '--nprocesses', - metavar = 'NPROCESSES', - help = 'number of mpi processes to use', - type = int, - dest = 'nb_processes', - default = 4) - parser.add_argument( - '--ntpp', '--nthreads-per-process', - type = int, - dest = 'nb_threads_per_process', - metavar = 'NTHREADS_PER_PROCESS', - help = 'number of threads to use per MPI process', - default = 1) - parser.add_argument( - '--no-debug', - action = 'store_true', - dest = 'no_debug') - parser.add_argument( - '--no-submit', - action = 'store_true', - dest = 'no_submit') - parser.add_argument( - '--environment', - type = str, - dest = 'environment', - default = None) - parser.add_argument( - '--minutes', - type = int, - dest = 'minutes', - default = 5, - help = 'If environment supports it, this is the requested wall-clock-limit.') - parser.add_argument( - '--njobs', - type = int, dest = 'njobs', - default = 1) - return None def simulation_parser_arguments( self, parser): diff --git a/TurTLE/PP.py b/TurTLE/PP.py index 01aa6e534171a0638e9e27e2734a80e4e8ee15e4..51223bdb63fb267987a3f3f76a4feb286deaa1ec 100644 --- a/TurTLE/PP.py +++ b/TurTLE/PP.py @@ -328,48 +328,6 @@ class PP(_code): f[field_name + '/complex/{0}'.format(iteration)] = data f.close() return None - def job_parser_arguments( - self, - parser): - parser.add_argument( - '--ncpu', - type = int, - dest = 'ncpu', - default = -1) - parser.add_argument( - '--np', '--nprocesses', - metavar = 'NPROCESSES', - help = 'number of mpi processes to use', - type = int, - dest = 'nb_processes', - default = 4) - parser.add_argument( - '--ntpp', '--nthreads-per-process', - type = int, - dest = 'nb_threads_per_process', - metavar = 'NTHREADS_PER_PROCESS', - help = 'number of threads to use per MPI process', - default = 1) - parser.add_argument( - '--no-submit', - action = 'store_true', - dest = 'no_submit') - parser.add_argument( - '--environment', - type = str, - dest = 'environment', - default = None) - parser.add_argument( - '--minutes', - type = int, - dest = 'minutes', - default = 5, - help = 'If environment supports it, this is the requested wall-clock-limit.') - parser.add_argument( - '--njobs', - type = int, dest = 'njobs', - default = 1) - return None def simulation_parser_arguments( self, parser): diff --git a/TurTLE/TEST.py b/TurTLE/TEST.py index 2c2124defa5e26f46e2df2afd4dc126fb0381add..c72b92b1200e8594f59e4a8bc1f6609f3835966c 100644 --- a/TurTLE/TEST.py +++ b/TurTLE/TEST.py @@ -264,48 +264,6 @@ class TEST(_code): 3, 3), dtype = np.int64) return None - def job_parser_arguments( - self, - parser): - parser.add_argument( - '--ncpu', - type = int, - dest = 'ncpu', - default = -1) - parser.add_argument( - '--np', '--nprocesses', - metavar = 'NPROCESSES', - help = 'number of mpi processes to use', - type = int, - dest = 'nb_processes', - default = 4) - parser.add_argument( - '--ntpp', '--nthreads-per-process', - type = int, - dest = 'nb_threads_per_process', - metavar = 'NTHREADS_PER_PROCESS', - help = 'number of threads to use per MPI process', - default = 1) - parser.add_argument( - '--no-submit', - action = 'store_true', - dest = 'no_submit') - parser.add_argument( - '--environment', - type = str, - dest = 'environment', - default = None) - parser.add_argument( - '--minutes', - type = int, - dest = 'minutes', - default = 5, - help = 'If environment supports it, this is the requested wall-clock-limit.') - parser.add_argument( - '--njobs', - type = int, dest = 'njobs', - default = 1) - return None def simulation_parser_arguments( self, parser): diff --git a/TurTLE/_base.py b/TurTLE/_base.py index f542601860d703ba5bb6438b55c35b087d99b9da..ae58dae7cf470745e9939a565c22cf7bc9d22c0d 100644 --- a/TurTLE/_base.py +++ b/TurTLE/_base.py @@ -258,23 +258,16 @@ class _base(object): def add_parser_arguments( self, parser): - self.specific_parser_arguments(parser) + self.job_parser_arguments(parser) self.parameters_to_parser_arguments(parser) return None - def specific_parser_arguments( + def job_parser_arguments( self, parser): parser.add_argument( '-v', '--version', action = 'version', version = '%(prog)s ' + __version__) - parser.add_argument( - '-n', '--cube-size', - type = int, - dest = 'n', - default = 32, - metavar = 'N', - help = 'code is run by default in a grid of NxNxN') parser.add_argument( '--ncpu', type = int, @@ -299,25 +292,32 @@ class _base(object): action = 'store_true', dest = 'no_submit') parser.add_argument( - '--simname', - type = str, dest = 'simname', - default = 'test') + '--no-debug', + action = 'store_true', + dest = 'no_debug') parser.add_argument( '--environment', type = str, dest = 'environment', default = None) - parser.add_argument( - '--wd', - type = str, dest = 'work_dir', - default = './') parser.add_argument( '--minutes', type = int, dest = 'minutes', default = 5, help = 'If environment supports it, this is the requested wall-clock-limit.') - + parser.add_argument( + '--njobs', + type = int, dest = 'njobs', + default = 1) + parser.add_argument( + '--profile-with-vtune', + action = 'store_true', + dest = 'use_vtune') + parser.add_argument( + '--profile-with-aps', + action = 'store_true', + dest = 'use_aps') return None def parameters_to_parser_arguments( self, diff --git a/TurTLE/_code.py b/TurTLE/_code.py index 00339f955ae67ff72df5743ec2a0cd1be75e6be1..75e3c8d0e9662702265f4701ea8d6d76e2ec8e38 100644 --- a/TurTLE/_code.py +++ b/TurTLE/_code.py @@ -757,11 +757,19 @@ class _code(_base): script_file.write('echo "Start time is `date`"\n') script_file.write('cd ' + self.work_dir + '\n') script_file.write('export HTMLOUTPUT={}.html\n'.format(command_atoms[-1])) + if host_info['use_vtune'] or host_info['use_aps']: + script_file.write('module load vtune\n') if 'executable_launcher' in self.host_info.keys(): executable_launcher = self.host_info['executable_launcher'] else: executable_launcher = 'srun' + if host_info['use_vtune']: + executable_launcher = 'srun vtune -collect hpc-performance -trace-mpi -quiet -result-dir=vtune_${SLURM_JOB_NAME}' + if host_info['use_aps']: + executable_launcher = 'srun aps --result-dir=aps_${SLURM_JOB_NAME} --collection-mode=all' script_file.write(executable_launcher + ' {0}\n'.format(' '.join(command_atoms))) + if host_info['use_aps']: + script_file.write('aps-report aps_${SLURM_JOB_NAME}\n') script_file.write('echo "End time is `date`"\n') script_file.write('exit 0\n') script_file.close() @@ -784,5 +792,9 @@ class _code(_base): self.set_host_info(TurTLE.host_info) if type(opt.environment) != type(None): self.host_info['environment'] = opt.environment + # we cannot use both vtune and aps for profiling at the same time + assert(not (opt.use_vtune and opt.use_aps)) + self.host_info['use_vtune'] = opt.use_vtune + self.host_info['use_aps'] = opt.use_aps return opt diff --git a/tests/DNS/test_scaling.py b/tests/DNS/test_scaling.py index d1917b9b0512bf0bf03ee42869c376dc6d766d97..5cbff34aab4dd5e598ad9382260463ce5193ff23 100644 --- a/tests/DNS/test_scaling.py +++ b/tests/DNS/test_scaling.py @@ -20,7 +20,8 @@ def get_DNS_parameters( src_prefix = 'fbL', src_iteration = None, kMeta = 1.5, - fftw_plan_rigor = 'FFTW_MEASURE'): + fftw_plan_rigor = 'FFTW_MEASURE', + extra_parameters = []): simname = (DNS_type + '{0:0>4d}'.format(N)) if output_on: simname = DNS_type + simname @@ -95,7 +96,7 @@ def get_DNS_parameters( DNS_parameters += ['--environment', environment, '--minutes', '{0}'.format(minutes), '--fftw_plan_rigor', fftw_plan_rigor] - return simname, work_dir, DNS_parameters + return simname, work_dir, DNS_parameters + extra_parameters def main(): #DNS_type = 'A', @@ -177,7 +178,20 @@ def main(): type = int, dest = 'src_iteration', default = None) + parser.add_argument( + '--profile-with-vtune', + action = 'store_true', + dest = 'use_vtune') + parser.add_argument( + '--profile-with-aps', + action = 'store_true', + dest = 'use_aps') opt = parser.parse_args(sys.argv[1:]) + extra_parameters = [] + if opt.use_vtune: + extra_parameters.append('--profile-with-vtune') + if opt.use_aps: + extra_parameters.append('--profile-with-aps') simname, work_dir, params = get_DNS_parameters( DNS_type = opt.DNS_setup, N = opt.n, @@ -192,7 +206,8 @@ def main(): src_dirname = opt.src_dirname, src_prefix = opt.src_prefix, src_iteration = opt.src_iteration, - kMeta = opt.src_kMeta) + kMeta = opt.src_kMeta, + extra_parameters = extra_parameters) print(work_dir + '/' + simname) print(' '.join(params)) # these following 2 lines actually launch something