diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..db66bec8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + # Set update schedule for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + +# vim: sw=4 diff --git a/.github/workflows/autopush.yml b/.github/workflows/autopush.yml index 8afb3425..0fd00a29 100644 --- a/.github/workflows/autopush.yml +++ b/.github/workflows/autopush.yml @@ -10,7 +10,7 @@ jobs: name: Automatic push to gitlab.tiker.net runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | mkdir ~/.ssh && echo -e "Host gitlab.tiker.net\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config eval $(ssh-agent) && echo "$GITLAB_AUTOPUSH_KEY" | ssh-add - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b457261..86afce8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,9 @@ jobs: name: Flake8 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # matches compat target in setup.py python-version: '3.8' @@ -27,7 +27,7 @@ jobs: name: Pylint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | sed 's/python=3/python=3.7/' .test-conda-env-py3.yml > .test-conda-env.yml @@ -39,7 +39,7 @@ jobs: name: Mypy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://tiker.net/ci-support-v0 @@ -55,7 +55,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project-within-miniconda.sh @@ -65,7 +65,7 @@ jobs: name: Conda Pytest with Intel CL runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://raw.githubusercontent.com/illinois-scicomp/machine-shop-maintenance/main/install-intel-icd.sh @@ -84,7 +84,7 @@ jobs: name: Conda Pytest without arg check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project-within-miniconda.sh @@ -95,7 +95,7 @@ jobs: name: Conda Pytest Twice (for cache behavior) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://tiker.net/ci-support-v0 @@ -108,7 +108,7 @@ jobs: name: Conda Examples runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" run: | curl -L -O https://tiker.net/ci-support-v0 @@ -126,9 +126,9 @@ jobs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: "Main Script" @@ -146,7 +146,7 @@ jobs: name: Tests for downstream project ${{ matrix.downstream_project }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Main Script" env: DOWNSTREAM_PROJECT: ${{ matrix.downstream_project }} @@ -194,8 +194,8 @@ jobs: name: Validate CITATION.cff runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - run: | pip install cffconvert cffconvert -i CITATION.cff --validate diff --git a/loopy/target/__init__.py b/loopy/target/__init__.py index be04d100..9e8211a0 100644 --- a/loopy/target/__init__.py +++ b/loopy/target/__init__.py @@ -216,7 +216,7 @@ def get_function_definition( def get_function_declaration( self, codegen_state: CodeGenerationState, codegen_result: CodeGenerationResult, schedule_index: int - ) -> Tuple[Sequence[Tuple[str, str]], ASTType]: + ) -> Tuple[Sequence[Tuple[str, str]], Optional[ASTType]]: """Returns preambles and the AST for the function declaration.""" raise NotImplementedError diff --git a/loopy/target/c/codegen/expression.py b/loopy/target/c/codegen/expression.py index f0c1fabd..a29325fa 100644 --- a/loopy/target/c/codegen/expression.py +++ b/loopy/target/c/codegen/expression.py @@ -448,10 +448,10 @@ def map_constant(self, expr, type_context): # FIXME: This assumes a 32-bit architecture. if isinstance(expr, np.float32): - return Literal(repr(expr)+"f") + return Literal(repr(float(expr))+"f") elif isinstance(expr, np.float64): - return Literal(repr(expr)) + return Literal(repr(float(expr))) # Disabled for now, possibly should be a subtarget. # elif isinstance(expr, np.float128): @@ -464,7 +464,7 @@ def map_constant(self, expr, type_context): suffix += "u" if iinfo.max > (2**31-1): suffix += "l" - return Literal(repr(expr)+suffix) + return Literal(repr(int(expr))+suffix) elif isinstance(expr, np.bool_): return Literal("true") if expr else Literal("false") else: @@ -473,7 +473,7 @@ def map_constant(self, expr, type_context): elif np.isfinite(expr): if type_context == "f": - return Literal(repr(np.float32(expr))+"f") + return Literal(repr(float((expr)))+"f") elif type_context == "d": return Literal(repr(float(expr))) elif type_context in ["i", "b"]: @@ -633,7 +633,19 @@ def join(self, joiner, iterable): # }}} def map_constant(self, expr, prec): - return repr(expr) + if isinstance(expr, np.generic): + if isinstance(expr, np.integer): + # FIXME: Add type suffixes? + return repr(int(expr)) + elif isinstance(expr, np.float32): + return f"{repr(float(expr))}f" + elif isinstance(expr, np.float64): + return repr(float(expr)) + else: + raise NotImplementedError( + f"unimplemented numpy-to-C conversion: {type(expr)}") + else: + return repr(expr) def map_call(self, expr, enclosing_prec): from pymbolic.primitives import Variable diff --git a/loopy/target/pyopencl.py b/loopy/target/pyopencl.py index 40963a85..2742e472 100644 --- a/loopy/target/pyopencl.py +++ b/loopy/target/pyopencl.py @@ -633,7 +633,7 @@ def generate_value_arg_setup( from genpy import If, Raise, Statement as S, Suite - result: List[str] = [] + result: List[genpy.Generable] = [] gen = result.append buf_indices_and_args = [] @@ -717,7 +717,7 @@ def generate_array_arg_setup( from loopy.kernel.array import ArrayBase from genpy import Statement as S, Suite - result: List[str] = [] + result: List[genpy.Generable] = [] gen = result.append cl_indices_and_args: List[Union[int, str]] = [] @@ -787,7 +787,7 @@ def get_function_definition( def get_function_declaration( self, codegen_state: CodeGenerationState, codegen_result: CodeGenerationResult, schedule_index: int - ) -> Tuple[Sequence[Tuple[str, str]], genpy.Generable]: + ) -> Tuple[Sequence[Tuple[str, str]], Optional[genpy.Generable]]: # no such thing in Python return [], None diff --git a/loopy/target/python.py b/loopy/target/python.py index f93d2b44..1940dab1 100644 --- a/loopy/target/python.py +++ b/loopy/target/python.py @@ -23,7 +23,7 @@ THE SOFTWARE. """ -from typing import Tuple, Sequence +from typing import Optional, Sequence, Tuple from pymbolic.mapper import Mapper from pymbolic.mapper.stringifier import StringifyMapper @@ -169,7 +169,7 @@ def ast_module(self): def get_function_declaration( self, codegen_state: CodeGenerationState, codegen_result: CodeGenerationResult, schedule_index: int - ) -> Tuple[Sequence[Tuple[str, str]], None]: + ) -> Tuple[Sequence[Tuple[str, str]], Optional[Generable]]: return [], None def get_function_definition(self, codegen_state, codegen_result, diff --git a/test/test_fortran.py b/test/test_fortran.py index 45e83b38..55f1dab1 100644 --- a/test/test_fortran.py +++ b/test/test_fortran.py @@ -130,7 +130,9 @@ def test_assign_single_precision_scalar(ctx_factory): """ t_unit = lp.parse_fortran(fortran_src) - assert "1.1f" in lp.generate_code_v2(t_unit).device_code() + + import re + assert re.search("1.1000000[0-9]*f", lp.generate_code_v2(t_unit).device_code()) a_dev = cl.array.empty(queue, 1, dtype=np.float64, order="F") t_unit(queue, a=a_dev)