Skip to content

Commit

Permalink
Addressed comments from @merlinND
Browse files Browse the repository at this point in the history
  • Loading branch information
DoeringChristian committed Nov 2, 2024
1 parent 1f73258 commit 07b77a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions include/drjit-core/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +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
/// If the \c domain is a nullptr, it returns the number of active entries in
/// all domains for the given backend
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);
extern JIT_EXPORT void jit_registry_get_pointers(JitBackend backend, void **dest);

/// Return the pointer value associated with a given instance ID
extern JIT_EXPORT void *jit_registry_ptr(JitBackend backend,
Expand Down
4 changes: 2 additions & 2 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,9 @@ uint32_t jit_registry_id_bound(JitBackend backend, const char *domain) {
return jitc_registry_id_bound(backend, domain);
}

void jit_registry_fill_ptrs(JitBackend backend, void **dest) {
void jit_registry_get_pointers(JitBackend backend, void **dest) {
lock_guard guard(state.lock);
return jitc_registry_fill_ptrs(backend, dest);
return jitc_registry_get_pointers(backend, dest);
}

void *jit_registry_ptr(JitBackend backend, const char *domain, uint32_t id) {
Expand Down
18 changes: 9 additions & 9 deletions src/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ 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;
uint32_t n = 0;
for (Domain &domain : r.domains) {
if (domain.backend == backend)
for (auto ptr : domain.fwd_map)
if (ptr.active)
i++;
n++;
}
return i;
return n;
}
auto it = r.domain_ids.find(DomainKey{ backend, domain });
if (it == r.domain_ids.end())
Expand All @@ -168,16 +168,16 @@ uint32_t jitc_registry_id_bound(JitBackend backend, const char *domain) {
return r.domains[it->second].id_bound;
}

void jitc_registry_fill_ptrs(JitBackend backend, void **dest) {
Registry &r = registry;
void jitc_registry_get_pointers(JitBackend backend, void **dest) {
const Registry &r = registry;

uint32_t i = 0;
for (Domain &domain : r.domains) {
uint32_t n = 0;
for (const Domain &domain : r.domains) {
if (domain.backend == backend)
for (auto ptr : domain.fwd_map) {
if (ptr.active) {
dest[i] = ptr.ptr;
i++;
dest[n] = ptr.ptr;
n++;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +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
/// If the \c domain is a nullptr, it returns the number of active entries in
/// all domains for the given backend
extern uint32_t jitc_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
void extern jitc_registry_fill_ptrs(JitBackend backend, void **dest);
void extern jitc_registry_get_pointers(JitBackend backend, void **dest);

/// Return the pointer value associated with a given instance ID
extern void *jitc_registry_ptr(JitBackend backend, const char *domain, uint32_t id);
Expand Down

0 comments on commit 07b77a8

Please sign in to comment.