Skip to content

Commit

Permalink
#16 Added an output directory prefix to the plotting in test_diffusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljohnsen committed Sep 11, 2024
1 parent 5d5741a commit 0002654
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/test/test_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import os
import scipy.ndimage as ndi

from lib.cpp.cpu.diffusion import diffusion as diffusion_cpu
Expand All @@ -19,7 +20,8 @@
sigma = 3 # Radius has to be <= 16 for the faster GPU implementation
reps = 100
plot = False
verify = True
plotting_dir = sys.path[0] + '/debug_plots/'
if plot: os.makedirs(plotting_dir, exist_ok=True)

run_py = True
run_cpp = True
Expand Down Expand Up @@ -60,10 +62,10 @@

if plot:
plt.imshow(python_impl[n//2], cmap='gray')
plt.savefig('python_impl.png')
plt.savefig(f'{plotting_dir}/python_impl.png')
plt.close()
plt.imshow(a[n//2], cmap='gray')
plt.savefig('original.png')
plt.savefig(f'{plotting_dir}/original.png')
plt.close()

#
Expand All @@ -81,7 +83,7 @@

if plot:
plt.imshow(cpp_impl[n//2], cmap='gray')
plt.savefig('cpp_impl.png')
plt.savefig(f'{plotting_dir}/cpp_impl.png')
plt.close()

if verify:
Expand Down Expand Up @@ -109,7 +111,7 @@

if plot:
plt.imshow(gpu_impl[n//2], cmap='gray')
plt.savefig('gpu_impl.png')
plt.savefig(f'{plotting_dir}/gpu_impl.png')
plt.close()

if verify:
Expand All @@ -123,7 +125,7 @@
if plot:
plt.imshow(diff[n//2])
plt.colorbar()
plt.savefig('diff.png')
plt.savefig(f'{plotting_dir}/diff.png')
plt.close()
checksum = np.sum(gpu_impl)
print (f"Checksum of GPU: {checksum != 0} ({checksum})")
Expand Down

0 comments on commit 0002654

Please sign in to comment.