forked from aayasin/perf-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
omp-bin
executable file
·33 lines (26 loc) · 1.07 KB
/
omp-bin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
# Copyright (c) 2020-2024, Intel Corporation
# Author: Ahmad Yasin
#
# This program is free software; you can redistribute it and/or modify it under the terms and conditions of the
# GNU General Public License, version 2, as published by the Free Software Foundation.
# This program is distributed in the hope it will be useful, but WITHOUT # ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# runs an OpenMP app with n-threads and affinity
#
from __future__ import print_function
__author__ = 'ayasin'
import common as C, os, sys
# usage: [OMPBIN_{V,DR}=1] omp-bin <N> [--taskset-arg its-val] <app> [<and its args>]
verbose = os.getenv('OMPBIN_V')
dontrun = os.getenv('OMPBIN_DR')
n = int(C.arg(1))
assert n > 0
a = 2
mask = '0x%x' % (2**n - 1)
if sys.argv[2].startswith('--'):
mask = ' '.join(sys.argv[2:4])
a = 4
app = ' '.join(sys.argv[a:])
cmd = 'OMP_NUM_THREAD=%d taskset %s %s' % (n, mask, app)
C.exe_cmd(cmd, debug=verbose, run=not dontrun)