Skip to content

Commit 3f84d55

Browse files
Added opaque width for freezing mean
1 parent eb26a2e commit 3f84d55

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

include/drjit-core/array.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ template <JitBackend Backend_, typename Value_> struct JitArray {
255255

256256
auto symbolic_width() {
257257
using UInt32 = JitArray<Backend_, uint32_t>;
258-
return UInt32::steal(jit_var_symbolic_width(m_index));
258+
return UInt32::steal(jit_var_opaque_width(m_index));
259259
}
260260

261261
void resize(size_t size) {

include/drjit-core/jit.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,9 @@ extern JIT_EXPORT uint32_t jit_var_data(uint32_t index, void **ptr_out);
11761176
/// Query the size of a given variable
11771177
extern JIT_EXPORT size_t jit_var_size(uint32_t index);
11781178

1179-
extern JIT_EXPORT uint32_t jit_var_symbolic_width(uint32_t index);
1179+
/// Query the size of a given variable, as an opaque variable. This also
1180+
/// notifies the ThreadState, allowing us to record this for frozen functions.
1181+
extern JIT_EXPORT uint32_t jit_var_opaque_width(uint32_t index);
11801182

11811183
/// Query the type of a given variable
11821184
extern JIT_EXPORT JIT_ENUM VarType jit_var_type(uint32_t index);

src/api.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ size_t jit_var_size(uint32_t index) {
610610
return (size_t) jitc_var(index)->size;
611611
}
612612

613-
uint32_t jit_var_symbolic_width(uint32_t index){
613+
uint32_t jit_var_opaque_width(uint32_t index){
614614
if(index == 0)
615615
return 0;
616616

@@ -619,6 +619,9 @@ uint32_t jit_var_symbolic_width(uint32_t index){
619619
Variable *var = jitc_var(index);
620620
uint32_t var_size = var->size;
621621

622+
// The variable has to be evaluated, to notify the ThreadState
623+
jitc_var_eval(index);
624+
622625
uint32_t width_index = jitc_var_literal(
623626
(JitBackend) var->backend, VarType::UInt32, &var_size, 1, true);
624627

tests/record.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ TEST_LLVM(10_scatter) {
251251

252252
TEST_BOTH(11_symbolic_width) {
253253
auto func = [](UInt32 x) {
254-
auto y = block_prefix_sum(x, x.size());
255-
y = y / x.symbolic_width();
254+
auto y = block_prefix_sum(x+1, x.size());
255+
if (jit_flag(JitFlag::FreezingScope))
256+
y = y / x.symbolic_width();
257+
else
258+
y = y / x.size();
256259
return y;
257260
};
258261

0 commit comments

Comments
 (0)