Skip to content

Commit

Permalink
llvm/execution: Improve comments and variable naming
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
  • Loading branch information
jvesely committed Nov 25, 2021
1 parent a2a4829 commit 0185842
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions psyneulink/core/llvm/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _state_struct(self):

def execute(self, variable):
# Make sure function inputs are 2d.
# Mechanism inptus are already 3d so the first part is nop.
# Mechanism inputs are already 3d so the first part is nop.
new_variable = np.asfarray(np.atleast_2d(variable),
dtype=self._vi_dty)

Expand Down Expand Up @@ -411,11 +411,14 @@ def _extract_node_struct(self, node, data):
# followed by a list of projection parameters; get the first one
# output structure consists of a list of node outputs,
# followed by a list of nested data structures; get the first one
field = data._fields_[0][0]
res_struct = getattr(data, field)
field_name = data._fields_[0][0]
res_struct = getattr(data, field_name)

# Get the index into the array of all nodes
index = self._composition._get_node_index(node)
field = res_struct._fields_[index][0]
res_struct = getattr(res_struct, field)
field_name = res_struct._fields_[index][0]
res_struct = getattr(res_struct, field_name)

return _convert_ctype_to_python(res_struct)

def extract_node_struct(self, node, struct):
Expand Down Expand Up @@ -663,11 +666,11 @@ def _prepare_evaluate(self, variable, num_evaluations):

bin_func = pnlvm.LLVMBinaryFunction.from_obj(ocm, tags=frozenset({"evaluate", "alloc_range"}))
self.__bin_func = bin_func
assert len(bin_func.byref_arg_types) == 7

# There are 7 arguments to evaluate_alloc_range:
# comp_param, comp_state, from, to, results, input, comp_data
# all but #4 are shared
assert len(bin_func.byref_arg_types) == 7

# Directly initialized structures
assert ocm.agent_rep is self._composition
Expand All @@ -690,8 +693,7 @@ def cuda_evaluate(self, variable, num_evaluations):
self._prepare_evaluate(variable, num_evaluations)
self._uploaded_bytes['input'] += converted_variable.nbytes

# Ouput is allocated on device, but we need the ctype.

# Output is allocated on device, but we need the ctype (out_ty).
cuda_args = (self.upload_ctype(ct_comp_param, 'params'),
self.upload_ctype(ct_comp_state, 'state'),
jit_engine.pycuda.driver.mem_alloc(ctypes.sizeof(out_ty)),
Expand Down

0 comments on commit 0185842

Please sign in to comment.