From a37df3a74f10837c2c0a65cc8ac412cd7aba26bf Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 14 Jul 2019 23:48:13 -0700 Subject: [PATCH 1/4] expand gitignores --- .gitignore | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3b93ce0..5298f42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ .idea/ -__pycache__ *.h5 -*.pyc + +__pycache__ +*.py[cod] +build/ +dist/ +*.egg-info/ From 314e36a3cc3b16fb3250a5a22b570ed84f4f13f7 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 14 Jul 2019 23:50:11 -0700 Subject: [PATCH 2/4] fix for 1-sized grids --- opencl_fdtd/kernels/common.cl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opencl_fdtd/kernels/common.cl b/opencl_fdtd/kernels/common.cl index deecec9..8c58d48 100644 --- a/opencl_fdtd/kernels/common.cl +++ b/opencl_fdtd/kernels/common.cl @@ -78,7 +78,8 @@ int p{{r}} = + (int) di{{r}}; int wrap_{{r}} = (s{{r}} - 1) * (int) di{{r}}; if ( {{r}} == 0 ) { m{{r}} = wrap_{{r}}; -} else if ( {{r}} == s{{r}} - 1 ) { +} +if ( {{r}} == s{{r}} - 1 ) { p{{r}} = -wrap_{{r}}; -} +} {% endfor %} From fe2f4f45109a21935056de044e381792fc950001 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 14 Jul 2019 23:51:57 -0700 Subject: [PATCH 3/4] style fixes --- opencl_fdtd/kernels/common.cl | 2 +- opencl_fdtd/kernels/update_j.cl | 4 ++-- opencl_fdtd/simulation.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/opencl_fdtd/kernels/common.cl b/opencl_fdtd/kernels/common.cl index 8c58d48..769c248 100644 --- a/opencl_fdtd/kernels/common.cl +++ b/opencl_fdtd/kernels/common.cl @@ -2,7 +2,7 @@ /* Common code for E, H updates * * Template parameters: - * ftype type name (e.g. float or double) + * ftype type name (e.g. float or double) * shape list of 3 ints specifying shape of fields */ #} diff --git a/opencl_fdtd/kernels/update_j.cl b/opencl_fdtd/kernels/update_j.cl index 4d7f64d..2682f39 100644 --- a/opencl_fdtd/kernels/update_j.cl +++ b/opencl_fdtd/kernels/update_j.cl @@ -1,11 +1,11 @@ /* - * Update E-field from J field + * Update E-field from J field * * Template parameters: * common_header: Rendered contents of common.cl * * OpenCL args: - * E, Jr, Ji, c, s, xmin, xmax, ymin, ymax, zmin, zmax + * E, Jr, Ji, c, s, xmin, xmax, ymin, ymax, zmin, zmax */ {{common_header}} diff --git a/opencl_fdtd/simulation.py b/opencl_fdtd/simulation.py index 9dd90c0..03b5588 100644 --- a/opencl_fdtd/simulation.py +++ b/opencl_fdtd/simulation.py @@ -286,13 +286,13 @@ class Simulation(object): alpha_max = pml['cfs_alpha'] def par(x): - scaling = ((x / (pml['thickness'])) ** pml['m']) + scaling = (x / pml['thickness']) ** pml['m'] sigma = scaling * sigma_max kappa = 1 + scaling * (kappa_max - 1) alpha = ((1 - x / pml['thickness']) ** pml['ma']) * alpha_max p0 = numpy.exp(-(sigma / kappa + alpha) * self.dt) p1 = sigma / (sigma + kappa * alpha) * (p0 - 1) - p2 = 1/kappa + p2 = 1 / kappa return p0, p1, p2 xe, xh = (numpy.arange(1, pml['thickness'] + 1, dtype=self.arg_type)[::-1] for _ in range(2)) From d5fd78d4933cb65f04d85eed7fca5e3264c934f8 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 17 Jul 2019 00:53:55 -0700 Subject: [PATCH 4/4] Revert "Add restrict keyword to pointers (not sharing the same memory for multiple fields)" This reverts commit 60b70bb332d29fb5a2aecb801517be659cf4daf9. It appears to have minimal performance impact, and fails to compile on nvidia cards. --- opencl_fdtd/simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencl_fdtd/simulation.py b/opencl_fdtd/simulation.py index 03b5588..c5d0005 100644 --- a/opencl_fdtd/simulation.py +++ b/opencl_fdtd/simulation.py @@ -170,7 +170,7 @@ class Simulation(object): ctype = type_to_C(self.arg_type) def ptr(arg: str) -> str: - return ctype + ' * restrict ' + arg + return ctype + ' *' + arg base_fields = OrderedDict() base_fields[ptr('E')] = self.E