Skip to content
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

Merged
merged 48 commits into from
Dec 21, 2023
Merged

compiler: Misc code generation improvements #2282

merged 48 commits into from
Dec 21, 2023

Conversation

FabioLuporini
Copy link
Contributor

No description provided.

@@ -215,6 +217,169 @@ def Prodder(self):
return self.lang.Prodder


class ShmTransformer(LangTransformer):
Copy link
Contributor Author

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

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 83 lines in your changes are missing coverage. Please review.

Comparison is base (3126fb0) 86.85% compared to head (5f63560) 86.76%.

Files Patch % Lines
devito/arch/compiler.py 20.00% 39 Missing and 1 partial ⚠️
devito/ir/iet/visitors.py 70.42% 12 Missing and 9 partials ⚠️
devito/symbolics/extended_sympy.py 91.25% 2 Missing and 5 partials ⚠️
devito/ir/iet/nodes.py 84.61% 5 Missing and 1 partial ⚠️
devito/passes/iet/orchestration.py 0.00% 5 Missing ⚠️
devito/passes/iet/langbase.py 97.18% 1 Missing and 1 partial ⚠️
devito/symbolics/printer.py 66.66% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mloubout mloubout left a 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.

devito/symbolics/extended_sympy.py Show resolved Hide resolved
context: .
file: './docker/Dockerfile.cpu'
push: true
target: 'cpu-icx-sycl'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would drop the icx

Copy link
Contributor Author

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...

context: .
file: './docker/Dockerfile.cpu'
push: true
target: 'gpu-icx-sycl'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

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

Copy link
Contributor

@mloubout mloubout left a 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

@@ -29,7 +29,7 @@
# Generic GPUs
'AMDGPUX', 'NVIDIAX', 'INTELGPUX',
# Intel GPUs
'PVC']
'PVC', 'MAX1100', 'MAX1550']
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding INTELGPUMAX

@@ -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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, same

Copy link
Contributor Author

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'
Copy link
Contributor

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

Copy link
Contributor Author

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)

if body:
body.append(c.Line())
body.extend(as_tuple(v))
body = flatten(body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right

_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 = '&'`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might define

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing


# 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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try


# A LocalObject using both a template and a modifier
class SpecialObject(LocalObject):
dtype = CustomDtype('bar', ('int', 'float'), '&')
Copy link
Contributor

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/...

Copy link
Contributor Author

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)
Copy link
Contributor

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'])
Copy link
Contributor

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

@FabioLuporini FabioLuporini force-pushed the sycl-init branch 3 times, most recently from 213d3a6 to 2ebdc2d Compare December 19, 2023 14:33
@mloubout mloubout merged commit c888cee into master Dec 21, 2023
35 checks passed
@mloubout mloubout deleted the sycl-init branch December 21, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants