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

Fix CachingAllocator debug for non-async operations #45368

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

fwyzard
Copy link
Contributor

@fwyzard fwyzard commented Jul 3, 2024

PR description:

@VinInn pointed out that filling memory asynchronously may be incorrect if the memory is later being set synchronously, without using a queue.
This is often the case with pinned host memory buffers, where the allocation and memset may be asynchronous, but the content is accessed directly using host-only operations.

This change makes the allocator wait for the memset to complete before returning the memory buffer to the user code.

It also adds a customisation function to activate memory filling, and uses it in the non-profling Alpaka workflows.

PR validation:

The new tests pass.

If this PR is a backport please specify the original PR and why you need to backport that PR. If this PR will be backported please specify to which release cycle the backport is meant for:

To be backported to 14.0.x to fix the same bug there.

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 3, 2024

type bugfix

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2024

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-45368/40797

  • This PR adds an extra 24KB to repository

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@VinInn
Copy link
Contributor

VinInn commented Jul 3, 2024

I think it should fix the issue, yes.
It is clearly an overkill and a fix to alpaka memset would be more efficient.

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 3, 2024

Actually, I think that the behaviour of alpaka::memset is correct.

The issue is how we handle pinned host memory:

  • the buffer needs to be allocated using an asynchronous operation, to guarantee that the memory is freed only after any asynchronous alpaka::memcpy operations are complete; so the queue associated to the buffer is an asynchronous one;
  • however, since the host memory may be written to with non-alpaka operations (std::memset, immediate writes, etc.) we configure the allocator to make sure the memory is available immediately after returning from the allocation;
  • alpaka::memset relies on the queue to dictate if the operation should be synchronous or asynchronous;
  • so we end up with an asynchronous queue, where we want to schedule a (host-only) synchronous operation.

The quick solution implemented here is to wait after the memset.

I agree a better solution is to use an immediate memory write: either std::memset, or alpaka::memset with an immediate host-only queue.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2024

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-45368/40804

  • This PR adds an extra 24KB to repository

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 3, 2024

@VinInn what do you think of this approach ?

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 3, 2024

enable gpu

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 3, 2024

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2024

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-45368/40805

  • This PR adds an extra 24KB to repository

@fwyzard
Copy link
Contributor Author

fwyzard commented Jul 4, 2024

+heterogeneous

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 4, 2024

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 4, 2024

Pull request #45368 was updated. @AdrianoDee, @kskovpen, @miquork, @srimanob, @subirsarkar, @sunilUIET can you please check and sign again.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 4, 2024

+1

Size: This PR adds an extra 44KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-ab131f/40245/summary.html
COMMIT: 70f422b
CMSSW: CMSSW_14_1_X_2024-07-04-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/45368/40245/install.sh to create a dev area with all the needed externals and cmssw changes.

  • DAS Queries: The DAS query tests failed, see the summary page for details.

Comparison Summary

Summary:

  • You potentially added 2 lines to the logs
  • Reco comparison results: 11 differences found in the comparisons
  • DQMHistoTests: Total files compared: 48
  • DQMHistoTests: Total histograms compared: 3345088
  • DQMHistoTests: Total failures: 9
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3345059
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 47 files compared)
  • Checked 202 log files, 165 edm output root files, 48 DQM output files
  • TriggerResults: no differences found

GPU Comparison Summary

Summary:

@srimanob
Copy link
Contributor

srimanob commented Jul 5, 2024

+Upgrade

@AdrianoDee
Copy link
Contributor

+pdmv

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 9, 2024

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

@antoniovilela
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 247f6db into cms-sw:master Jul 9, 2024
15 checks passed
@fwyzard fwyzard deleted the Alpaka_CachingAllocator_debug_141x branch July 17, 2024 14:43
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.

6 participants