diff --git a/src/python/parla/common/dataflow.py b/src/python/parla/common/dataflow.py index 8bdfcf74..254d0b9f 100644 --- a/src/python/parla/common/dataflow.py +++ b/src/python/parla/common/dataflow.py @@ -103,7 +103,7 @@ def process_crosspys( _out.append((parray, i)) else: raise TypeError( - f"Invalid Type: {type(element)}. Dataflow should be PArray, CrossPyArray, or Tuple[PArray, int]" + f"Invalid Type: {type(element)}. Dataflow should be PArray, CrossPyArray, or Tuple[PArray, int]" ) return _out diff --git a/src/python/parla/common/parray/coherence.py b/src/python/parla/common/parray/coherence.py index 62e103a8..ba2c546d 100644 --- a/src/python/parla/common/parray/coherence.py +++ b/src/python/parla/common/parray/coherence.py @@ -27,14 +27,14 @@ class MemoryOperation: # Flag SWITCH_DEVICE_FLAG = ( - 101 - ) # if the flag is set, it means dst is not the current device + 101 # if the flag is set, it means dst is not the current device + ) LOAD_SUBARRAY = ( - 102 - ) # if the flag is set, it means a subarray of src should be loaded + 102 # if the flag is set, it means a subarray of src should be loaded + ) ENSURE_IS_COMPLETE = ( - 103 - ) # if the flag is set, check data will also check if the data is complete + 103 # if the flag is set, check data will also check if the data is complete + ) def __init__(self, inst: int = NOOP, dst: int = -1, src: int = -1, flag: int = []): self.inst = inst @@ -125,9 +125,7 @@ def __init__(self, init_owner: int, num_gpu: int, cyparray_state: CyPArrayState) self._is_complete[CPU_INDEX] = None self._local_states[init_owner] = self.MODIFIED # initial state is MODIFIED - self.owner = ( - init_owner - ) # the device that has the complete copy (take the role of main memory) + self.owner = init_owner # the device that has the complete copy (take the role of main memory) self._versions[init_owner] = 0 # the first version is 0 self._is_complete[init_owner] = True # the copy is complete self._latest_version = 0 # the latest version in the system diff --git a/src/python/parla/common/parray/core.py b/src/python/parla/common/parray/core.py index c4211086..c7dd56ed 100644 --- a/src/python/parla/common/parray/core.py +++ b/src/python/parla/common/parray/core.py @@ -170,13 +170,11 @@ def get_array(self, device_idx: Optional[int] = None) -> ndarray: """ if device_idx is None: - device_idx = self._current_device_index + device_idx = self._current_device_index if self._slices: # so this is a sub-parray object # index into origin array by saved slices - ret = self._array.get_by_global_slices( - device_idx, self._slices[0] - ) + ret = self._array.get_by_global_slices(device_idx, self._slices[0]) for s in self._slices[1:]: ret = ret[s] return ret @@ -214,10 +212,9 @@ def _current_device_index(self) -> int: # to avoid import gpu context, which is slow to setup. return device.device.id # device.device should be a cupy.cuda.Device object - # Public API: - def get(self, device: Optional[PyDevice] = None) -> 'np.ndarray' | 'cp.ndarray': + def get(self, device: Optional[PyDevice] = None) -> "np.ndarray" | "cp.ndarray": if device is None: return self.array else: diff --git a/src/python/parla/utility/graphs.py b/src/python/parla/utility/graphs.py index 072f44f3..d9852dea 100644 --- a/src/python/parla/utility/graphs.py +++ b/src/python/parla/utility/graphs.py @@ -251,8 +251,8 @@ class RunConfig: """ outer_iterations: int = ( - 1 - ) # Number of times to launch the Parla runtime and execute the task graph + 1 # Number of times to launch the Parla runtime and execute the task graph + ) # Number of times to execute the task graph within the same Parla runtime inner_iterations: int = 1 inner_sync: bool = False # Whether to synchronize after each kernel launch @@ -504,7 +504,7 @@ def get_task_properties(line: str): def parse_blog( - filename: str = "parla.blog" + filename: str = "parla.blog", ) -> Tuple[Dict[TaskID, TaskTime], Dict[TaskID, List[TaskID]]]: try: result = subprocess.run(