From c7a291ac816cee10380b610f97acd4e9ea527f10 Mon Sep 17 00:00:00 2001 From: "enzyme-ci-bot[bot]" <78882869+enzyme-ci-bot[bot]@users.noreply.github.com> Date: Sat, 8 Feb 2025 07:34:54 +0000 Subject: [PATCH] Format code --- ext/ReactantCUDAExt.jl | 16 +++++++++++----- src/Compiler.jl | 36 +++++++++++++++++++----------------- src/Reactant.jl | 8 ++++---- src/XLA.jl | 16 ++++++++-------- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/ext/ReactantCUDAExt.jl b/ext/ReactantCUDAExt.jl index 4ce7fcfe81..1a8de8086d 100644 --- a/ext/ReactantCUDAExt.jl +++ b/ext/ReactantCUDAExt.jl @@ -459,7 +459,9 @@ function vendored_optimize_module!( end end -function vendored_buildEarlyOptimizerPipeline(mpm, @nospecialize(job), opt_level; instcombine=false) +function vendored_buildEarlyOptimizerPipeline( + mpm, @nospecialize(job), opt_level; instcombine=false +) LLVM.add!(mpm, LLVM.NewPMCGSCCPassManager()) do cgpm # TODO invokeCGSCCCallbacks LLVM.add!(cgpm, LLVM.NewPMFunctionPassManager()) do fpm @@ -496,7 +498,9 @@ function vendored_buildEarlyOptimizerPipeline(mpm, @nospecialize(job), opt_level end end -function vendored_buildIntrinsicLoweringPipeline(mpm, @nospecialize(job), opt_level; instcombine::Bool=false) +function vendored_buildIntrinsicLoweringPipeline( + mpm, @nospecialize(job), opt_level; instcombine::Bool=false +) GPUCompiler.add!(mpm, LLVM.Interop.RemoveNIPass()) # lower GC intrinsics @@ -561,7 +565,9 @@ function vendored_buildIntrinsicLoweringPipeline(mpm, @nospecialize(job), opt_le else LLVM.add!(fpm, LLVM.InstSimplifyPass()) end - LLVM.add!(fpm, LLVM.SimplifyCFGPass(; GPUCompiler.AggressiveSimplifyCFGOptions...)) + LLVM.add!( + fpm, LLVM.SimplifyCFGPass(; GPUCompiler.AggressiveSimplifyCFGOptions...) + ) end end @@ -570,7 +576,7 @@ function vendored_buildIntrinsicLoweringPipeline(mpm, @nospecialize(job), opt_le # Julia's operand bundles confuse the inliner, so repeat here now they are gone. # FIXME: we should fix the inliner so that inlined code gets optimized early-on - LLVM.add!(mpm, LLVM.AlwaysInlinerPass()) + return LLVM.add!(mpm, LLVM.AlwaysInlinerPass()) end function vendored_buildNewPMPipeline!(mpm, @nospecialize(job), opt_level) @@ -595,7 +601,7 @@ function vendored_buildNewPMPipeline!(mpm, @nospecialize(job), opt_level) # end end vendored_buildIntrinsicLoweringPipeline(mpm, job, opt_level) - GPUCompiler.buildCleanupPipeline(mpm, job, opt_level) + return GPUCompiler.buildCleanupPipeline(mpm, job, opt_level) end # compile to executable machine code diff --git a/src/Compiler.jl b/src/Compiler.jl index d6d0d602ce..fa69d58060 100644 --- a/src/Compiler.jl +++ b/src/Compiler.jl @@ -416,7 +416,10 @@ function optimization_passes(; no_nan::Bool=false, sroa::Bool=false, inline::Boo if sroa push!(passes, "propagate-constant-bounds") if DUMP_LLVMIR[] - push!(passes, "sroa-wrappers{dump_prellvm=true dump_postllvm=true instcombine=false instsimplify=true}") + push!( + passes, + "sroa-wrappers{dump_prellvm=true dump_postllvm=true instcombine=false instsimplify=true}", + ) else push!(passes, "sroa-wrappers{instcombine=false instsimplify=true}") end @@ -558,7 +561,6 @@ end const DEBUG_KERNEL = Ref{Bool}(false) const DUMP_LLVMIR = Ref{Bool}(false) - const Raise = Ref{Bool}(false) function compile_mlir!( @@ -657,7 +659,7 @@ function compile_mlir!( opt_passes2, kern, raise, - jit + jit, ], ',', ), @@ -711,7 +713,7 @@ function compile_mlir!( "remove-unnecessary-enzyme-ops", "enzyme-simplify-math", opt_passes2, - kern + kern, ], ',', ), @@ -758,7 +760,7 @@ function compile_mlir!( opt_passes2, kern, raise, - jit + jit, ], ',', ), @@ -769,21 +771,21 @@ function compile_mlir!( mod, "$enzyme_pass,arith-raise{stablehlo=true}"; enable_verifier=false ) run_pass_pipeline!( - mod, join([ - "canonicalize,remove-unnecessary-enzyme-ops,enzyme-simplify-math", - kern, - raise, - jit - ], ',') + mod, + join( + [ + "canonicalize,remove-unnecessary-enzyme-ops,enzyme-simplify-math", + kern, + raise, + jit, + ], + ',', + ), ) elseif optimize === :canonicalize - run_pass_pipeline!( - mod, "canonicalize" - ) + run_pass_pipeline!(mod, "canonicalize") elseif optimize === :just_batch - run_pass_pipeline!( - mod, "enzyme-batch" - ) + run_pass_pipeline!(mod, "enzyme-batch") elseif optimize !== :none error("Invalid optimize option: $(Meta.quot(optimize))") end diff --git a/src/Reactant.jl b/src/Reactant.jl index 8440aec2bf..e3b8d86bec 100644 --- a/src/Reactant.jl +++ b/src/Reactant.jl @@ -160,10 +160,10 @@ function initialize_dialect() registry[]::MLIR.API.MlirDialectRegistry )::Cvoid if !passes_initialized[] - @ccall MLIR.API.mlir_c.InitializePasses( - registry[]::MLIR.API.MlirDialectRegistry - )::Cvoid - passes_initialized[] = true + @ccall MLIR.API.mlir_c.InitializePasses( + registry[]::MLIR.API.MlirDialectRegistry + )::Cvoid + passes_initialized[] = true end return nothing end diff --git a/src/XLA.jl b/src/XLA.jl index 6511efd498..1f6387106b 100644 --- a/src/XLA.jl +++ b/src/XLA.jl @@ -217,15 +217,15 @@ function __init__() println(stdout, e) end else - if !Reactant.precompiling() - try - gpu = GPUClient() - backends["gpu"] = gpu - default_backend[] = gpu - catch e - println(stdout, e) + if !Reactant.precompiling() + try + gpu = GPUClient() + backends["gpu"] = gpu + default_backend[] = gpu + catch e + println(stdout, e) + end end - end end end