-
Notifications
You must be signed in to change notification settings - Fork 234
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
misc: Update advisor with oneAPI 2025 #2533
base: master
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
devito/arch/compiler.py
Outdated
# Locate the Intel Advisor installation and | ||
# add the necessary flags to the compiler | ||
from devito.operator.profiling import locate_intel_advisor | ||
path = locate_intel_advisor() |
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 aren't all those set by the setvars.sh
that's what it's supposed to be for
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, this was true with Intel studios, but now they are not by default. You have to link explicitly. At least, this is what I see.
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.
And this is actually why it stopped working at some point
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2533 +/- ##
==========================================
+ Coverage 87.29% 87.32% +0.03%
==========================================
Files 238 238
Lines 46063 46061 -2
Branches 4080 4079 -1
==========================================
+ Hits 40211 40224 +13
+ Misses 5162 5147 -15
Partials 690 690 ☔ View full report in Codecov by Sentry. |
project = advisor.open_project(str(project)) | ||
|
||
if not project: | ||
err('Could not open project %s.' % project) | ||
err(f'Could not open project {project}.') |
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.
What does open_project
return if it fails to open the project? This error message might return something cryptic since project
gets overwritten
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 was sure I had replied in this, not sure I cannot see my message. This is part of the advisor API, it should already be there
@@ -267,86 +272,6 @@ | |||
"As you can see from this roofline graph, the main point is different from the single point of the previous graph. Moreover, each point is labelled with 'Time' and 'Incidence' indicators. These represent the total execution time of each loop's main body and their percentage incidence on the total execution time of the main time loop." | |||
] | |||
}, | |||
{ |
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.
All this is redundant in my opinion to be treated as-a-worthy to mention API
devito/operator/profiling.py
Outdated
compiler.add_library_dirs(libdir) | ||
compiler.add_ldflags('-Wl,-rpath,%s' % libdir) | ||
super(AdvisorProfiler, self).__init__(name) | ||
return |
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 need
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.
AFAICT, this is just yet another empty constructor? droppable?
devito/arch/compiler.py
Outdated
@@ -771,6 +771,18 @@ def __init_finalize__(self, **kwargs): | |||
self.__init_intel_mpi__() | |||
self.__init_intel_mpi_flags__() | |||
|
|||
if configuration['profiling'] == 'advisor': |
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.
see comment below, but basically since "profiling" requires third-party tools (as opposed to MPI which is an actual API) I have a preference for this bit of logic to be kept in profiling
4c1f058
to
ed910e5
Compare
devito/operator/operator.py
Outdated
@@ -219,6 +219,12 @@ def _build(cls, expressions, **kwargs): | |||
|
|||
# Required for the jit-compilation | |||
op._compiler = kwargs['compiler'] | |||
|
|||
# Add any metadata from the profiler |
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.
nitpicking, I wouldn't call it "metadata"
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.
hope is better
conftest.py
Outdated
@@ -80,7 +80,7 @@ def skipif(items, whole_module=False): | |||
skipit = "`icx+cpu64` won't work with this test" | |||
break | |||
# Skip if icx or advisor are not available | |||
if i not in 'only-advisor' or \ | |||
if i not in ('noadvisor') or \ |
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 is wrong as it's not a tuple
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.
omg, forgot the comma
devito/operator/profiling.py
Outdated
libdir = path.joinpath('lib64').as_posix() | ||
self._lib_dirs = [libdir] | ||
else: | ||
warning("Intel Advisor not found; reverting to `advanced`") |
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.
is it really reverting?
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.
good catch, indeed it is reverting, but there is another mini-bug. It was reverting to basic, now it is reverting to advanced, and dropped a double-emmited warning due to this
d0ff002
to
b79acd3
Compare
warning("Couldn't set up `%s` profiler; reverting to `advanced`" % level) | ||
profiler = profiler_registry['basic'](name) |
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.
Here, it was reverting to basic
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 but no need for that extra var imho (nitpicking)
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.
well this was only for a better fstring...but ok
devito/operator/profiling.py
Outdated
if path: | ||
self._include_dirs = [path.joinpath('include').as_posix()] | ||
libdir = path.joinpath('lib64').as_posix() | ||
self._lib_dirs = [libdir] |
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, instances shouldn't change class attributes like that....
and btw why is it even a class attribute ?
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.
What should it have been?
warning("Couldn't set up `%s` profiler; reverting to `advanced`" % level) | ||
profiler = profiler_registry['basic'](name) |
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 but no need for that extra var imho (nitpicking)
398b613
to
53a26bd
Compare
devito/operator/profiling.py
Outdated
@@ -52,8 +50,18 @@ def __init__(self, name): | |||
# Python-level timers | |||
self.py_timers = OrderedDict() | |||
|
|||
# Instance attributes |
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.
remove this comment
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'd better change/improve I think this comment
devito/operator/profiling.py
Outdated
@@ -52,8 +50,18 @@ def __init__(self, name): | |||
# Python-level timers | |||
self.py_timers = OrderedDict() | |||
|
|||
# Instance attributes | |||
self._include_dirs = [] |
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.
since these attributes (and the corresponding _add methods (please make them private)) are used only required by "third party profilers", you should move them into the Advisor class , or inside an intermediate class for ThirdPartyProfilers/ExternalProfilers
because here they'll never ever be used by the standard Profiler classes
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.
oh, I see why now...
because you need these attributes in operator.py
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.
So, no changes here AFAIU
da91de6
to
e3c2211
Compare
self.path = locate_intel_advisor() | ||
if self.path is None: | ||
self.initialized = False | ||
if self._attempted_init: |
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.
shouldn't this go after the super()
below?
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, otherwise, we would change the class attributes again! And then we would have the same problem as why it was not working before. include dirs and libdirs will not be included
e3c2211
to
9e6ddb1
Compare
9e6ddb1
to
cb89174
Compare
conftest.py
Outdated
@@ -79,6 +79,12 @@ def skipif(items, whole_module=False): | |||
isinstance(configuration['platform'], Cpu64): | |||
skipit = "`icx+cpu64` won't work with this test" | |||
break | |||
# Skip if icx or advisor are not available | |||
if i not in ('noadvisor',) or \ |
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.
shouldn't this rather be
if i == 'noadvisor' and (not isinstance(configuration['compiler'], IntelCompiler) or not get_advisor_path())
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.
hm.... you are right.. I mistakenly saw in the docker image the mpi test being executed and thought it was this...(compared to a local run in which the mpi test was skipped....)
VERY good catch may thanks
devito/operator/profiling.py
Outdated
self.initialized = True | ||
self._attempted_init = True | ||
|
||
def add_include_dir(self, dir_path): |
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.
you don't need these public methods since the updated attributes (_include_dirs
, _lib_dirs
) are only updated internally from the class itself, not from the outside
devito/operator/profiling.py
Outdated
|
||
path = get_advisor_path() | ||
if path: | ||
self.add_include_dir(path.joinpath('include').as_posix()) |
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.
as explained above, this should just be self._include_dirs.append(...)
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.
yes
c6e780d
to
c700ca2
Compare
conftest.py
Outdated
@@ -79,6 +79,12 @@ def skipif(items, whole_module=False): | |||
isinstance(configuration['platform'], Cpu64): | |||
skipit = "`icx+cpu64` won't work with this test" | |||
break | |||
# Skip if icx or advisor are not available | |||
if i == 'noadvisor' and \ | |||
not isinstance(configuration['compiler'], IntelCompiler) or \ |
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.
this is wrong again, I think, because of and/or operator precedence...
The fact we got this wrong multiple times and nothing breaks on CI suggests it's not very useful maybe
c700ca2
to
c77c4d3
Compare
if path: | ||
self._include_dirs.append(path.joinpath('include').as_posix()) | ||
self._lib_dirs.append(path.joinpath('lib64').as_posix()) | ||
self._attempted_init = True |
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 for another day, but these three lines
self._attempted_init = True
else:
self._attempted_init = False
could become a single line
self._attempted_init = bool(path)
but anyway, nitpicking... maybe you can do it in another PR
@@ -158,9 +155,13 @@ | |||
"name": "stdout", | |||
"output_type": "stream", | |||
"text": [ | |||
"\u001b[1;37;32mOpening project...\u001b[0m\n", | |||
"\u001b[1;37;32mOpening project /home/gb4018/workspace/devitocodes/devito/examples/performance/profilings/JupyterProfiling...\u001b[0m\n", |
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.
This is not OK, I don't like personal dirs in logs (ie gb4018
)
@@ -218,9 +219,13 @@ | |||
"name": "stdout", | |||
"output_type": "stream", | |||
"text": [ | |||
"\u001b[1;37;32mOpening project...\u001b[0m\n", | |||
"\u001b[1;37;32mOpening project /home/gb4018/workspace/devitocodes/devito/examples/performance/profilings/JupyterProfiling...\u001b[0m\n", |
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 here
@@ -219,6 +219,12 @@ def _build(cls, expressions, **kwargs): | |||
|
|||
# Required for the jit-compilation | |||
op._compiler = kwargs['compiler'] | |||
|
|||
# Required for compilation by the profiler |
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 aren't those part of the profller init?
Some more changes are needed, but finally works