Skip to content

Assert if tracking provider is not empty #153

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

Merged

Conversation

ldorau
Copy link
Contributor

@ldorau ldorau commented Jan 17, 2024

No description provided.

@ldorau ldorau requested a review from a team as a code owner January 17, 2024 10:53
@ldorau ldorau marked this pull request as draft January 17, 2024 10:54
@ldorau ldorau changed the title Assert if tracking provider is not empty [DRAFT] Assert if tracking provider is not empty Jan 17, 2024
@bratpiorka
Copy link
Contributor

great job with finding this problems :)

@igchor
Copy link
Member

igchor commented Jan 17, 2024

Hm, I'm not sure if this is correct. We have a single critnib (hTracker) for the entire library and tracking provider is per-pool (trackingFinalize will be called on each umfPoolDestroy).

This means that if we have multiple pools opened (and with active allocations), this assert will fail, even, if we are destroying a pool that did all necessary cleanup.

@bratpiorka
Copy link
Contributor

@igchor ok and what about moving this code to tracker destructor? providerFini() and deleteLibTracker()

@igchor
Copy link
Member

igchor commented Jan 17, 2024

@igchor ok and what about moving this code to tracker destructor? providerFini() and deleteLibTracker()

Yes, that should work.

But I think checking the leaks per each memory pool would be also good.

We can implement a provider in tests, that will be a wrapper and will forward all allocs/free to the upstream provider + will count all allocs and frees. If the counter is not 0 at the end, report an error. You can see here, how you can implement a custom provider easily: https://github.com/oneapi-src/unified-memory-framework/blob/main/test/memoryPoolAPI.cpp#L205

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 5f9428b to 79cc4e1 Compare January 17, 2024 20:45
@ldorau
Copy link
Contributor Author

ldorau commented Jan 17, 2024

@igchor checking the leaks per each memory pool done :-)

@igchor
Copy link
Member

igchor commented Jan 17, 2024

@igchor checking the leaks per each memory pool done :-)

Looks good. I would just put those checks (especially the iteration in trackingFinalize) under some define (maybe just #ifndef NDEBUG or some custom one which we would set in tests) We don't want to do those checks in a production version as there might be thousands / millions of entries in the critnib.

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 79cc4e1 to 5c32aa9 Compare January 17, 2024 21:07
@ldorau
Copy link
Contributor Author

ldorau commented Jan 17, 2024

#ifndef NDEBUG

@igchor Done.

@ldorau
Copy link
Contributor Author

ldorau commented Jan 17, 2024

See the version with all required fixes: #155

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 5c32aa9 to 887bb1f Compare January 17, 2024 22:29
@ldorau ldorau changed the title [DRAFT] Assert if tracking provider is not empty Assert if tracking provider is not empty Jan 17, 2024
@ldorau
Copy link
Contributor Author

ldorau commented Jan 17, 2024

Requires the following PRs to be merged in order to pass all CI builds (see #155):

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 887bb1f to 1ea502a Compare January 22, 2024 11:00
@bratpiorka
Copy link
Contributor

@ldorau is this PR ready to review? Could you rebase and re-run checks?

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 1ea502a to 6a710cb Compare January 22, 2024 16:46
@ldorau
Copy link
Contributor Author

ldorau commented Jan 22, 2024

@ldorau is this PR ready to review? Could you rebase and re-run checks?

Rebased and checks re-run, but not all of them pass yet :-(

@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 6a710cb to 5a189e3 Compare January 23, 2024 10:52
@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 5a189e3 to 269ec74 Compare January 24, 2024 09:51
@ldorau ldorau force-pushed the Assert_if_tracking_provider_is_not_empty branch from 269ec74 to 273e05a Compare January 24, 2024 10:07
@ldorau ldorau marked this pull request as ready for review January 24, 2024 10:07
@bratpiorka bratpiorka merged commit 0dc5f35 into oneapi-src:main Jan 24, 2024
@ldorau ldorau deleted the Assert_if_tracking_provider_is_not_empty branch January 24, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants