-
-
Save kpresler/1cfa6a8b002ecdfbc761352335bec81a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE = 4 | |
PER_CPU = 4 | |
import subprocess | |
import time | |
def set_affinity(): | |
res = subprocess.run(["ps", "aux"], capture_output=True, text=True) | |
output = res.stdout | |
output = output.split("\n") | |
print(len(output)) | |
llr_tasks = list() | |
gfn_tasks = list() | |
for line in output: | |
if "boinc" in line: | |
pieces = line.split() | |
pid = pieces[1] | |
if "sllr2" in line: | |
llr_tasks.append(pid) | |
if "genefer" in line: | |
gfn_tasks.append(pid) | |
start = BASE; | |
for pid in llr_tasks: | |
task_start = start | |
start = start + PER_CPU | |
task_end = start - 1 | |
print(f"assigning {pid} to {task_start}-{task_end}") | |
lst = f"{task_start}-{task_end}" | |
subprocess.run(["taskset", "-pc", lst, pid]) | |
start = 0 | |
for pid in gfn_tasks: | |
print(f"assigning {pid} to {start}") | |
start = (start + 1) % 2 | |
lst = str(start) | |
subprocess.run(["taskset", "-pc", lst, pid]) | |
while True: | |
set_affinity() | |
time.sleep(240) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment