Skip to content

Commit 2c2a339

Browse files
chore: enable memory effects pass (#1237)
* chore: enable memory effects pass * Update src/Compiler.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8c255bb commit 2c2a339

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

ext/ReactantCUDAExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,14 +1191,14 @@ Reactant.@reactant_overlay @noinline function (func::LLVMFunc{F,tt})(
11911191
)
11921192
end
11931193

1194-
location = MLIR.IR.Location()
11951194
@assert length(restys) == length(aliases)
11961195
call = MLIR.Dialects.enzymexla.kernel_call(
11971196
blk_operands...,
11981197
mlir_args;
11991198
result_0=restys,
12001199
fn=MLIR.IR.FlatSymbolRefAttribute(sym_name),
12011200
output_operand_aliases=MLIR.IR.Attribute(output_operand_aliases),
1201+
xla_side_effect_free=MLIR.IR.UnitAttribute(),
12021202
)
12031203

12041204
argidx = 1

src/Compiler.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ function compile_mlir!(
12741274
join(
12751275
if raise_first
12761276
[
1277+
"mark-func-memory-effects",
12771278
opt_passes,
12781279
kern,
12791280
raise_passes,
@@ -1289,6 +1290,7 @@ function compile_mlir!(
12891290
]
12901291
else
12911292
[
1293+
"mark-func-memory-effects",
12921294
opt_passes,
12931295
"enzyme-batch",
12941296
opt_passes2,
@@ -1312,9 +1314,10 @@ function compile_mlir!(
13121314
mod,
13131315
join(
13141316
if raise_first
1315-
[opt_passes]
1317+
["mark-func-memory-effects", opt_passes]
13161318
else
13171319
[
1320+
"mark-func-memory-effects",
13181321
opt_passes,
13191322
"enzyme-batch",
13201323
opt_passes2,
@@ -1336,6 +1339,7 @@ function compile_mlir!(
13361339
join(
13371340
if raise_first
13381341
[
1342+
"mark-func-memory-effects",
13391343
opt_passes,
13401344
kern,
13411345
raise_passes,
@@ -1350,6 +1354,7 @@ function compile_mlir!(
13501354
]
13511355
else
13521356
[
1357+
"mark-func-memory-effects",
13531358
opt_passes,
13541359
"enzyme-batch",
13551360
opt_passes2,
@@ -1372,9 +1377,10 @@ function compile_mlir!(
13721377
mod,
13731378
join(
13741379
if raise_first
1375-
[opt_passes]
1380+
["mark-func-memory-effects", opt_passes]
13761381
else
13771382
[
1383+
"mark-func-memory-effects",
13781384
opt_passes,
13791385
"enzyme-batch",
13801386
opt_passes2,
@@ -1396,6 +1402,7 @@ function compile_mlir!(
13961402
mod,
13971403
join(
13981404
[
1405+
"mark-func-memory-effects",
13991406
opt_passes,
14001407
"enzyme-batch",
14011408
opt_passes2,
@@ -1415,6 +1422,7 @@ function compile_mlir!(
14151422
mod,
14161423
join(
14171424
[
1425+
"mark-func-memory-effects",
14181426
"enzyme-batch",
14191427
enzyme_pass,
14201428
"canonicalize",
@@ -1431,6 +1439,7 @@ function compile_mlir!(
14311439
join(
14321440
if raise_first
14331441
[
1442+
"mark-func-memory-effects",
14341443
kern,
14351444
raise_passes,
14361445
"enzyme-batch",
@@ -1443,6 +1452,7 @@ function compile_mlir!(
14431452
]
14441453
else
14451454
[
1455+
"mark-func-memory-effects",
14461456
"enzyme-batch",
14471457
enzyme_pass,
14481458
"canonicalize",
@@ -1464,6 +1474,7 @@ function compile_mlir!(
14641474
join(
14651475
if raise_first
14661476
[
1477+
"mark-func-memory-effects",
14671478
opt_passes,
14681479
kern,
14691480
raise_passes,
@@ -1475,6 +1486,7 @@ function compile_mlir!(
14751486
]
14761487
else
14771488
[
1489+
"mark-func-memory-effects",
14781490
opt_passes,
14791491
"enzyme-batch",
14801492
opt_passes2,
@@ -1490,7 +1502,7 @@ function compile_mlir!(
14901502
"after_enzyme",
14911503
)
14921504
elseif optimize === :canonicalize
1493-
run_pass_pipeline!(mod, "canonicalize", "canonicalize")
1505+
run_pass_pipeline!(mod, "mark-func-memory-effects,canonicalize", "canonicalize")
14941506
elseif optimize === :just_batch
14951507
run_pass_pipeline!(mod, "enzyme-batch", "enzyme-batch")
14961508
elseif optimize isa String

0 commit comments

Comments
 (0)