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

misc: Update advisor with oneAPI 2025 #2533

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

georgebisbas
Copy link
Contributor

Some more changes are needed, but finally works

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

devito/arch/compiler.py Outdated Show resolved Hide resolved
# 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()
Copy link
Contributor

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

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

Copy link
Contributor Author

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

Copy link

codecov bot commented Feb 10, 2025

Codecov Report

Attention: Patch coverage is 40.38462% with 31 lines in your changes missing coverage. Please review.

Project coverage is 86.20%. Comparing base (8321193) to head (e3c2211).

Files with missing lines Patch % Lines
devito/operator/profiling.py 34.78% 14 Missing and 1 partial ⚠️
devito/arch/archinfo.py 25.00% 9 Missing ⚠️
tests/test_benchmark.py 40.00% 6 Missing ⚠️
conftest.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2533      +/-   ##
==========================================
- Coverage   87.29%   86.20%   -1.10%     
==========================================
  Files         238      238              
  Lines       46058    46060       +2     
  Branches     4080     4079       -1     
==========================================
- Hits        40205    39704     -501     
- Misses       5163     5661     +498     
- Partials      690      695       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

benchmarks/user/advisor/README.md Show resolved Hide resolved
project = advisor.open_project(str(project))

if not project:
err('Could not open project %s.' % project)
err(f'Could not open project {project}.')
Copy link
Contributor

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

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

https://www.intel.com/content/www/us/en/developer/articles/training/how-to-use-the-intel-advisor-python-api.html

benchmarks/user/advisor/roofline.py Outdated Show resolved Hide resolved
@@ -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."
]
},
{
Copy link
Contributor Author

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

compiler.add_library_dirs(libdir)
compiler.add_ldflags('-Wl,-rpath,%s' % libdir)
super(AdvisorProfiler, self).__init__(name)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

no need

Copy link
Contributor

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?

if self.path is None:
self.initialized = False
else:
super().__init__(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to keep this logic here rather than in compiler.py, which shouldn't be aware of profiling

@@ -771,6 +771,18 @@ def __init_finalize__(self, **kwargs):
self.__init_intel_mpi__()
self.__init_intel_mpi_flags__()

if configuration['profiling'] == 'advisor':
Copy link
Contributor

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

@georgebisbas georgebisbas force-pushed the advisor_refresh_II branch 3 times, most recently from 4c1f058 to ed910e5 Compare February 14, 2025 07:48
conftest.py Outdated Show resolved Hide resolved
@@ -219,6 +219,12 @@ def _build(cls, expressions, **kwargs):

# Required for the jit-compilation
op._compiler = kwargs['compiler']

# Add any metadata from the profiler
Copy link
Contributor

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hope is better

@georgebisbas georgebisbas requested a review from EdCaunt February 14, 2025 08:36
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 \
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 is wrong as it's not a tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

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

omg, forgot the comma

libdir = path.joinpath('lib64').as_posix()
self._lib_dirs = [libdir]
else:
warning("Intel Advisor not found; reverting to `advanced`")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it really reverting?

Copy link
Contributor Author

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

Comment on lines -517 to -518
warning("Couldn't set up `%s` profiler; reverting to `advanced`" % level)
profiler = profiler_registry['basic'](name)
Copy link
Contributor Author

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

Copy link
Contributor

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)

Copy link
Contributor Author

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

if path:
self._include_dirs = [path.joinpath('include').as_posix()]
libdir = path.joinpath('lib64').as_posix()
self._lib_dirs = [libdir]
Copy link
Contributor

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 ?

Copy link
Contributor Author

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?

Comment on lines -517 to -518
warning("Couldn't set up `%s` profiler; reverting to `advanced`" % level)
profiler = profiler_registry['basic'](name)
Copy link
Contributor

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)

@FabioLuporini FabioLuporini changed the title advisor: Update advisor with oneAPI 2025 misc: Update advisor with oneAPI 2025 Feb 17, 2025
@@ -52,8 +50,18 @@ def __init__(self, name):
# Python-level timers
self.py_timers = OrderedDict()

# Instance attributes
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this comment

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'd better change/improve I think this comment

@@ -52,8 +50,18 @@ def __init__(self, name):
# Python-level timers
self.py_timers = OrderedDict()

# Instance attributes
self._include_dirs = []
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants