Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threading test patch #3007

Merged
merged 2 commits into from Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions psi4/share/psi4/scripts/test_threading.py
Expand Up @@ -53,17 +53,17 @@ def test_threaded_blas(args):
retnp = (time.time() - tnp) / nruns
print("Time for threads %2d, size %5d: Psi4: %12.6f NumPy: %12.6f" % (th, sz, retp4, retnp))
if sz == 4000:
times["p4-n{}".format(th)] = retp4
times["np-n{}".format(th)] = retnp
times[f"p4-n{th}"] = retp4
times[f"np-n{th}"] = retnp
assert psi4.get_num_threads() == th

rat1 = times["np-n" + str(threads[-1])] / times["p4-n" + str(threads[-1])]
rat2 = times["p4-n" + str(threads[0])] / times["p4-n" + str(threads[-1])]
print(" NumPy@n%d : Psi4@n%d ratio (want ~1): %.2f" % (threads[-1], threads[-1], rat1))
print(" Psi4@n%d : Psi4@n%d ratio (want ~%d): %.2f" % (threads[0], threads[-1], threads[-1], rat2))
if args.passfail:
assert math.isclose(rat1, 1.0, rel_tol=0.2), 'PsiAPI:NumPy speedup {} !~= 1.0'.format(rat1)
assert math.isclose(rat2, threads[-1], rel_tol=0.4), 'PsiAPI speedup {} !~= {}'.format(rat2, threads[-1])
assert math.isclose(rat1, 1.0, rel_tol=0.4), f'PsiAPI:NumPy speedup {rat1} !~= 1.0'
assert math.isclose(rat2, threads[-1], rel_tol=0.4), f'PsiAPI speedup {rat2} !~= {threads[-1]}'


def test_psithon(args):
Expand Down Expand Up @@ -117,8 +117,8 @@ def run_psithon_inputs(args, tfn, label):

for nt in threads:
t0 = time.time()
cmd = """psi4 -i {tfn}.in -o {tfn}_n{nt}.out -n{nt}""".format(tfn=tfn, nt=nt)
print('Running {} ...'.format(cmd))
cmd = f"""psi4 -i {tfn}.in -o {tfn}_n{nt}.out -n{nt}"""
print(f'Running {cmd} ...')
subprocess.call(cmd.split())

t1 = time.time()
Expand All @@ -129,7 +129,7 @@ def run_psithon_inputs(args, tfn, label):
print(" Psi4@n%d : Psi4@n%d ratio (want ~%d): %.2f" % (threads[0], threads[-1], threads[-1], rat1))
if args.passfail:
#assert math.isclose(rat1, threads[-1], rel_tol=0.6), 'Psithon speedup {} !~= {}'.format(rat1, threads[-1])
assert rat1 > 1.25, '{} Psithon speedup {} !~= {}'.format(label, rat1, threads[-1])
assert rat1 > 1.25, f'{label} Psithon speedup {rat1} !~= {threads[-1]}'


def test_plugin_dfmp2(args):
Expand Down Expand Up @@ -205,7 +205,7 @@ def print_math_ldd(args):
return True

cmd = """{} {} | grep -e ':' -e 'mkl' -e 'openblas' -e 'iomp5' -e 'gomp' -e 'libomp'""".format(lddish, modcore)
print('Running {} ...'.format(cmd))
print(f'Running {cmd} ...')
subprocess.call(cmd, shell=True)
lddout = subprocess.getoutput(cmd)
report = {'mkl': lddout.count('libmkl'),
Expand Down Expand Up @@ -246,7 +246,7 @@ def print_math_ldd(args):
okmkl2 = report['mkl'] and omplike and not report['openblas']
if args.passfail:
if sys.platform.startswith('linux'):
assert okmkl != okopenblas
assert okmkl2 != okopenblas
elif sys.platform.startswith('darwin'):
# plugins on Mac won't show mkl through otool (linked to psi4.core)
assert (okmkl2 != okopenblas) or (omplike != okopenblas)
Expand Down
1 change: 1 addition & 0 deletions psi4/src/psi4/libfock/DiskDFJK.cc
Expand Up @@ -38,6 +38,7 @@
#include "psi4/libmints/twobody.h"
#include "psi4/libmints/integral.h"
#include "psi4/lib3index/dftensor.h"
#include "psi4/liboptions/liboptions.h"

#include "jk.h"

Expand Down