Skip to content

MemoryRef layout fix#2746

Merged
wsmoses merged 7 commits intomainfrom
mrl
Nov 6, 2025
Merged

MemoryRef layout fix#2746
wsmoses merged 7 commits intomainfrom
mrl

Conversation

@wsmoses
Copy link
Member

@wsmoses wsmoses commented Nov 6, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/utils.jl b/src/utils.jl
index d61060bf..c8ddf176 100644
--- a/src/utils.jl
+++ b/src/utils.jl
@@ -462,23 +462,23 @@ end
 
 else
 
-function is_memory_ref_field2_an_offset(@nospecialize(T::Type{<:GenericMemoryRef}))
-    ET = eltype(T)
+    function is_memory_ref_field2_an_offset(@nospecialize(T::Type{<:GenericMemoryRef}))
+        ET = eltype(T)
 
-    # 0 = inlinealloc
-    # 1 = isboxed
-    # 2 = isbitsunion
-    return (Base.datatype_arrayelem(T.types[2]) == 2) || Base.datatype_layoutsize(T.types[2]) == 0
-end
+        # 0 = inlinealloc
+        # 1 = isboxed
+        # 2 = isbitsunion
+        return (Base.datatype_arrayelem(T.types[2]) == 2) || Base.datatype_layoutsize(T.types[2]) == 0
+    end
 
 @inline function typed_fieldtype(@nospecialize(T::Type), i::Int)::Type
     if T <: GenericMemoryRef && i == 1 || T <: GenericMemory && i == 2
-        if T <: GenericMemoryRef && i == 1 && is_memory_ref_field2_an_offset(T)
-            Int
-        else
-            eT = eltype(T)
-            Ptr{eT}
-        end
+            if T <: GenericMemoryRef && i == 1 && is_memory_ref_field2_an_offset(T)
+                Int
+            else
+                eT = eltype(T)
+                Ptr{eT}
+            end
     else
         fieldtype(T, i)
     end

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Benchmark Results

main 5f359d5... main / 5f359d5...
basics/make_zero/namedtuple 0.0556 ± 0.0028 μs 0.0578 ± 0.003 μs 0.961 ± 0.069
basics/make_zero/struct 0.26 ± 0.0063 μs 0.276 ± 0.0082 μs 0.941 ± 0.036
basics/overhead 4.34 ± 0.01 ns 5.26 ± 0.01 ns 0.825 ± 0.0025
basics/remake_zero!/namedtuple 0.24 ± 0.0097 μs 0.241 ± 0.011 μs 0.994 ± 0.06
basics/remake_zero!/struct 0.234 ± 0.01 μs 0.242 ± 0.015 μs 0.966 ± 0.072
fold_broadcast/multidim_sum_bcast/1D 10.3 ± 0.26 μs 10.3 ± 0.32 μs 1 ± 0.04
fold_broadcast/multidim_sum_bcast/2D 12.2 ± 0.29 μs 12.3 ± 0.39 μs 0.998 ± 0.04
time_to_load 1.34 ± 0.002 s 1.35 ± 0.0024 s 0.989 ± 0.0023

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/19122850316/artifacts/4482132207.

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.01%. Comparing base (97dbf1b) to head (5f359d5).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2746   +/-   ##
=======================================
  Coverage   70.00%   70.01%           
=======================================
  Files          58       58           
  Lines       19295    19300    +5     
=======================================
+ Hits        13507    13512    +5     
  Misses       5788     5788           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wsmoses wsmoses merged commit f8f2b44 into main Nov 6, 2025
50 of 52 checks passed
@wsmoses wsmoses deleted the mrl branch November 6, 2025 04:09
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.

2 participants