-
Notifications
You must be signed in to change notification settings - Fork 18
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
All domain Registry Traversal per Backend #106
base: master
Are you sure you want to change the base?
All domain Registry Traversal per Backend #106
Conversation
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.
Thanks for making this one easy to review as well!
include/drjit-core/jit.h
Outdated
extern JIT_EXPORT uint32_t jit_registry_id_bound(JitBackend backend, | ||
const char *domain); | ||
|
||
/// Fills the \c dest pointer array with all pointers registered in the registry | ||
/// \c dest has to point to an array with \c jit_registry_id_bound(backend, nullptr) entries | ||
extern JIT_EXPORT void jit_registry_fill_ptrs(JitBackend backend, void **dest); |
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.
"fill_ptrs" could sound like you're filling the registry. Maybe jit_registry_all_pointers()
or jit_registry_get_pointers()
?
include/drjit-core/jit.h
Outdated
@@ -494,9 +494,14 @@ extern JIT_EXPORT void jit_registry_remove(const void *ptr); | |||
extern JIT_EXPORT uint32_t jit_registry_id(const void *ptr); | |||
|
|||
/// Return the largest instance ID for the given domain | |||
/// If the \c domain is a nullptr, it returns the largest instance ID for the given backend |
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.
Actually it looks like it just counts the number of active entries in a domain, not the largest instance ID?
for (Domain &domain : r.domains) { | ||
if (domain.backend == backend) |
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 guess you could create a DomainKey{ backend, domain_name }
to look up the domain ID into r.domain_ids
, but I don't think it would be faster than your current implementation.
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.
Agreed. I guess it depends on how many domains there are with a different backend.
src/registry.cpp
Outdated
@@ -149,13 +151,38 @@ uint32_t jitc_registry_id(const void *ptr) { | |||
|
|||
uint32_t jitc_registry_id_bound(JitBackend backend, const char *domain) { | |||
Registry &r = registry; | |||
if (!domain) { | |||
uint32_t i = 0; |
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.
uint32_t i = 0; | |
uint32_t n = 0; |
since it's a count and not an index.
src/registry.cpp
Outdated
auto it = r.domain_ids.find(DomainKey{ backend, domain }); | ||
if (it == r.domain_ids.end()) | ||
return 0; | ||
else | ||
return r.domains[it->second].id_bound; | ||
} | ||
|
||
void jitc_registry_fill_ptrs(JitBackend backend, void **dest) { | ||
Registry &r = registry; |
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.
Registry &r = registry; | |
const Registry &r = registry; |
src/registry.h
Outdated
@@ -22,8 +22,13 @@ extern void jitc_registry_remove(const void *ptr); | |||
extern uint32_t jitc_registry_id(const void *ptr); | |||
|
|||
/// Return the largest instance ID for the given domain | |||
/// If the \c domain is a nullptr, it returns the largest instance ID for the given backend |
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 comment as above
The PR adds the option to traverse all registry entries for a backend.
This is required for function freezing, as it is not easily possible to get the domains of a variable representing a pointer, when traversing a C++ class such as a scene.
The fix is to just traverse the whole registry.
This PR makes the following changes:
jitc_registry_id_bound
function to return the bound over all domains in the backend if thedomain
argument is anullptr
jitc_registry_fill_ptrs
function, taking a pointer to a memory region to fill with the registered pointers.Domain
struct