Skip to content

Commit

Permalink
Refactor OperatorMsg (#3773)
Browse files Browse the repository at this point in the history
* use instantiateAndRegister for binopvv

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* update multi-dim config file

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* continue swapping registerND for instantiateAndRegister in OperatorMsg

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* fix bigint dispatching in OperatorMsg

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* finish refactoring OperatorMsg

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* remove unused 'rname' variables from OperatorMsg

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* add notes about syntax-highlighter workaround to BinOP

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>

* Update src/BinOp.chpl

Co-authored-by: tess <48131946+stress-tess@users.noreply.github.com>

* Update src/BinOp.chpl

Co-authored-by: tess <48131946+stress-tess@users.noreply.github.com>

* Update src/BinOp.chpl

Co-authored-by: tess <48131946+stress-tess@users.noreply.github.com>

---------

Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>
Co-authored-by: tess <48131946+stress-tess@users.noreply.github.com>
  • Loading branch information
jeremiah-corrado and stress-tess committed Sep 27, 2024
1 parent 3cc2a5b commit 815f971
Show file tree
Hide file tree
Showing 7 changed files with 2,060 additions and 2,442 deletions.
9 changes: 9 additions & 0 deletions .configs/registration-config-multi-dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"bigint"
]
},
"binop": {
"dtype": [
"int",
"uint",
"real",
"bool",
"bigint"
]
},
"scalar": {
"dtype": [
"int",
Expand Down
9 changes: 9 additions & 0 deletions .configs/registration-config-single-dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"bigint"
]
},
"binop": {
"dtype": [
"int",
"uint",
"real",
"bool",
"bigint"
]
},
"scalar": {
"dtype": [
"int",
Expand Down
23 changes: 15 additions & 8 deletions arkouda/pdarrayclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ def _binop(self, other: pdarray, op: str) -> pdarray:
x1, x2, tmp_x1, tmp_x2 = broadcast_if_needed(self, other)
except ValueError:
raise ValueError(f"shape mismatch {self.shape} {other.shape}")
repMsg = generic_msg(cmd=f"binopvv{x1.ndim}D", args={"op": op, "a": x1, "b": x2})
repMsg = generic_msg(
cmd=f"binopvv<{self.dtype},{other.dtype},{x1.ndim}>",
args={"op": op, "a": x1, "b": x2}
)
if tmp_x1:
del x1
if tmp_x2:
Expand All @@ -537,8 +540,8 @@ def _binop(self, other: pdarray, op: str) -> pdarray:
if dt not in DTypes:
raise TypeError(f"Unhandled scalar type: {other} ({type(other)})")
repMsg = generic_msg(
cmd=f"binopvs{self.ndim}D",
args={"op": op, "a": self, "dtype": dt, "value": other},
cmd=f"binopvs<{self.dtype},{dt},{self.ndim}>",
args={"op": op, "a": self, "value": other},
)
return create_pdarray(repMsg)

Expand Down Expand Up @@ -582,8 +585,8 @@ def _r_binop(self, other: pdarray, op: str) -> pdarray:
if dt not in DTypes:
raise TypeError(f"Unhandled scalar type: {other} ({type(other)})")
repMsg = generic_msg(
cmd=f"binopsv{self.ndim}D",
args={"op": op, "dtype": dt, "value": other, "a": self},
cmd=f"binopsv<{self.dtype},{dt},{self.ndim}>",
args={"op": op, "dtype": dt, "a": self, "value": other},
)
return create_pdarray(repMsg)

Expand Down Expand Up @@ -774,7 +777,10 @@ def opeq(self, other, op):
if isinstance(other, pdarray):
if self.shape != other.shape:
raise ValueError(f"shape mismatch {self.shape} {other.shape}")
generic_msg(cmd=f"opeqvv{self.ndim}D", args={"op": op, "a": self, "b": other})
generic_msg(
cmd=f"opeqvv<{self.dtype},{other.dtype},{self.ndim}>",
args={"op": op, "a": self, "b": other}
)
return self
# pdarray binop scalar
# opeq requires scalar to be cast as pdarray dtype
Expand All @@ -788,8 +794,9 @@ def opeq(self, other, op):
raise TypeError(f"Unhandled scalar type: {other} ({type(other)})")

generic_msg(
cmd=f"opeqvs{self.ndim}D",
args={"op": op, "a": self, "dtype": self.dtype.name, "value": self.format_other(other)},
# TODO: does opeqvs really need to select over pairs of dtypes?
cmd=f"opeqvs<{self.dtype},{self.dtype},{self.ndim}>",
args={"op": op, "a": self, "value": self.format_other(other)},
)
return self

Expand Down
9 changes: 9 additions & 0 deletions registration-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"bigint"
]
},
"binop": {
"dtype": [
"int",
"uint",
"real",
"bool",
"bigint"
]
},
"scalar": {
"dtype": [
"int",
Expand Down
Loading

0 comments on commit 815f971

Please sign in to comment.