-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: Misc code generation improvements #2282
Conversation
@@ -215,6 +217,169 @@ def Prodder(self): | |||
return self.lang.Prodder | |||
|
|||
|
|||
class ShmTransformer(LangTransformer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
essentially just lifted from parpragma
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2282 +/- ##
==========================================
- Coverage 86.85% 86.76% -0.10%
==========================================
Files 229 229
Lines 42584 42884 +300
Branches 7900 7951 +51
==========================================
+ Hits 36986 37207 +221
- Misses 4942 5002 +60
- Partials 656 675 +19 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick look and comments, will have another pass.
Overall looks fairly straighforward.
.github/workflows/docker-bases.yml
Outdated
context: . | ||
file: './docker/Dockerfile.cpu' | ||
push: true | ||
target: 'cpu-icx-sycl' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would drop the icx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it there because SYCL is an open standard and there are multiple implementations... though yeah, the only that really matters at this point is Intel's, I think...
.github/workflows/docker-bases.yml
Outdated
context: . | ||
file: './docker/Dockerfile.cpu' | ||
push: true | ||
target: 'gpu-icx-sycl' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dropping
@@ -682,11 +682,12 @@ def __init_finalize__(self, *args, **kwargs): | |||
assert isinstance(weights, (list, tuple, np.ndarray)) | |||
|
|||
# Normalize `weights` | |||
weights = tuple(sympy.sympify(i) for i in weights) | |||
from devito.symbolics import pow_to_mul # noqa, sigh | |||
weights = tuple(pow_to_mul(sympy.sympify(i)) for i in weights) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise you get pow(h_x, 2)
upon reconstructions
b857931
to
b2387c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor comments left nearly GTG, Compiler init_finalize needs revert to CustomCompiler compatible.
Launched docker build will let you know when ready
devito/arch/archinfo.py
Outdated
@@ -29,7 +29,7 @@ | |||
# Generic GPUs | |||
'AMDGPUX', 'NVIDIAX', 'INTELGPUX', | |||
# Intel GPUs | |||
'PVC'] | |||
'PVC', 'MAX1100', 'MAX1550'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a generic "MAX" by itself too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding INTELGPUMAX
devito/arch/compiler.py
Outdated
@@ -774,7 +782,7 @@ def __lookup_cmds__(self): | |||
class IntelKNLCompiler(IntelCompiler): | |||
|
|||
def __init_finalize__(self, **kwargs): | |||
IntelCompiler.__init_finalize__(self, **kwargs) | |||
super().__init_finalize__(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this needs to be IntelCompiler.__init_finalize__(self, **kwargs)
or it breaks CustomCompiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
devito/arch/compiler.py
Outdated
@@ -787,41 +795,85 @@ def __init_finalize__(self, **kwargs): | |||
class OneapiCompiler(IntelCompiler): | |||
|
|||
def __init_finalize__(self, **kwargs): | |||
IntelCompiler.__init_finalize__(self, **kwargs) | |||
super().__init_finalize__(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
# The Intel toolchain requires the I_MPI_OFFLOAD env var to be set | ||
# to enable GPU-aware MPI (that is, passing device pointers to MPI calls) | ||
if isinstance(platform, IntelDevice): | ||
environ['I_MPI_OFFLOAD'] = '1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no compiler flag for it? Seems "dangerous" to change environ like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no compiler flag...
it is "dangerous" but devito would break anyway without this env var. It's what enables device pointer support in MPI calls ("GPU-aware MPI"), which is what we rely on (only sane choice today)
devito/ir/iet/visitors.py
Outdated
if body: | ||
body.append(c.Line()) | ||
body.extend(as_tuple(v)) | ||
body = flatten(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
devito/types/object.py
Outdated
_C_modifier = None | ||
""" | ||
A modifier added to the LocalObject's C declaration when the object appears | ||
in a function signature. For example, a subclass my define `_C_modifier = '&'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might define
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing
docker/Dockerfile.cpu
Outdated
|
||
# NOTE: the name of this file ends with ".cpu" but this is a GPU image. | ||
# It then feels a bit akward, so some restructuring might be needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably make a Dockerfile.intel
the same way we have an AMD and NVIDIA one and then rename this one as something like "Dockerfile.basic" or something with just the GCC in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try
tests/test_iet.py
Outdated
|
||
# A LocalObject using both a template and a modifier | ||
class SpecialObject(LocalObject): | ||
dtype = CustomDtype('bar', ('int', 'float'), '&') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template=('int', 'float'), modifier='&'
since this is the "example" a bit better to be explicit for new users/...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
lo4 = MyObject('obj4', cargs=(1, 2), initvalue=Macro('meh')) | ||
|
||
# A LocalObject with generic sympy exprs used as constructor args | ||
expr = sympy.Function('ceil')(FLOAT(Symbol(name='s'))**-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we might wanna create place holder for all those ceil(type
, floor(type
.... for cleaner use
@@ -287,6 +288,52 @@ def test_intdiv(): | |||
assert ccode(v) == 'b*((a + b) / 2) + 3' | |||
|
|||
|
|||
def test_def_function(): | |||
foo0 = DefFunction('foo', arguments=['a', 'b'], template=['int']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this allow template='int'
or is list mandatory
213d3a6
to
2ebdc2d
Compare
2ebdc2d
to
dfd7968
Compare
No description provided.