Skip to content

Commit

Permalink
style: apply ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelhc13 authored and github-actions[bot] committed Jan 14, 2024
1 parent 22d8066 commit 896fe79
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/python/parla/common/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 7 additions & 9 deletions src/python/parla/common/parray/coherence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/python/parla/common/parray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/python/parla/utility/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 896fe79

Please sign in to comment.