From 80a1d1ceb92039f39de470e7b74e6d98364d73cc Mon Sep 17 00:00:00 2001
From: Matt Wala <wala1@illinois.edu>
Date: Sun, 21 May 2017 16:28:03 -0500
Subject: [PATCH] P2P: Pass target_to_source instead of source_to_target.

Closes #16 on gitlab.
---
 sumpy/p2p.py         | 8 ++++----
 test/test_fmm.py     | 4 ++--
 test/test_kernels.py | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sumpy/p2p.py b/sumpy/p2p.py
index b0f15abb..874fd1ae 100644
--- a/sumpy/p2p.py
+++ b/sumpy/p2p.py
@@ -131,7 +131,7 @@ class P2P(P2PBase):
                         """] + loopy_insns + ["""
                         <> d[idim] = targets[idim,itgt] - sources[idim,isrc]
                         """] + ["""
-                        <> is_self = (source_to_target[isrc] == itgt)
+                        <> is_self = (isrc == target_to_source[itgt])
                         """ if self.exclude_self else ""] + [
                         lp.Assignment(id=None,
                             assignee="pair_result_%d" % i, expression=expr,
@@ -158,7 +158,7 @@ class P2P(P2PBase):
                     lp.GlobalArg("result", None,
                         shape="nresults,ntargets", dim_tags="sep,C")
                 ] + (
-                    [lp.GlobalArg("source_to_target", np.int32, shape=("nsources",))]
+                    [lp.GlobalArg("target_to_source", np.int32, shape=("ntargets",))]
                     if self.exclude_self else []
                 ) + gather_loopy_source_arguments(self.kernels),
                 name=self.name,
@@ -255,7 +255,7 @@ class P2PFromCSR(P2PBase):
                                         targets[idim,itgt] - sources[idim,isrc] \
                                         {dup=idim}
                                 """] + ["""
-                                <> is_self = (source_to_target[isrc] == itgt)
+                                <> is_self = (isrc == target_to_source[itgt])
                                 """ if self.exclude_self else ""] + [
                                 ] + loopy_insns + [
                                 lp.Assignment(id=None,
@@ -292,7 +292,7 @@ class P2PFromCSR(P2PBase):
                 lp.ValueArg("ntargets", np.int32),
                 "...",
             ] + (
-                [lp.GlobalArg("source_to_target", np.int32, shape=("nsources",))]
+                [lp.GlobalArg("target_to_source", np.int32, shape=("ntargets",))]
                 if self.exclude_self else []
             ) + gather_loopy_source_arguments(self.kernels),
             name=self.name, assumptions="ntgt_boxes>=1")
diff --git a/test/test_fmm.py b/test/test_fmm.py
index acfcb2fa..b8132f6f 100644
--- a/test/test_fmm.py
+++ b/test/test_fmm.py
@@ -254,8 +254,8 @@ def test_sumpy_fmm_exclude_self(ctx_getter):
     rng = PhiloxGenerator(ctx)
     weights = rng.uniform(queue, nsources, dtype=np.float64)
 
-    source_to_target = np.arange(tree.nsources, dtype=np.int32)
-    self_extra_kwargs = {"source_to_target": source_to_target}
+    target_to_source = np.arange(tree.ntargets, dtype=np.int32)
+    self_extra_kwargs = {"target_to_source": target_to_source}
 
     out_kernels = [knl]
 
diff --git a/test/test_kernels.py b/test/test_kernels.py
index b7b51e7d..c32435d3 100644
--- a/test/test_kernels.py
+++ b/test/test_kernels.py
@@ -79,7 +79,7 @@ def test_p2p(ctx_getter, exclude_self):
     extra_kwargs = {}
 
     if exclude_self:
-        extra_kwargs["source_to_target"] = np.arange(n, dtype=np.int32)
+        extra_kwargs["target_to_source"] = np.arange(n, dtype=np.int32)
 
     evt, (potential, x_derivative) = knl(
             queue, targets, sources, [strengths],
-- 
GitLab