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

Make Alpaka ESProducers asynchronous for non-host backends #47034

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

makortel
Copy link
Contributor

@makortel makortel commented Jan 2, 2025

PR description:

This PR makes Alpaka ESProducers asynchronous, i.e. replaces the existing blocking alpaka::wait() call with a non-blocking synchronization (unless the newly-added alpaka.synchronize parameter #47028 is set to True).

While doing that, I got annoyed by the present useESProductDirectly<T> helper, because its value does not really depend on T. So I simplified its definition (first commit), and for consistency also the Event-system-side useProductDirectly (second commit) to be independent of T. In the Event-system case I also replaced the #ifdef with the use of type traits.

Resolves cms-sw/framework-team#1126

PR validation:

Unit tests pass on nodes with and without NVIDIA GPU.

…ductDirectly

The value depends only on the ALPAKA_ACCELERATOR_NAMESPACE::Platform,
and is independent of the data product type.
…ctDirectly

The value depends only on the types of
ALPAKA_ACCELERATOR_NAMESPACE::{Platform,Queue}, and is independent of
the data product type.
@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 2, 2025

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 2, 2025

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 2, 2025

A new Pull Request was created by @makortel for master.

It involves the following packages:

  • HeterogeneousCore/AlpakaCore (heterogeneous)

@cmsbuild, @fwyzard, @makortel can you please review it and eventually sign? Thanks.
@missirol, @rovere this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

makortel commented Jan 2, 2025

enable gpu

@makortel
Copy link
Contributor Author

makortel commented Jan 2, 2025

@cmsbuild, please test

Comment on lines 78 to 81
static_assert(std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(deviceRecord.queue())>>,
alpaka::Queue<Device, alpaka::Blocking>>,
"Non-blocking queue when trying to use ES data product directly. This might indicate a "
"need to extend the Alpaka ESProducer base class.");
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 could also just do

Suggested change
static_assert(std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(deviceRecord.queue())>>,
alpaka::Queue<Device, alpaka::Blocking>>,
"Non-blocking queue when trying to use ES data product directly. This might indicate a "
"need to extend the Alpaka ESProducer base class.");
alpaka::wait(deviceRecord.queue());

instead, but I'd expect a CPU backend with a non-blocking Queue to have other consequences as well, so I thought a static_assert might be useful.

// Given that the ESProducers are expected to be mostly
// for host-to-device data copies, that are serialized
// anyway (at least on current NVIDIA), this should be
// reasonable behavior for now.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively the Queues could be stored in an std::vector like before, that is then moved from the "acquire" lambda to be "produce" lambda.

Copy link
Contributor

@fwyzard fwyzard Jan 4, 2025

Choose a reason for hiding this comment

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

The Queue is returned to the QueueCache. The same Queue may be used for other work before the work enqueued here finishes.

Isn't this already a common behaviour with queues in the QueueCache ?
Or, in the other cases, queues are returned only once all work has been completed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Queue is returned to the QueueCache. The same Queue may be used for other work before the work enqueued here finishes.

Isn't this already a common behaviour with queues in the QueueCache ? Or, in the other cases, queues are returned only once all work has been completed ?

In the Event system case the queues are returned only after all work has been completed. This happens because the shared_ptr<Queue> are held in the Event data products, and they return the queue only after synchronization. (although I'd say this behavior is more of a result of other design decisions than being a deliberate choice by itself)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes. It's the EventCache that has additional provisions to avoid reusing events that are not yet "ready".

IMHO these current changes are fine, because Event Setup transitions are supposed to be "rare" with respect to the Event work.
If we later notice any performance impact here, we can always add back the vector, or extend the QueueCache to only return queues that are "empty".

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 2, 2025

+1

Size: This PR adds an extra 40KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-2ff5d2/43615/summary.html
COMMIT: 496947a
CMSSW: CMSSW_15_0_X_2025-01-02-1100/el8_amd64_gcc12
Additional Tests: GPU
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/47034/43615/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 1 lines to the logs
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 49
  • DQMHistoTests: Total histograms compared: 3818730
  • DQMHistoTests: Total failures: 596
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3818114
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
  • Checked 214 log files, 184 edm output root files, 49 DQM output files
  • TriggerResults: no differences found

GPU Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 24 differences found in the comparisons
  • DQMHistoTests: Total files compared: 7
  • DQMHistoTests: Total histograms compared: 53071
  • DQMHistoTests: Total failures: 907
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 52164
  • DQMHistoTests: Total skipped: 0
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 6 files compared)
  • Checked 24 log files, 30 edm output root files, 7 DQM output files
  • TriggerResults: no differences found

@makortel
Copy link
Contributor Author

makortel commented Jan 3, 2025

(tiny simplification)

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 3, 2025

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47034/43162

@fwyzard
Copy link
Contributor

fwyzard commented Jan 6, 2025

(though you could also squash the last commit)

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 6, 2025

This pull request is fully signed and it will be integrated in one of the next master IBs after it passes the integration tests. This pull request will now be reviewed by the release team before it's merged. @sextonkennedy, @antoniovilela, @rappoccio, @mandrenguyen (and backports should be raised in the release meeting by the corresponding L2)

@makortel
Copy link
Contributor Author

makortel commented Jan 6, 2025

(though you could also squash the last commit)

Done.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 6, 2025

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47034/43184

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 6, 2025

Pull request #47034 was updated. @cmsbuild can you please check and sign again.

@makortel
Copy link
Contributor Author

makortel commented Jan 6, 2025

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 6, 2025

+1

Size: This PR adds an extra 20KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-2ff5d2/43643/summary.html
COMMIT: 24181b3
CMSSW: CMSSW_15_0_X_2025-01-06-1100/el8_amd64_gcc12
Additional Tests: GPU
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/47034/43643/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

GPU Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 24 differences found in the comparisons
  • DQMHistoTests: Total files compared: 7
  • DQMHistoTests: Total histograms compared: 53071
  • DQMHistoTests: Total failures: 900
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 52171
  • DQMHistoTests: Total skipped: 0
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 6 files compared)
  • Checked 24 log files, 30 edm output root files, 7 DQM output files
  • TriggerResults: no differences found

@makortel
Copy link
Contributor Author

makortel commented Jan 6, 2025

Comparison differences are related to #39803 and #46416 (and the usual non-reproducibility of GPU pixel reconstruction)

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit d51a812 into cms-sw:master Jan 7, 2025
14 checks passed
@makortel makortel deleted the alpakaESProducerAsync branch January 7, 2025 14:07
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.

Make Alpaka ESProducer asynchronous
4 participants