Skip to content

Commit

Permalink
Merge pull request #23 from firedrakeproject/connorjward/check-upstream
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
connorjward authored Apr 16, 2024
2 parents 6f7f72a + 6c4f14b commit 967461b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 27 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
# Set update schedule for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

# vim: sw=4
2 changes: 1 addition & 1 deletion .github/workflows/autopush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion loopy/target/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 17 additions & 5 deletions loopy/target/c/codegen/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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"]:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions loopy/target/pyopencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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]] = []
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions loopy/target/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion test/test_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 967461b

Please sign in to comment.