Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ omit =
# omit anything in a .local directory anywhere
*/.local/*
# omit everything in /usr
/usr/*
/usr/*
50 changes: 50 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will install Python formatting tool black and check correctness of code format for all python files
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: python-package

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
formatting:
strategy:
matrix:
python-version: [3.13]
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install black
# - name: black format
# run: |
# black --diff --check .
- name: Check files end with newline
run: |
# Find all files (excluding binary and git files) and check if they end with a newline
EXIT_CODE=0
while IFS= read -r -d '' file; do
# Skip __init__.py files (should not end with newline)
if [[ "$file" == *"__init__.py" ]]; then
continue
fi
# Skip binary files
if file "$file" | grep -q "text"; then
# Check if file ends with a newline
if [ -n "$(tail -c 1 "$file")" ]; then
echo "ERROR: $file does not end with a newline"
EXIT_CODE=1
fi
fi
done < <(find . -type f -not -path '*/\.git/*' -print0)
exit $EXIT_CODE
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ Sessionx.vim
tags
# Persistent undo
[._]*.un~

# Output files and directories
build/
2 changes: 1 addition & 1 deletion examples/BabelStream/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kokkos/babel_stream/babel_stream
kokkos/babel_stream/babel_stream
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.nbi
*.nbc
*.nbc
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This directory contains an implementation of ExaMiniMD written in PyKokkos.
Original repo: https://github.com/ECP-copa/ExaMiniMD
SHA: b6db78eeab55ccd95675bbf87b4638bb7a403039

To run: python src/main.py -il input/in.lj --fill
To run: python src/main.py -il input/in.lj --fill
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/standalone/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.nbi
*.nbc
*.nbc
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/standalone/input.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
V: 0.378024 0.545211 0.640403 || -1.068958 -0.481107 0.561693 || 0.460053 -1.095252 -0.577054 || 0.198839 1.077796 -0.682463 || 1.060739 1.373164 -0.723115 || 0.161829 -1.159987 -1.706320 || 0.039016 0.676862 0.622015 || -0.788906 -0.437339 -0.400488 || -1.359995 0.485555 1.040725 || 0.646287 0.055289 0.411390 || -1.268214 1.074131 0.584679 || 0.008655 -0.592103 0.395507 || -0.264262 -0.487297 -1.688796 || 0.905854 0.130842 0.702301 || -0.700365 -0.408724 -1.521469 || -1.064948 1.048318 0.905022 ||
Mass: 2.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 74922952976463886612494639615534525265225649798966677392892387483161181263696273328494175337183569571031983095237201100666603071569423424169407163557637775218342900125680904049529227457647208929519363737595668997040750422300188026968362339945938944.000000 || 0.005000 || 0.002500 || 0.000000 || 0.000000 || 16920071172525382285473125425930026455059225750565119522777865124712019447860338814225844729775420856359922438758568758850413809874236159358595359738524412104577874239900167886037697955889152.000000 || 10589246342251358090997449139234627623056451755240821348127726367574270708878985113278288483606729164319343270646915331883419249485806695294377605875108000780781466778198364969505790109913194980835559245252579557376.000000 || 0.000000 ||
Type: 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 ||
Got: 65.100000
Got: 65.100000
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/standalone/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def run() -> None:
exa_mini_md.run(exa_mini_md.input.nsteps)

if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/workload/input.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
V: 0.378024 0.545211 0.640403 || -1.068958 -0.481107 0.561693 || 0.460053 -1.095252 -0.577054 || 0.198839 1.077796 -0.682463 || 1.060739 1.373164 -0.723115 || 0.161829 -1.159987 -1.706320 || 0.039016 0.676862 0.622015 || -0.788906 -0.437339 -0.400488 || -1.359995 0.485555 1.040725 || 0.646287 0.055289 0.411390 || -1.268214 1.074131 0.584679 || 0.008655 -0.592103 0.395507 || -0.264262 -0.487297 -1.688796 || 0.905854 0.130842 0.702301 || -0.700365 -0.408724 -1.521469 || -1.064948 1.048318 0.905022 ||
Mass: 2.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 0.000000 || 74922952976463886612494639615534525265225649798966677392892387483161181263696273328494175337183569571031983095237201100666603071569423424169407163557637775218342900125680904049529227457647208929519363737595668997040750422300188026968362339945938944.000000 || 0.005000 || 0.002500 || 0.000000 || 0.000000 || 16920071172525382285473125425930026455059225750565119522777865124712019447860338814225844729775420856359922438758568758850413809874236159358595359738524412104577874239900167886037697955889152.000000 || 10589246342251358090997449139234627623056451755240821348127726367574270708878985113278288483606729164319343270646915331883419249485806695294377605875108000780781466778198364969505790109913194980835559245252579557376.000000 || 0.000000 ||
Type: 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 ||
Got: 65.100000
Got: 65.100000
2 changes: 1 addition & 1 deletion examples/ExaMiniMD/workload/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def run() -> None:
exa_mini_md.run(exa_mini_md.input.nsteps)

if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion examples/LogisticRegression/LR.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,4 +1062,4 @@ def main():
clf.predict_proba(asarray(X[:2, :]))
print(clf.score(asarray(X), asarray(y)))

main()
main()
2 changes: 1 addition & 1 deletion examples/NaiveBayes/GaussianNB.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,4 @@ def main():
y_pred = gnb.fit(asarray(X_train), asarray(y_train)).predict(asarray(X_test))
print("Number of mislabeled points out of a total %d points : %d" % (X_test.shape[0], (y_test != y_pred).sum()))

main()
main()
2 changes: 1 addition & 1 deletion examples/ParRes/functor/nstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ def run() -> None:
print("Avg time (ms): %f" % (avgtime/1.e-3))

if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion examples/ParRes/standalone/nstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def run() -> None:
print("Avg time (ms): %f" % (avgtime/1.e-3))

if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion examples/kokkos/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This directory contains examples translated from the main Kokkos repository:
https://github.com/kokkos/kokkos/tree/develop/example/tutorial
https://github.com/kokkos/kokkos/tree/develop/example/tutorial
2 changes: 1 addition & 1 deletion examples/pykokkos/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This directory contains examples of how certain features
are implemented in PyKokkos.
are implemented in PyKokkos.
2 changes: 1 addition & 1 deletion examples/pykokkos/team_thread_mdrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def run():
print(A)

if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion pykokkos/core/fusion/access_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,4 @@ def get_view_write_indices_and_modes(AST: ast.FunctionDef, view_args: Dict[str,
visitor.visit(AST)
access_indices: Dict[Tuple[str, int], Tuple[AccessIndex, AccessMode, str]] = visitor.access_indices

return access_indices
return access_indices
2 changes: 1 addition & 1 deletion pykokkos/core/fusion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ def add_parent_refs(classdef: ast.ClassDef) -> ast.ClassDef:
grand_child.parent_accessor = field_name
grand_child.idx_in_parent = idx

return classdef
return classdef
2 changes: 1 addition & 1 deletion pykokkos/core/module_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ def is_compiled(self) -> bool:
Check if this module is compiled for its execution space
"""

return CppSetup.is_compiled(self.get_output_dir(self.main, self.metadata, self.space, self.types_signature, self.restrict_signature))
return CppSetup.is_compiled(self.get_output_dir(self.main, self.metadata, self.space, self.types_signature, self.restrict_signature))
2 changes: 1 addition & 1 deletion pykokkos/core/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,4 @@ def is_workunit(node: ast.stmt, pk_import: str) -> bool:
if (attribute.value.id == pk_import and Decorator.is_work_unit(attribute.attr)):
return True

return False
return False
2 changes: 1 addition & 1 deletion pykokkos/core/template_Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ run: $(TARGET)

clean:
rm *.o
rm $(TARGET)
rm $(TARGET)
2 changes: 1 addition & 1 deletion pykokkos/core/translators/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,4 @@ def get_random_pool(self, classdef: ast.ClassDef, source: Tuple[List[str], int],
declref = n
decltype = t

return declref, decltype
return declref, decltype
2 changes: 1 addition & 1 deletion pykokkos/core/translators/symbols_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ def get_error_messages(self, nodes: Dict[ast.AST, ErrorStatus]) -> List[str]:
message: str = f"File \"{self.path}\", line {node.lineno}:\n {error.value} symbol {symbol} used"
messages.append(message)

return messages
return messages
2 changes: 1 addition & 1 deletion pykokkos/core/type_inference/args_type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,4 @@ def restore_original_args(workunit_str: str, tree: ast.AST) -> ast.AST:
# first call, store the original params
ORIGINAL_PARAMS[workunit_str] = pickle.dumps(tree.args.args)

return tree
return tree
2 changes: 1 addition & 1 deletion pykokkos/interface/atomic/atomic_fetch_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ def atomic_compare_exchange(
indices: List[int],
comparison_value: int,
new_value: int) -> int:
pass
pass
2 changes: 1 addition & 1 deletion pykokkos/interface/execution_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ def __init__(self, team_member: TeamMember, count: int):

class TeamThreadMDRange(ExecutionPolicy):
def __init__(self, *args) -> None:
pass
pass
2 changes: 1 addition & 1 deletion pykokkos/interface/execution_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def __init__(self, space: ExecutionSpace, stream = None):

self.instance = instance_constructor(stream.ptr, False)
else:
self.instance = instance_constructor()
self.instance = instance_constructor()
2 changes: 1 addition & 1 deletion pykokkos/interface/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def get_default_layout(space: MemorySpace) -> Layout:
if space is MemorySpace.HostSpace:
return Layout.LayoutRight
else:
return Layout.LayoutLeft
return Layout.LayoutLeft
2 changes: 1 addition & 1 deletion pykokkos/interface/mathematical_special_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ def cyl_bessel_j0(input: float) -> float:
pass

def cyl_bessel_j1(input: float) -> float:
pass
pass
2 changes: 1 addition & 1 deletion pykokkos/interface/parallel_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,4 @@ def execute(space: ExecutionSpace, workload: object) -> None:


def flush():
runtime_singleton.runtime.flush_trace()
runtime_singleton.runtime.flush_trace()
2 changes: 1 addition & 1 deletion pykokkos/interface/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def rand(dtype: type):
:param dtype: the data type of the number to be generated
"""

pass
pass
2 changes: 1 addition & 1 deletion pykokkos/lib/manipulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def expand_dims(view, axis=0):
out = pk.View([view.shape[0], 1, view.shape[1]], pk.double)
pk.parallel_for(view.shape[0], expand_dims_1_impl_2d_double, view=view, out=out)

return out
return out
2 changes: 1 addition & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ readonly RC_FILE="${_DIR}"/.coveragerc

coverage run --rcfile="${RC_FILE}" -m unittest discover -s "${TESTS_DIR}"
coverage report
coverage xml -o cov.xml
coverage xml -o cov.xml
2 changes: 1 addition & 1 deletion tests/loop_fusion_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ def main():


if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion tests/test_parallelfor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
# self.assertEqual(result, expected_result)

# if __name__ == '__main__':
# unittest.main()
# unittest.main()